Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading error message for missing path-based dependency used as build helper #22279

Open
ianprime0509 opened this issue Dec 21, 2024 · 0 comments
Labels
error message This issue points out an error message that is unhelpful and should be improved.

Comments

@ianprime0509
Copy link
Contributor

Zig Version

0.14.0-dev.2546+0ff0bdb4a

Steps to Reproduce and Observed Output

Check out the build-dependency-path branch of https://github.com/ianprime0509/pathological-packages (commit 6be4a689b948bf5032156f488ae2d7cabf131fc9). This is a simple example of a project with a dependency specified using path in build.zig.zon which imports that dependency in build.zig as a build helper. Running zig build --help on the project as-is shows that a do-something step has been added to the build.

Now, change the path of the helper dependency in the root build.zig.zon to an incorrect path, such as ./invalid/helper. Run zig build --help again, and now the output is as follows:

/var/home/ian/src/pathological-packages/build.zig:2:24: error: no module named 'helper' available within module root.@build
const helper = @import("helper");
                       ^~~~~~~~
referenced by:
    build: /var/home/ian/src/pathological-packages/build.zig:5:5
    runBuild__anon_4419: /var/home/ian/src/zig/lib/std/Build.zig:2388:33
    6 reference(s) hidden; use '-freference-trace=8' to see all references

Expected Output

The error message should mention that the incorrect path in build.zig.zon does not exist or does not refer to a package which can be imported as a build helper (e.g. if the path exists but does not contain a build.zig).

For comparison, invoking b.dependency("helper", .{}) in the same project with the invalid path yields the following error, which does contain this context:

unable to open '/var/home/ian/src/pathological-packages/invalid/helper': FileNotFound
error: the following build command failed with exit code 1:
/var/home/ian/src/pathological-packages/.zig-cache/o/348eb32a6d21a299b246f2bdb33dbcb8/build /var/home/ian/src/zig/build/stage3/bin/zig /var/home/ian/src/zig/lib /var/home/ian/src/pathological-packages /var/home/ian/src/pathological-packages/.zig-cache /var/home/ian/.cache/zig --seed 0x5063ab2 -Z3a012f4b1ad78b7c --help
@ianprime0509 ianprime0509 added the error message This issue points out an error message that is unhelpful and should be improved. label Dec 21, 2024
@ianprime0509 ianprime0509 changed the title Misleading error message for path-based dependency used as build helper Misleading error message for missing path-based dependency used as build helper Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error message This issue points out an error message that is unhelpful and should be improved.
Projects
None yet
Development

No branches or pull requests

1 participant