Hi All,
I got the following error response. I looks like it’s failing because the build file can’t find the addPassthruArgs function or value. The only thing I can think if is that it is a version issue. I am using Zig version 0.16.0. the addPassthruArgs does not exist in the Run.zig file :
❯ ./your_program.sh
build.zig:31:12: error: no field or member function named ‘addPassthruArgs’ in ‘Build.Step.Run’
run_cmd.addPassthruArgs();
~^~~~~~~~~~
/usr/local/zig-x86_64-linux-0.16.0/lib/std/Build/Step/Run.zig:1:1: note: struct declared here
const Run = @This();
^~~~~
build.zig:31:12: note: method invocation only supports up to one level of implicit pointer dereferencing
build.zig:31:12: note: use ‘.*’ to dereference pointer
referenced by:
runBuild__anon_34192: /usr/local/zig-x86_64-linux-0.16.0/lib/std/Build.zig:2264:33
main: /usr/local/zig-x86_64-linux-0.16.0/lib/compiler/build_runner.zig:463:29
5 reference(s) hidden; use ‘-freference-trace=7’ to see all references
Thanks in advance for any help!
Dillon KO
OK I was able to look at the code on a few sites and I had to modify the build file in order to make it work. Since I am on Zig version 0.16.0 and this seems to on 0.17.0. The subtle diffrence was that function. I had to also add the import builtin so I could detect the version. This is the following change I added:
const builtin = @importimport(“builtin”); // added as line #2
I also added the following to replace line 33:
if (comptime builtin.zig_version.minor >= 17) {
run_cmd.addPassthruArgs();
} else {
if (b.args) |args| run_cmd.addArgs(args);
}
This allowed for the app to run and then I got the follwing error. I think this part is expected and I need to add the needed code but just placing it here in case I am wrong:
❯ ./your_program.sh
Logs from your program will appear here!
client connected!codecrafters-http-server-zig on master [!] via ↯ v0.16.0 took 2m13s
❯ codecrafters submit
Submitting changes (commit: 8d6b269)…
This is a turbo test run
Running tests on your code. Logs should appear shortly…
Detected changes to build.zig. Re-building… (this might take a while)
[build] Starting build…
[build] If you don’t see logs for 60s+, please contact us at hello@codecraft
[build] Step 1 complete.
[build] Step 2 complete.
[build] Step 3 complete.
[build] Step 4 complete.
[build] Step 5 complete.
[build] Step 6 complete.
[build] Step 7 complete.
[build] > [auth] Started getting token authority from the client for registry-1.docker.i
[build] > [auth] Completed getting token authority from the client for registry-1.docker.i after 0.031s
[build] Step 8 complete.
[build] Step 9 complete.
[build] Step 10 complete.
[build] Step 11 complete.
[build] Step 12 complete.
[build] Step 13 complete.
[build] Step 14 complete.
[build] Step 15 complete.
[build] Step 16 complete.
[build] Step 17 complete.
[build] Step 18 complete.
[build] Step 19 complete.
[build] Step 20 complete.
[build] Step 21 complete.
[build] Step 22 complete.
[build] Step 23 complete.
[build] Build successful.
[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.
[tester::#IA4] Running tests for Stage #IA4 (Respond with 200)
[tester::#IA4] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[tester::#IA4] $ curl -v http://localhost:4221/
[your_program] client connected!
[tester::#IA4] Failed to read response:
[tester::#IA4] Received: “” (no content received)
[tester::#IA4] ^ error
[tester::#IA4] Error: Expected: HTTP-version, Received: “”
[tester::#IA4] Test failed
View our article on debugging test failures: How do I debug test failures? - CodeCrafters
codecrafters-http-server-zig on master via ↯ v0.16.0 took 2m30s
Best,
Dillon KO