jetzig-framework / jetzig

Jetzig is a web framework written in Zig
MIT License
579 stars 25 forks source link

required Zig version? errors on zig build run #98

Closed devara-gheist closed 2 months ago

devara-gheist commented 2 months ago

I'm using Zig version 0.12 and I followed the instruction both from Jetzig's youtube and website. Everything went fine until i execute: zig build run.

Got these error messages:

warning: [zmpl] Templates path not found: src/app/mailers - skipping.
run
└─ run demo
└─ install
└─ install demo
└─ zig build-exe demo Debug native 6 errors
/home/mxlinux/.cache/zig/p/1220efbc744de6e13e57ab9fa6370ea9690601e55ba6ced74179c081a295c99fd422/src/worker.zig:1388:57: error: no field named 'sec' in struct 'os.linux.x86_64.timeval'
const timeout = std.mem.toBytes(std.posix.timeval{ .sec = 5, .usec = 0 });
^~~
/home/mxlinux/.zig/lib/std/os/linux/x86_64.zig:274:28: note: struct declared here
pub const timeval = extern struct {
~~~~~~~^~~~~~
referenced by:
serverError__anon_19861: /home/mxlinux/.cache/zig/p/1220efbc744de6e13e57ab9fa6370ea9690601e55ba6ced74179c081a295c99fd422/src/worker.zig:1379:22
requestParseError: /home/mxlinux/.cache/zig/p/1220efbc744de6e13e57ab9fa6370ea9690601e55ba6ced74179c081a295c99fd422/src/worker.zig:1370:35
remaining reference traces hidden; use '-freference-trace' to see all reference traces
/home/mxlinux/.cache/zig/p/1220efbc744de6e13e57ab9fa6370ea9690601e55ba6ced74179c081a295c99fd422/src/worker.zig:1334:24: error: no field named 'sec' in struct 'os.linux.timespec'
return @intcast(ts.sec);
^~~
/home/mxlinux/.zig/lib/std/os/linux.zig:6086:29: note: struct declared here
pub const timespec = extern struct {
~~~~~~~^~~~~~
/home/mxlinux/.cache/zig/p/1220efbc744de6e13e57ab9fa6370ea9690601e55ba6ced74179c081a295c99fd422/src/worker.zig:1388:57: error: no field named 'sec' in struct 'os.linux.x86_64.timeval'
const timeout = std.mem.toBytes(std.posix.timeval{ .sec = 5, .usec = 0 });
^~~
/home/mxlinux/.zig/lib/std/os/linux/x86_64.zig:274:28: note: struct declared here
pub const timeval = extern struct {
~~~~~~~^~~~~~
/home/mxlinux/.cache/zig/p/1220efbc744de6e13e57ab9fa6370ea9690601e55ba6ced74179c081a295c99fd422/src/worker.zig:1388:57: error: no field named 'sec' in struct 'os.linux.x86_64.timeval'
const timeout = std.mem.toBytes(std.posix.timeval{ .sec = 5, .usec = 0 });
^~~
/home/mxlinux/.zig/lib/std/os/linux/x86_64.zig:274:28: note: struct declared here
pub const timeval = extern struct {
~~~~~~~^~~~~~
/home/mxlinux/.cache/zig/p/1220a36b9f1be391d474a22f7f52a3e8bd8027ac523d2db19c987328a03041ab1412/src/server/server.zig:1277:17: error: no field named 'len' in struct 'posix.iovec_const'
.{ .len = buf.len, .base = &buf },
^~~
/home/mxlinux/.zig/lib/std/posix.zig:180:32: note: struct declared here
pub const iovec_const = extern struct {
~~~~~~~^~~~~~
/home/mxlinux/.cache/zig/p/1220a36b9f1be391d474a22f7f52a3e8bd8027ac523d2db19c987328a03041ab1412/src/server/server.zig:1299:17: error: no field named 'len' in struct 'posix.iovec_const'
.{ .len = header.len, .base = header.ptr },
^~~
/home/mxlinux/.zig/lib/std/posix.zig:180:32: note: struct declared here
pub const iovec_const = extern struct {
~~~~~~~^~~~~~
error: the following command failed with 6 compilation errors:
/home/mxlinux/.zig/zig build-exe -ODebug --dep jetzig --dep zmpl --dep zmd --dep routes --dep static -Mroot=/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/src/main.zig --dep mime_types --dep zmpl --dep args --dep zmd --dep jetkv --dep smtp --dep httpz -Mjetzig=/home/mxlinux/.cache/zig/p/1220ffe0c1f7a7d3a7b6d87346e945bbf818cfb6c03601110d91a069ab7da741dd82/src/jetzig.zig --dep zmd --dep zmpl.manifest -Mzmpl=/home/mxlinux/.cache/zig/p/12207c30c6fbcb8c7519719fc47ff9d0acca72a3557ec671984d16260bdf1c832740/src/zmpl.zig -Mzmd=/home/mxlinux/.cache/zig/p/12203b56c2e17a2fd62ea3d3d9be466f43921a3aef88b381cf58f41251815205fdb5/src/zmd.zig --dep jetzig --dep zmpl --dep zmd --dep routes -Mroutes=/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache/o/8f03171ddcfa0f662ec5ce819d464db1/routes.zig -Mstatic=/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache/o/24445ad921dee9b77e678d0cd7a67830/static.zig -Mmime_types=/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache/o/72b25efd1d10b0e9b932ba7abe9814d6/mime_types.zig -Margs=/home/mxlinux/.cache/zig/p/1220904d2fdcd970dd0d216211d092eb3ef6da01117163cc9393ab845a1d66c029d9/args.zig -Mjetkv=/home/mxlinux/.cache/zig/p/1220434169bfbfbb3a0bbe7073f9bcff5401979a967d25ba3915046f6ea44e40839d/src/jetkv.zig -Msmtp=/home/mxlinux/.cache/zig/p/1220cebfcf6c63295819df92ec54abe62aad91b1d16666781194c29a7874bb7bbbda/src/smtp.zig --dep metrics --dep websocket --dep build -Mhttpz=/home/mxlinux/.cache/zig/p/1220efbc744de6e13e57ab9fa6370ea9690601e55ba6ced74179c081a295c99fd422/src/httpz.zig --dep zmpl --dep zmd -Mzmpl.manifest=/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache/o/4e1ae03e9522554ad85e061535a065a8/zmpl.manifest.zig -Mmetrics=/home/mxlinux/.cache/zig/p/1220232ab38d0c2cfb10680115c17ad2fa1a8531dbaf8bbfb359ec67e80c7d5f5758/src/metrics.zig --dep build=build0 -Mwebsocket=/home/mxlinux/.cache/zig/p/1220a36b9f1be391d474a22f7f52a3e8bd8027ac523d2db19c987328a03041ab1412/src/websocket.zig -Mbuild=/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache/c/c3224a9469deeb49ba950b1e58a2caf5/options.zig -Mbuild0=/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache/c/d485b2be29cea3d49688178f61cc1037/options.zig --cache-dir /home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache --global-cache-dir /home/mxlinux/.cache/zig --name demo --listen=-
Build Summary: 11/16 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run demo transitive failure
├─ zig build-exe demo Debug native 6 errors
└─ install transitive failure
└─ install demo transitive failure
└─ zig build-exe demo Debug native (+21 more reused dependencies)
error: the following build command failed with exit code 1:
/home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache/o/24762782203da7ee5d436aadc2b6f087/build /home/mxlinux/.zig/zig /home/mxlinux/Documents/programming/languages/zig/jetzig/demo /home/mxlinux/Documents/programming/languages/zig/jetzig/demo/zig-cache /home/mxlinux/.cache/zig --seed 0x8c13b624 -Z816b2868d8c7c0a1 run

using ZVM i've tried zig build run using version 0.13.0 and master. The 0.13.0 got similar error messages to the 0.12.0 above, while master still encountering error:

/home/mxlinux/.cache/zig/p/12207c30c6fbcb8c7519719fc47ff9d0acca72a3557ec671984d16260bdf1c832740/build.zig:156:10: error: no field named 'Struct' in enum '@typeinfo(builtin.Type).@"union".tag_type.?'
.Struct => |info| info.fields,
~^~~~~~
/home/mxlinux/.zvm/master/lib/std/builtin.zig:259:18: note: enum declared here
pub const Type = union(enum) {
^~~~~
referenced by:
build: /home/mxlinux/.cache/zig/p/1220ffe0c1f7a7d3a7b6d87346e945bbf818cfb6c03601110d91a069ab7da741dd82/build.zig:48:66
runBuild__anon_60776: /home/mxlinux/.zvm/master/lib/std/Build.zig:2155:44
15 reference(s) hidden; use '-freference-trace=17' to see all references

Please advise.

bobf commented 2 months ago

@devara-gheist The issues you have been having were due to compatibility with different Zig versions (as it looks like you guessed by trying different versions).

Unfortunately a recent change to Zig master broke a lot of code (changes to Type), including in some of Jetzig's dependencies. Luckily those dependencies have all been fixed and I've just pushed a commit to Jetzig's main branch to include all the fixed dependencies plus a number of fixes to Jetzig and some other components of the framework (Zmpl, JetKV, Zmd).

All tests are passing for me on main using latest Zig nightly (0.14.0-dev.1366+d997ddaa1) and I'm able to run a server.

Using a pre-1.0 language can be quite interesting at times. :-)

Let me know if you're still having issues using latest Zig master.

devara-gheist commented 2 months ago

hi thanks for the reply. I have installed Zig nightly and cloned the latest jetzig. Below is my zig version (same version as yours) : image

On zig build install the jetzig cli I'm still encountering errors:

 ~/Downloads/jetzig/cli | main                                                               
> zig build install
install
└─ install jetzig
   └─ zig build-exe jetzig Debug native 1 errors
commands/generate/view.zig:104:35: error: no field named 'Enum' in union 'builtin.Type'
    inline for (@typeInfo(Method).Enum.fields) |tag| {
                                  ^~~~
/home/aabbcc/.zvm/master/lib/std/builtin.zig:259:18: note: union declared here
pub const Type = union(enum) {
                 ^~~~~
referenced by:
    run: commands/generate/view.zig:55:24
    run__anon_3552: commands/generate.zig:94:30
    7 reference(s) hidden; use '-freference-trace=9' to see all references
error: the following command failed with 1 compilation errors:
/home/aabbcc/.zvm/master/zig build-exe -ODebug --dep args --dep init_data -Mroot=/home/aabbcc/Downloads/jetzig/cli/cli.zig -Margs=/home/aabbcc/.cache/zig/p/1220411a8c46d95bbf3b6e2059854bcb3c5159d428814099df5294232b9980517e9c/args.zig -Minit_data=/home/aabbcc/Downloads/jetzig/cli/.zig-cache/o/cd7c89230911e4949d77db55abab12d2/init_data.zig --cache-dir /home/aabbcc/Downloads/jetzig/cli/.zig-cache --global-cache-dir /home/aabbcc/.cache/zig --name jetzig --zig-lib-dir /home/aabbcc/.zvm/master/lib/ --listen=-
Build Summary: 1/4 steps succeeded; 1 failed
install transitive failure
└─ install jetzig transitive failure
   └─ zig build-exe jetzig Debug native 1 errors
error: the following build command failed with exit code 1:
/home/aabbcc/Downloads/jetzig/cli/.zig-cache/o/cb1f1fa5ddcc209121e250bad1bc1791/build /home/aabbcc/.zvm/master/zig /home/aabbcc/.zvm/master/lib /home/aabbcc/Downloads/jetzig/cli /home/aabbcc/Downloads/jetzig/cli/.zig-cache /home/aabbcc/.cache/zig --seed 0x71d457a -Z78dfbb728d2f17de install

yeah got stuck on: no field named 'Enum' in union 'builtin.Type'. Again thanks for the help, appreciate it!

bobf commented 2 months ago

Ah, I missed one ! I just pushed a fix to main.

I created a new project using jetzig init (after compiling the CLI tool described here) and was able to launch the project successfully.

Thanks for your patience on this, hopefully everything will work for you now.

devara-gheist commented 2 months ago

it's working!

image

Thanks for this, I've been looking to rewrite my Python webapps using Zig and now I'm one step closer via Jetzig. Cheers!

bobf commented 2 months ago

@devara-gheist Nice ! Feel free free to swing by our discord if you need help with anything, or just create issues here.