Skip to content

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

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
Collaborator

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 #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 00ccf2810a9d9d716da7592a1ba2313eeecee73d of pull request #428 (workflow run)

Summary: Changes scripts/setup.sh so ensure_cargo_on_system_path honors CARGO_HOME and falls back to 'command -v' for cargo and rustc. It then symlinks them into a system PATH directory. The change is small and self-contained and has no dependency or workflow changes. The fallback logic is sound, and the error path now also checks rustc.

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