ziglings/exercises
60
1.5k
Fork
You've already forked exercises
478

"zig build" only works from ziglings's root directory #474

Closed
opened 2026年06月26日 04:08:24 +02:00 by perryprog · 3 comments

It seems that Elrond is assuming that the CWD is the root of the project as running zig build from, for example, the exercises directory results in this:

Output
~/git/ziglings/exercises main
❯ zig build
[... snip ...]
Progress: [>-----------------------------------------------------------] 1/115
Compiling 001_hello.zig...
Checking 001_hello.zig...
error: failed to check cache: 'exercises/001_hello.zig' file_hash FileNotFound
[... snip ...]
Edit exercises/001_hello.zig and run 'zig build' again.
ziglings
└run exe elrond failure
[... snip ...]

While when run from the root of the project:

Output
❯ /Users/perry/git/zig/stage3/bin/zig build
[... snip ...]
Progress: [>-----------------------------------------------------------] 1/115
Compiling 001_hello.zig...
Checking 001_hello.zig...
/Users/perry/git/zig/stage3/lib/zig/std/start.zig:750:43: error: 'main' is not marked 'pub'
 const fn_info = @typeInfo(@TypeOf(root.main)).@"fn";
 ~~~~^~~~~
exercises/001_hello.zig:19:1: note: declared here
fn main() void {
^~~~~~~~~~~~~~
/Users/perry/git/zig/stage3/lib/zig/std/start.zig:692:20: note: called inline here
 return callMain(argv[0..argc], env_block);
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/perry/git/zig/stage3/lib/zig/std/start.zig:644:38: note: called inline here
 std.process.exit(callMainWithArgs(argc, argv, envp));
 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
referenced by:
 _start: /Users/perry/git/zig/stage3/lib/zig/std/start.zig:523:40
 comptime: /Users/perry/git/zig/stage3/lib/zig/std/start.zig:86:67
 2 reference(s) hidden; use '-freference-trace=4' to see all references
[... snip ...]
Edit exercises/001_hello.zig and run 'zig build' again.
ziglings
└run exe elrond failure
[... snip ...]

(The specific use-case that I found this affecting was in emacs where zig-mode will run zig build in the directory of whatever file you're currently in when using M-x zig-compile.)

It seems that Elrond is assuming that the CWD is the root of the project as running `zig build` from, for example, the exercises directory results in this: <details> <summary>Output</summary> ``` ~/git/ziglings/exercises main ❯ zig build [... snip ...] Progress: [>-----------------------------------------------------------] 1/115 Compiling 001_hello.zig... Checking 001_hello.zig... error: failed to check cache: 'exercises/001_hello.zig' file_hash FileNotFound [... snip ...] Edit exercises/001_hello.zig and run 'zig build' again. ziglings └run exe elrond failure [... snip ...] ``` </details> While when run from the root of the project: <details> <summary>Output</summary> ``` ❯ /Users/perry/git/zig/stage3/bin/zig build [... snip ...] Progress: [>-----------------------------------------------------------] 1/115 Compiling 001_hello.zig... Checking 001_hello.zig... /Users/perry/git/zig/stage3/lib/zig/std/start.zig:750:43: error: 'main' is not marked 'pub' const fn_info = @typeInfo(@TypeOf(root.main)).@"fn"; ~~~~^~~~~ exercises/001_hello.zig:19:1: note: declared here fn main() void { ^~~~~~~~~~~~~~ /Users/perry/git/zig/stage3/lib/zig/std/start.zig:692:20: note: called inline here return callMain(argv[0..argc], env_block); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/perry/git/zig/stage3/lib/zig/std/start.zig:644:38: note: called inline here std.process.exit(callMainWithArgs(argc, argv, envp)); ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ referenced by: _start: /Users/perry/git/zig/stage3/lib/zig/std/start.zig:523:40 comptime: /Users/perry/git/zig/stage3/lib/zig/std/start.zig:86:67 2 reference(s) hidden; use '-freference-trace=4' to see all references [... snip ...] Edit exercises/001_hello.zig and run 'zig build' again. ziglings └run exe elrond failure [... snip ...] ``` </details> (The specific use-case that I found this affecting was in emacs where zig-mode will run zig build in the directory of whatever file you're currently in when using `M-x zig-compile`.)

thanks, now I added the absolute root path to the exercises, that should fix it.

thanks, now I added the absolute root path to the exercises, that should fix it.

Looks like this is still an issue with exercise 105, probably because it's a "test" exercise instead of an exe.

Looks like this is still an issue with exercise 105, probably because it's a "test" exercise instead of an exe.

will test it again

will test it again
Sign in to join this conversation.
No Branch/Tag specified
main
v0.16.0
v0.15.1
v0.14.0
v0.13.0
v0.12.0
v0.11.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglings/exercises#474
Reference in a new issue
ziglings/exercises
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?