Skip to content

Commit 607bea7

Browse files
authored
Fix Windows PATH issue in install.bat
setx reads from the session %PATH% (system + user combined) and silently truncates at 1024 characters, corrupting the user PATH on install. Use PowerShell's SetEnvironmentVariable to append only to the user PATH from the registry, with no length limit. Also fix the warmup call to use the full installed path instead of relying on the new PATH entry being active in the current session.
1 parent ea0a076 commit 607bea7

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "bugfix",
3+
"description": "Fix Windows user PATH corruption in install.bat caused by setx silently truncating values over 1024 characters",
4+
"pull_requests": [
5+
"[#3117](https://github.com/smithy-lang/smithy/pull/3117)"
6+
]
7+
}

smithy-cli/configuration/install.bat

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ if exist "%choice_path%" goto upgrade
2929

3030
:: Copy the installation
3131
xcopy /i /h /e /k "%installer_path%*" "%choice_path%\"
32-
setx path "%path%;%choice_path%\;"
33-
call %exe_name% warmup
32+
set "smithy_install_dir=%choice_path%"
33+
powershell -Command "& { $installDir = $env:smithy_install_dir; $userPath = [Environment]::GetEnvironmentVariable('PATH','User'); if ([string]::IsNullOrEmpty($userPath)) { [Environment]::SetEnvironmentVariable('PATH', $installDir, 'User') } elseif (-not $userPath.Contains($installDir)) { [Environment]::SetEnvironmentVariable('PATH', $userPath.TrimEnd(';') + ';' + $installDir, 'User') } }"
34+
if %ERRORLEVEL% neq 0 (
35+
echo Failed to update PATH. You may need to add %choice_path% to your PATH manually.
36+
goto done
37+
)
38+
call "%choice_path%\bin\%exe_name%" warmup
3439
echo You may now run '%exe_name% --version'
3540
goto done
3641

0 commit comments

Comments
 (0)