Skip to content

fix(rust-napi-ci): ensure cargo bin is on PATH after rust-toolchain#32

Merged
jan-kubica merged 1 commit into
mainfrom
fix/rust-toolchain-path
May 15, 2026
Merged

fix(rust-napi-ci): ensure cargo bin is on PATH after rust-toolchain#32
jan-kubica merged 1 commit into
mainfrom
fix/rust-toolchain-path

Conversation

@jan-kubica
Copy link
Copy Markdown
Contributor

Summary

dtolnay/rust-toolchain only adds \$CARGO_HOME/bin to PATH when it installs rustup itself (its install rustup if needed step). On GitHub macOS runners that ship with rustup pre-installed but no active toolchain, the action installs the toolchain via rustup toolchain install stable, but PATH still resolves cargo to a rustup-init symlink. Subsequent cargo metadata calls (e.g. from @napi-rs/cli) then fail intermittently with:

```
Internal Error: cargo metadata exited with code 1
error: error: unexpected argument 'metadata' found
Usage: rustup-init[EXE] [OPTIONS]
```

Adding \$HOME/.cargo/bin to \$GITHUB_PATH after each rust-toolchain action invocation makes the just-installed toolchain win on PATH unconditionally.

Hit at least 3 times today across stella/aho-corasick, stella/fuzzy-search PRs on macOS aarch64/x86_64 build matrices.

Test plan

  • After merge + SHA bump in consumer repos, napi-ci / Build - aarch64-apple-darwin and x86_64-apple-darwin stop intermittent failures.

dtolnay/rust-toolchain only prepends $CARGO_HOME/bin to PATH when
it installs rustup itself. On GitHub macOS runners with pre-installed
rustup but no active toolchain, the action installs the toolchain but
PATH still resolves `cargo` to a `rustup-init` symlink. Calls like
`cargo metadata` (from @napi-rs/cli) then fail with:

  Internal Error: cargo metadata exited with code 1
  error: error: unexpected argument 'metadata' found
  Usage: rustup-init[EXE] [OPTIONS]

Adding `$HOME/.cargo/bin` to $GITHUB_PATH after every rust-toolchain
invocation makes the just-installed toolchain win on PATH.
@jan-kubica jan-kubica requested a review from nnad3N as a code owner May 15, 2026 08:51
@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@jan-kubica jan-kubica merged commit 90c81b4 into main May 15, 2026
1 check passed
@jan-kubica jan-kubica deleted the fix/rust-toolchain-path branch May 15, 2026 08:51
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant