Skip to content

fix: install.ps1 persists PATH instead of printing manual instructions - #27

Merged
boristane merged 1 commit into
mainfrom
claude/installps1-persist-path
Aug 12, 2026
Merged

fix: install.ps1 persists PATH instead of printing manual instructions#27
boristane merged 1 commit into
mainfrom
claude/installps1-persist-path

Conversation

@claude

@claude claude Bot commented Aug 12, 2026

Copy link
Copy Markdown

Requested by boris · Slack thread

Before / After

Before: every first-time Windows install ended with a wall of homework — "Add C:\Users\you\.polylane\bin to your PATH:" followed by a setx PATH ... command and a PowerShell one-liner to paste. Nothing was persisted, so polylane didn't work until the user did it themselves. Worse, the suggested setx command 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 PATH plus 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, so polylane --help works immediately in the same window. A manual PowerShell one-liner is shown only as a fallback if the registry write throws. The setx suggestion is gone entirely.

How

Two small helpers, Test-PathHasDir and Add-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 with SetEnvironmentVariable(..., 'User') — never setx, 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 setx no longer appears in the script. What could not be tested here: the actual SetEnvironmentVariable(..., '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 manual irm | iex smoke test on Windows before release.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kr1tfSNy6gvd6vwwD2vayo


Generated by Claude Code

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
boristane merged commit eae520f into main Aug 12, 2026
3 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.

2 participants