diff --git a/install.ps1 b/install.ps1 index d61a13f..cdc0b8c 100644 --- a/install.ps1 +++ b/install.ps1 @@ -42,7 +42,7 @@ function Ensure-Cargo { Write-Info "cargo not found; installing Rust toolchain with winget/rustup" winget install --id Rustlang.Rustup -e --accept-package-agreements --accept-source-agreements $cargoBin = Join-Path $HOME ".cargo\bin" - if (Test-Path $cargoBin) { + if ((Test-Path $cargoBin) -and -not (PathList-Contains $env:Path $cargoBin)) { $env:Path = "$cargoBin;$env:Path" } if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) { diff --git a/tests/release_scripts.rs b/tests/release_scripts.rs index edc9e50..5f0f727 100644 --- a/tests/release_scripts.rs +++ b/tests/release_scripts.rs @@ -213,6 +213,8 @@ fn windows_installer_bootstraps_rust_for_source_fallback_like_unix() { assert!(ps1.contains("cargo not found; installing Rust toolchain with winget/rustup")); assert!(ps1.contains("winget install --id Rustlang.Rustup")); assert!(ps1.contains("--accept-package-agreements --accept-source-agreements")); + assert!(ps1.contains("PathList-Contains $env:Path $cargoBin")); + assert!(ps1.contains("$env:Path = \"$cargoBin;$env:Path\"")); assert!(ps1.contains("Ensure-Cargo")); assert!(!ps1.contains("Require-Command cargo")); }