Fix Windows PATH issue in install.bat#3117
Merged
Merged
Conversation
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>
Contributor
|
This pull request does not contain a staged changelog entry. To create one, use the Make sure that the description is appropriate for a changelog entry and that the proper feature type is used. See |
There was a problem hiding this comment.
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
setxwith PowerShell[Environment]::SetEnvironmentVariableto update the user PATH without thesetx1024-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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
kstich
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
PATHseparately (via https://github.com/smithy-lang/scoop-bucket/blob/main/bucket/smithy-cli.json#L9).Testing
Followed the manual steps for Windows (from https://smithy.io/2.0/guides/smithy-cli/cli_installation.html) after replacing the
install.batfile with the content from my fork. On my Workspace, confirmed the path was appended correctly and I could invokesmithy --version.Before:
After:
Links
N/A
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.