Skip to content

std.Build.Step.Run: prefix relative path arguments with './' #24218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

mlugg
Copy link
Member

@mlugg mlugg commented Jun 18, 2025

This is necessary in two cases:

  • On POSIX, the exe path (argv[0]) must contain a path separator
  • Some programs might treat a file named e.g. -foo as a flag, which can be avoided by passing ./-foo

Rather than detecting these two cases, just always include the prefix; there's no harm in it.

Also, if the cwd is specified, include it in the manifest. If the user has set the cwd of a Run step, it is clearly because this affects the behavior of the executable somehow, so that cwd path should be a part of the step's manifest.

Resolves: #24216

This is necessary in two cases:

* On POSIX, the exe path (`argv[0]`) must contain a path separator
* Some programs might treat a file named e.g. `-foo` as a flag, which
  can be avoided by passing `./-foo`

Rather than detecting these two cases, just always include the prefix;
there's no harm in it.

Also, if the cwd is specified, include it in the manifest. If the user
has set the cwd of a Run step, it is clearly because this affects the
behavior of the executable somehow, so that cwd path should be a part of
the step's manifest.

Resolves: ziglang#24216
@mlugg
Copy link
Member Author

mlugg commented Jun 18, 2025

aarch64-macos-debug just failed due to Zach's disk being full, and this definitely shouldn't be able to break anything given everywhere it passed; bypassing merge requirements to get the fix in.

@mlugg mlugg merged commit 36499c2 into ziglang:master Jun 18, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

running a binary relative to a setCwd broken on latest master
1 participant