Skip to content

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

@ianprime0509

Description

@ianprime0509

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messageThis issue points out an error message that is unhelpful and should be improved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions