Skip to content

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

Closed

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)

Activity

  1. added
    bugObserved behavior contradicts documented or intended behavior
    zig build systemstd.Build, the build runner, `zig build` subcommand, package management
    on Aug 30, 2022
  2. added this to the 0.10.0 milestone on Aug 30, 2022
  3. added a commit that references this issue on Aug 30, 2022
  4. modified the milestones: 0.10.0, 0.10.1 on Oct 12, 2022
  5. added 2 commits that reference this issue on Jan 5, 2023
    bbd30b4
    789a06f
  6. modified the milestones: 0.10.1, 0.11.0 on Jan 10, 2023
  7. added a commit that references this issue on Jan 27, 2023
    576401f
  8. modified the milestones: 0.11.0, 0.11.1 on Jul 24, 2023
  9. added 2 commits that reference this issue on Jul 30, 2023
    810f3f5
    38840e2
  10. modified the milestones: 0.11.1, 0.11.0 on Jul 31, 2023
  11. added a commit that references this issue on Aug 3, 2023
    bedca92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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