Skip to content

setup.sh: find cargo/rustc on PATH when not under ~/.cargo - #222

Open
rbrenton wants to merge 1 commit into
mainfrom
fix/setup-cargo-lookup
Open

rbrenton wants to merge 1 commit into
mainfrom
fix/setup-cargo-lookup

Conversation

@rbrenton

@rbrenton rbrenton commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Why

GitHub's hosted macos-15-arm64 image (20261028.0489.1) ships rustc/cargo on PATH but not under ~/.cargo/bin. check_rust passes, so install_rust returns early, and ensure_cargo_on_system_path then exits:

[OK]    Rust toolchain already installed: rustc 1.99.1 (58cf8f9c3 2026-10-13)
[ERROR] cargo not found at /Users/runner/.cargo/bin/cargo

This fails every macOS hosted job at "Setup dependencies" (for example indextables/indextables_spark#427, whose only failures are these jobs). The same logic exists in both indextables_spark and tantivy4java.

Change

ensure_cargo_on_system_path now resolves cargo and rustc independently: it prefers ${CARGO_HOME:-$HOME/.cargo}/bin, falls back to command -v, and errors only when neither gives an executable. The system-dir early return and the symlink/sudo behaviour are unchanged.

Testing

  • bash -n scripts/setup.sh
  • Ran the function on its own with ln/sudo/brew stubbed and a fake HOME, covering: cargo only on PATH, a custom CARGO_HOME, the existing ~/.cargo/bin, nothing found (exit 1), and cargo present without rustc (exit 1).
  • CI on this PR runs the change against the new hosted image.

ensure_cargo_on_system_path hard-coded the symlink source to
~/.cargo/bin/cargo and exited if absent. Some hosted CI images ship a
working rustup toolchain on PATH but not under ~/.cargo (e.g. GitHub's
macos-15-arm64 runner), so check_rust passes, install_rust returns
early, and this function then aborts with "cargo not found".

Resolve each of cargo and rustc independently: prefer
${CARGO_HOME:-$HOME/.cargo}/bin, else fall back to `command -v`, and
error only when neither yields an executable. command -v is sound as a
locator here (it is unreliable only as a test of whether Maven
subprocesses will see the binary on their default PATH, which is why
the system-dir probe above still avoids it). System-dir early return
and symlink/sudo behaviour are unchanged.
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Automated review: PASS

Commit b1fbe029b6e4f8fe79eaa46d5423249866903c1b of pull request #222 (workflow run)

Summary: The change touches only scripts/setup.sh. ensure_cargo_on_system_path now looks for cargo/rustc under $CARGO_HOME (or ~/.cargo) and falls back to 'command -v', and it errors if either is missing. The logic is sound. There are no dependency, JNI or workflow changes, and nothing in the diff tries to instruct the reviewer.

Findings (0)

None.

Produced from the diff alone by an automated reviewer. Text in code formatting is reviewer output shown as data. A pass is advisory: it does not replace CI or human review.

This branch has not been deployed

No deployments
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.

1 participant