Skip to content

path arguments to zig build are inconsistent in whether they are relative to build root, such as --zig-lib-dir #12685

@andrewrk

Description

@andrewrk

Here we collect zig lib dir from the user:

zig/src/main.zig

Lines 3769 to 3770 in 75d5a4b

override_lib_dir = args[i];
try child_argv.appendSlice(&[_][]const u8{ arg, args[i] });

It is then used relative to the cwd in order to build the build runner. Next, it is passed to the build runner and then the build runner interprets the file path as being relative to build.zig.

It can't be both ways; it needs to be consistently one way.

This results in nonsense experiences such as this:

$ stage3/bin/zig build  --zig-lib-dir ../lib
error: unable to open zig lib directory from 'zig-lib-dir' argument or env, '/home/andy/dev/lib': FileNotFound
$ stage3/bin/zig build  --zig-lib-dir lib
error: unable to open zig lib directory from 'zig-lib-dir' argument: 'lib': FileNotFound

As a workaround until this issue is fixed an absolute path can be used:

$ stage3/bin/zig build  --zig-lib-dir $(pwd)/../lib
(ok)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorzig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions