From 79495b1ba9598caec8ff65f29762f401b3f823c8 Mon Sep 17 00:00:00 2001 From: DuProcess <273172371+DuProcess@users.noreply.github.com> Date: Thu, 16 Jul 2026 21:47:46 -0400 Subject: [PATCH] Refresh Windows process PATH before duplicate check --- install.ps1 | 6 +++--- tests/release_scripts.rs | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/install.ps1 b/install.ps1 index bc06155..f26ec54 100644 --- a/install.ps1 +++ b/install.ps1 @@ -333,6 +333,9 @@ function Add-UserPath($PathToAdd) { $entries = @($userPath -split ';' | Where-Object { $_ }) } $wanted = Normalize-PathForCompare $PathToAdd + if (-not (";$env:Path;").Contains(";$PathToAdd;")) { + $env:Path = "$PathToAdd;$env:Path" + } foreach ($entry in $entries) { if ((Normalize-PathForCompare $entry) -ieq $wanted) { return @@ -344,9 +347,6 @@ function Add-UserPath($PathToAdd) { $PathToAdd } [Environment]::SetEnvironmentVariable("Path", $next, "User") - if (-not (";$env:Path;").Contains(";$PathToAdd;")) { - $env:Path = "$PathToAdd;$env:Path" - } } function Write-Utf8NoBom($Path, $Content) { diff --git a/tests/release_scripts.rs b/tests/release_scripts.rs index b824f02..188b919 100644 --- a/tests/release_scripts.rs +++ b/tests/release_scripts.rs @@ -239,6 +239,12 @@ fn windows_installer_adds_user_path_idempotently() { assert!(ps1.contains("(@($entries) + $PathToAdd) -join ';'")); assert!(ps1.contains("(\";$env:Path;\").Contains(\";$PathToAdd;\")")); assert!(ps1.contains("$env:Path = \"$PathToAdd;$env:Path\"")); + assert!( + ps1.find("(\";$env:Path;\").Contains(\";$PathToAdd;\")") + .unwrap() + < ps1.find("foreach ($entry in $entries)").unwrap(), + "Windows installer must refresh the current shell PATH even when user PATH already contains Dosh" + ); assert!( !ps1.contains("\"$userPath;$bindir\""), "Windows installer must not write a leading semicolon when user PATH is empty"