Make Windows PATH install idempotent
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s

This commit is contained in:
DuProcess
2026-07-16 20:02:22 -04:00
parent 6eb0392aaa
commit 6cb8f50205
2 changed files with 35 additions and 4 deletions
+21 -4
View File
@@ -299,6 +299,26 @@ function Assert-SafeUpdateCache($Path) {
$full
}
function Add-UserPath($PathToAdd) {
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$entries = @()
if ($userPath) {
$entries = @($userPath -split ';' | Where-Object { $_ })
}
$wanted = Normalize-PathForCompare $PathToAdd
foreach ($entry in $entries) {
if ((Normalize-PathForCompare $entry) -ieq $wanted) {
return
}
}
$next = if ($entries.Count -gt 0) {
(@($entries) + $PathToAdd) -join ';'
} else {
$PathToAdd
}
[Environment]::SetEnvironmentVariable("Path", $next, "User")
}
$bindir = Join-Path $Prefix "bin"
$configDir = Join-Path $HOME ".config\dosh"
New-Item -ItemType Directory -Force -Path $bindir, $configDir | Out-Null
@@ -447,10 +467,7 @@ predict = true
"@ | Set-Content -NoNewline -Encoding utf8 $hostsConfig
}
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (-not (($userPath -split ';') -contains $bindir)) {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$bindir", "User")
}
Add-UserPath $bindir
Write-Host "Installed Dosh client to $bindir"
Write-Host "Configured UDP port $Port"