build-nvidia: find rustup's cargo when PATH is stale, say to install Rust otherwise (#3117) #3342

Merged
MoonEyes merged 2 commits from upstream-pr/3342 into main 2026-12-03 14:59:33 +00:00
MoonEyes commented 2026-12-03 14:30:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T14:30:34Z.


Claim: BUILD-CARGO-MISSING in #3312. Fixes #3117.

Players hit "The term 'cargo' is not recognized" at launch (#3117; five reports in the public channels on 2026-12-03). Two causes: Rust is not installed, or it was installed from a window opened before rustup changed PATH, so the launcher's shell still does not see it. d3d12/scripts/build-nvidia.ps1 called cargo without checking.

Now, before the build, when cargo is not on PATH:

  • if %USERPROFILE%\.cargo\bin\cargo.exe exists (rustup's own folder), it is added to PATH for this build;
  • otherwise the script prints "Rust is not installed: cargo was not found. Install it from https://rustup.rs with the default options, then start again" and exits 9009, which scripts/play-d3d12.ps1 already turns into "cargo build failed".

This is the build script, not the launcher (#3341 leaves play*.ps1 and build scripts open); OreoFR is asked to review as the launcher calls it.

Tested (Windows 11)

  • PowerShell parser: no errors.
  • PATH without cargo and an empty profile folder: prints the message, exit 9009.
  • PATH without cargo, profile folder with .cargo\bin\cargo.exe: Get-Command cargo resolves to that file and the build is attempted.
  • scripts/check_no_game_data.py on the file: clean. No game run needed (the build itself is unchanged when cargo is on PATH).

AI-assisted (Claude Code, Claude Opus 5.5). Independent review: a separate Claude Opus 5.5 agent before merge.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5628495215 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3342). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T14:30:34Z. --- Claim: `BUILD-CARGO-MISSING` in #3312. Fixes #3117. Players hit "The term 'cargo' is not recognized" at launch (#3117; five reports in the public channels on 2026-12-03). Two causes: Rust is not installed, or it was installed from a window opened before rustup changed `PATH`, so the launcher's shell still does not see it. `d3d12/scripts/build-nvidia.ps1` called `cargo` without checking. Now, before the build, when `cargo` is not on `PATH`: - if `%USERPROFILE%\.cargo\bin\cargo.exe` exists (rustup's own folder), it is added to `PATH` for this build; - otherwise the script prints "Rust is not installed: cargo was not found. Install it from https://rustup.rs with the default options, then start again" and exits 9009, which `scripts/play-d3d12.ps1` already turns into "cargo build failed". This is the build script, not the launcher (#3341 leaves `play*.ps1` and build scripts open); OreoFR is asked to review as the launcher calls it. ## Tested (Windows 11) - PowerShell parser: no errors. - `PATH` without cargo and an empty profile folder: prints the message, exit 9009. - `PATH` without cargo, profile folder with `.cargo\bin\cargo.exe`: `Get-Command cargo` resolves to that file and the build is attempted. - `scripts/check_no_game_data.py` on the file: clean. No game run needed (the build itself is unchanged when cargo is on `PATH`). AI-assisted (Claude Code, Claude Opus 5.5). Independent review: a separate Claude Opus 5.5 agent before merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-12-03 14:31:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T14:31:54Z.


This overlaps the build preflight in #3187 and the shared lookup in #3263. I checked 2a29d1af, #3187 8af4eb44, and #3263 9c2e340b against 128579e9. Both older PRs now conflict with this one in build-nvidia.ps1.

One case worth carrying over is a configured CARGO_HOME. With a synthetic Cargo in $env:CARGO_HOME/bin, an empty default profile, and a stale PATH, this head reports Rust missing without invoking the stub. Both existing PRs invoke it with build --locked --profile diag -p leonida. Their build preflights also passed the default-home, PATH-priority, and missing-install cases in PowerShell 7.6.6 on Linux. For #3263, the Cargo, launcher, and gate test files produced 47 passes and 7 Windows-only skips.

The shared lookup in #3263 also covers the direct launcher’s earlier Cargo check. If this PR lands first, the overlapping build hunk can keep a single preflight and retain CARGO_HOME support. This check used synthetic executables and does not replace the Windows launcher run in the PR description. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7381600229 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3342#issuecomment-7381600229). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T14:31:54Z. --- This overlaps the build preflight in #3187 and the shared lookup in #3263. I checked `2a29d1af`, #3187 `8af4eb44`, and #3263 `9c2e340b` against `128579e9`. Both older PRs now conflict with this one in `build-nvidia.ps1`. One case worth carrying over is a configured `CARGO_HOME`. With a synthetic Cargo in `$env:CARGO_HOME/bin`, an empty default profile, and a stale `PATH`, this head reports Rust missing without invoking the stub. Both existing PRs invoke it with `build --locked --profile diag -p leonida`. Their build preflights also passed the default-home, PATH-priority, and missing-install cases in PowerShell 7.6.6 on Linux. For #3263, the Cargo, launcher, and gate test files produced 47 passes and 7 Windows-only skips. The shared lookup in #3263 also covers the direct launcher’s earlier Cargo check. If this PR lands first, the overlapping build hunk can keep a single preflight and retain `CARGO_HOME` support. This check used synthetic executables and does not replace the Windows launcher run in the PR description. AI-assisted (Codex).
merzleckeier commented 2026-12-03 14:37:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T14:37:26Z.


Rechecked the change on 6c8e856d. A configured CARGO_HOME now works with stale PATH, including when USERPROFILE is unset. When both homes contain Cargo, the custom home wins, and an existing PATH entry still takes precedence.

Two path cases remain in the candidate probe. CARGO_HOME named cargo [sdk] misses an existing bin/cargo.exe because Test-Path treats the brackets as a pattern. A directory named cargo.exe also passes the current existence check and then produces a generic command-not-found error. Test-Path -LiteralPath (Join-Path $_ 'cargo.exe') -PathType Leaf handled both. All seven cases then passed. This was PowerShell 7.6.6 on Linux with synthetic Cargo files and the platform PATH separator substituted for ;. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7381756432 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3342#issuecomment-7381756432). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T14:37:26Z. --- Rechecked the change on `6c8e856d`. A configured `CARGO_HOME` now works with stale `PATH`, including when `USERPROFILE` is unset. When both homes contain Cargo, the custom home wins, and an existing `PATH` entry still takes precedence. Two path cases remain in the candidate probe. `CARGO_HOME` named `cargo [sdk]` misses an existing `bin/cargo.exe` because `Test-Path` treats the brackets as a pattern. A directory named `cargo.exe` also passes the current existence check and then produces a generic command-not-found error. `Test-Path -LiteralPath (Join-Path $_ 'cargo.exe') -PathType Leaf` handled both. All seven cases then passed. This was PowerShell 7.6.6 on Linux with synthetic Cargo files and the platform PATH separator substituted for `;`. AI-assisted (Codex).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3342
No description provided.