fix: install.ps1 persists PATH instead of printing manual instructions - #27
Merged
Conversation
Previously the Windows installer only printed manual PATH instructions — including a setx suggestion that would bake the merged Machine+User PATH into the User value and truncate anything over 1024 chars. Now it appends the install dir to the user PATH via [Environment]::SetEnvironmentVariable (User scope only, no setx), prepends it to $env:Path for the current session, and keeps a manual PowerShell one-liner only as a fallback when the write throws. Membership check is case-insensitive and tolerant of trailing backslashes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kr1tfSNy6gvd6vwwD2vayo
boristane
approved these changes
Aug 12, 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.
Requested by boris · Slack thread
Before / After
Before: every first-time Windows install ended with a wall of homework — "Add
C:\Users\you\.polylane\binto your PATH:" followed by asetx PATH ...command and a PowerShell one-liner to paste. Nothing was persisted, sopolylanedidn't work until the user did it themselves. Worse, the suggestedsetxcommand was actively harmful: it bakes the merged Machine+User%PATH%into the User value and silently truncates anything over 1024 characters.After: the installer adds the install dir to the user PATH itself and prints
✓ added C:\Users\you\.polylane\bin to your PATHplus a note that new terminals pick it up automatically (nothing is printed if it's already there). It also prepends the dir to the current session's$env:Path, sopolylane --helpworks immediately in the same window. A manual PowerShell one-liner is shown only as a fallback if the registry write throws. Thesetxsuggestion is gone entirely.How
Two small helpers,
Test-PathHasDirandAdd-DirToPath, do the membership check (case-insensitive, trailing-backslash-tolerant, empty entries ignored — replacing the old-notlike "*$PrefixDir*"substring match, which false-positived on e.g....\bin2) and the append. Persistence reads[Environment]::GetEnvironmentVariable('Path', 'User')and writes back only the User-scope value withSetEnvironmentVariable(..., 'User')— neversetx, never the merged Machine+User PATH.Tested on Linux with pwsh 7.6.4: full-file parse check (no syntax errors) and 21 unit cases exercising the two helpers with injected values (exact/case/trailing-slash matches, substring non-matches, empty/null/whitespace PATHs, no double semicolons, >1024-char PATH round-trips unmangled), plus a check that
setxno longer appears in the script. What could not be tested here: the actualSetEnvironmentVariable(..., 'User')registry persistence and new-terminal pickup are Windows-only, so this change has not been run on a real Windows machine — worth a quick manualirm | iexsmoke test on Windows before release.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kr1tfSNy6gvd6vwwD2vayo
Generated by Claude Code