prajwalch / yazap

🔧 The ultimate Zig library for seamless command line argument parsing.
https://prajwalch.github.io/yazap
MIT License
152 stars 13 forks source link

Installation fails when `examples` directory is missing #28

Closed xixixao closed 1 month ago

xixixao commented 1 month ago

Total zig n00b here: After I add

const yazap = b.dependency("yazap", .{});
exe.root_module.addImport("yazap", yazap.module("yazap"));

to my build.zig (which I haven't changed from zig init)

I get an error about missing examples directory:

zig build new
thread 17483357 panic: failed to open examples dir
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/posix.zig:1768:23: 0x1006a7f9f in openatZ (build)
            .NOENT => return error.FileNotFound,
                      ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/fs/Dir.zig:1564:21: 0x10067d4d7 in openDirFlagsZ (build)
        else => |e| return e,
                    ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/fs/Dir.zig:1528:5: 0x10063d6a3 in openDirZ (build)
    return self.openDirFlagsZ(sub_path_c, symlink_flags);
    ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/fs/Dir.zig:1472:5: 0x100632f07 in openDir (build)
    return self.openDirZ(&sub_path_c, args);
    ^
/Users/michalsrb/.cache/zig/p/12205ffe4a0eeeac29ad958251085f9d3c988c56d22af0574b1d4dafb7703eb56dd4/build.zig:23:79: 0x1007a55fb in examplesStep (build)
    var dir = std.fs.cwd().openDir("./examples/", .{ .iterate = true }) catch @panic(
                                                                              ^
/Users/michalsrb/.cache/zig/p/12205ffe4a0eeeac29ad958251085f9d3c988c56d22af0574b1d4dafb7703eb56dd4/build.zig:7:17: 0x100749ddf in build (build)
    examplesStep(b, yazap);
                ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2116:33: 0x1006fd217 in runBuild__anon_16131 (build)
        .Void => build_zig.build(b),
                                ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2097:29: 0x1006b7293 in dependencyInner__anon_14831 (build)
        sub_builder.runBuild(bz) catch @panic("unhandled error");
                            ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:1954:35: 0x10068acbf in dependency__anon_13816 (build)
            return dependencyInner(b, name, pkg.build_root, if (@hasDecl(pkg, "build_zig")) pkg.build_zig else null, pkg_hash, pkg.deps, args);
                                  ^
/Users/michalsrb/Code/Zig/zig-human-utils/build.zig:39:31: 0x10065141b in build (build)
    const yazap = b.dependency("yazap", .{});
                              ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2116:33: 0x10063687b in runBuild__anon_8407 (build)
        .Void => build_zig.build(b),
                                ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/compiler/build_runner.zig:301:29: 0x1006317d7 in main (build)
        try builder.runBuild(root);
                            ^
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/start.zig:524:37: 0x100638ebf in main (build)
            const result = root.main() catch |err| {

Creating examples directory in my project fixes it, but I assume this is not intended?

prajwalch commented 1 month ago

Yeah, I didn't expect that to fail. Let me fix it.

prajwalch commented 1 month ago

Closing this issue as completed now :)