From fc72eacc879ff119ef35985928593f0f95bb044d Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Sat, 14 Mar 2026 19:55:55 +0000 Subject: [PATCH] setup.ps1: fix PATH check to use exact entry comparison instead of substring match --- studio/setup.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/studio/setup.ps1 b/studio/setup.ps1 index 63ce76151e..76254df294 100644 --- a/studio/setup.ps1 +++ b/studio/setup.ps1 @@ -598,15 +598,15 @@ if ($HasPython) { $ScriptsDir = python -c "import sysconfig; print(sysconfig.get_path('scripts', 'nt_user') if __import__('os').path.exists(sysconfig.get_path('scripts', 'nt_user')) else sysconfig.get_path('scripts'))" if ($ScriptsDir) { $UserPath = [Environment]::GetEnvironmentVariable('Path', 'User') - if (-not $UserPath -or $UserPath -notlike "*$ScriptsDir*") { - if ($UserPath) { - [Environment]::SetEnvironmentVariable('Path', "$ScriptsDir;$UserPath", 'User') - } else { - [Environment]::SetEnvironmentVariable('Path', "$ScriptsDir", 'User') - } + $UserPathEntries = if ($UserPath) { $UserPath.Split(';') } else { @() } + if (-not ($UserPathEntries | Where-Object { $_.TrimEnd('\') -eq $ScriptsDir })) { + $newUserPath = if ($UserPath) { "$ScriptsDir;$UserPath" } else { $ScriptsDir } + [Environment]::SetEnvironmentVariable('Path', $newUserPath, 'User') + # Also add to current process so it's available immediately - if ($env:PATH -notlike "*$ScriptsDir*") { - [Environment]::SetEnvironmentVariable('PATH', "$ScriptsDir;$env:PATH", 'Process') + $ProcessPathEntries = $env:PATH.Split(';') + if (-not ($ProcessPathEntries | Where-Object { $_.TrimEnd('\') -eq $ScriptsDir })) { + $env:PATH = "$ScriptsDir;$env:PATH" } Write-Host " Persisted Python Scripts dir to user PATH: $ScriptsDir" -ForegroundColor Gray }