Skip to content

Fix Windows PATH issue in install.bat#3117

Merged
kstich merged 3 commits into
smithy-lang:mainfrom
dscpinheiro:main
May 14, 2026
Merged

Fix Windows PATH issue in install.bat#3117
kstich merged 3 commits into
smithy-lang:mainfrom
dscpinheiro:main

Conversation

@dscpinheiro
Copy link
Copy Markdown
Contributor

I was trying to install the Smithy CLI on my Windows laptop earlier today, but ran into an issue since setx (which the previous script used) reads from the session %PATH% (system + user combined) and silently truncates at 1024 characters.

So I replaced that with PowerShell's SetEnvironmentVariable, which reads and writes only the user PATH from the registry without a length limit. Also added some extra validation such as preventing duplicates on re-installs and checking the exit code in case updating the path fails.

This shouldn't impact the Scoop installation method since it manages updating the PATH separately (via https://github.com/smithy-lang/scoop-bucket/blob/main/bucket/smithy-cli.json#L9).

Testing

Before:

PS> [Environment]::GetEnvironmentVariable('PATH', 'User')
D:\Users\dspin\AppData\Local\Microsoft\WindowsApps; 

After:

PS> [Environment]::GetEnvironmentVariable('PATH', 'User')
D:\Users\dspin\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Smithy
PS> smithy --version
1.70.0

Links

N/A


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 14, 2026 03:10
@dscpinheiro dscpinheiro requested a review from a team as a code owner May 14, 2026 03:10
@dscpinheiro dscpinheiro requested a review from yefrig May 14, 2026 03:10
@github-actions
Copy link
Copy Markdown
Contributor

This pull request does not contain a staged changelog entry. To create one, use the ./.changes/new-change command. For example:

./.changes/new-change --pull-requests "#3117" --type feature --description "Fix Windows PATH issue in install.bat"

Make sure that the description is appropriate for a changelog entry and that the proper feature type is used. See ./.changes/README or run ./.changes/new-change -h for more information.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Windows install.bat flow for Smithy CLI to avoid setx PATH truncation by switching to a PowerShell-based user PATH update, aiming to make installs more reliable on systems with long PATH values.

Changes:

  • Replace setx with PowerShell [Environment]::SetEnvironmentVariable to update the user PATH without the setx 1024-character truncation behavior.
  • Add basic validation to avoid appending duplicate install entries to the user PATH.
  • Add an %ERRORLEVEL% check to stop and instruct the user if the PATH update fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread smithy-cli/configuration/install.bat Outdated
Comment thread smithy-cli/configuration/install.bat
dscpinheiro and others added 2 commits May 13, 2026 20:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@kstich kstich merged commit 607bea7 into smithy-lang:main May 14, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants