Zig Version
0.14.0-dev.3239+d7b93c787
Steps to Reproduce and Observed Output
- initialize a new project with
zig init
- add
const foo = @import("non_existent_file.zig"); to src/main.zig
- run
zig build
The observed output is the following:
install
└─ install zig-testspace
└─ zig build-exe zig-testspace Debug native 1 errors
error: unable to load 'src/non_existent_file.zig': FileNotFound
error: the following command failed with 1 compilation errors:
/home/techatrix/.config/Code/User/globalStorage/ziglang.vscode-zig/zig/linux-x86_64-0.14.0-dev.3239+d7b93c787/zig build-exe -ODebug --dep zig-testspace_lib -Mroot=/home/techatrix/zig-testspace/src/main.zig -ODebug -Mzig-testspace_lib=/home/techatrix/zig-testspace/src/root.zig --cache-dir /home/techatrix/zig-testspace/.zig-cache --global-cache-dir /home/techatrix/.cache/zig --name zig-testspace --zig-lib-dir /home/techatrix/.config/Code/User/globalStorage/ziglang.vscode-zig/zig/linux-x86_64-0.14.0-dev.3239+d7b93c787/lib/ --listen=-
Build Summary: 2/5 steps succeeded; 1 failed
install transitive failure
└─ install zig-testspace transitive failure
└─ zig build-exe zig-testspace Debug native 1 errors
error: the following build command failed with exit code 1:
/home/techatrix/zig-testspace/.zig-cache/o/0ecb37263bb79ce3abd63cb0ab38457a/build /home/techatrix/.config/Code/User/globalStorage/ziglang.vscode-zig/zig/linux-x86_64-0.14.0-dev.3239+d7b93c787/zig /home/techatrix/.config/Code/User/globalStorage/ziglang.vscode-zig/zig/linux-x86_64-0.14.0-dev.3239+d7b93c787/lib /home/techatrix/zig-testspace /home/techatrix/zig-testspace/.zig-cache /home/techatrix/.cache/zig --seed 0x3c5952fd -Z094682ccc96a6f25
Expected Output
I would expect an error message that is identical to running zig run src/main.zig:
src/main.zig:5:21: error: unable to load 'src/non_existent_file.zig': FileNotFound
const foo = @import("non_existent_file.zig");
^~~~~~~~~~~~~~~~~~~~~~~
I also noticed that zig build --watch -fincremental will report the correct error message but only on the first compile cycle.
The missing source location stops ZLS's build on save feature from providing an error message in this situation. See zigtools/zls#2196.
Zig Version
0.14.0-dev.3239+d7b93c787
Steps to Reproduce and Observed Output
zig initconst foo = @import("non_existent_file.zig");tosrc/main.zigzig buildThe observed output is the following:
Expected Output
I would expect an error message that is identical to running
zig run src/main.zig:I also noticed that
zig build --watch -fincrementalwill report the correct error message but only on the first compile cycle.The missing source location stops ZLS's build on save feature from providing an error message in this situation. See zigtools/zls#2196.