Skip to content

fix(install.ps1): update $env:PATH in current session so refuse runs immediately#47

Merged
gok03 merged 2 commits into
mainfrom
fix/install-ps1-current-session-path
Jun 8, 2026
Merged

fix(install.ps1): update $env:PATH in current session so refuse runs immediately#47
gok03 merged 2 commits into
mainfrom
fix/install-ps1-current-session-path

Conversation

@gok03

@gok03 gok03 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Repro

Fresh Windows box, follow the docs:

PS> irm https://raw.githubusercontent.com/RefuseHQ/refuse-cli/main/scripts/install.ps1 | iex
refuse: installed C:\Users\…\.refuse\bin\refuse.exe
refuse: try `refuse --version` then `refuse init` (in a new terminal)
PS> refuse init
refuse : The term 'refuse' is not recognized as the name of a cmdlet ...

The script's own "next step" fails because the persistent user PATH is updated but the current session's $env:PATH is not.

Fix

After the existing [Environment]::SetEnvironmentVariable("PATH", ..., "User") call, also mutate $env:PATH in the running session (idempotent). Update the trailing message to drop the "open a new terminal" instruction.

Works because irm | iex runs in the caller's scope; $env:PATH writes in the piped script propagate to the user's prompt.

Pairs with #46

Sibling fix for the same shape of bug on Linux/macOS — the scripts/install.sh companion in #46.

Test plan

  • Fresh Windows 11 box: irm | iex → confirm refuse --version works without opening a new terminal.
  • Re-run the installer: confirm $env:PATH is not double-prepended.
  • User PATH registry write still works (open a new terminal afterwards, confirm refuse is on PATH there too).
  • Old Windows PowerShell 5.1 + PowerShell 7+.

…immediately

Same UX bug the Linux install.sh fix in #46 addresses, on Windows:
the script writes the user-scope PATH via SetEnvironmentVariable but
the current PowerShell session keeps its old $env:PATH, so the very
next command the script suggests (`refuse --version` / `refuse
init`) fails with "The term 'refuse' is not recognized".

Fix: after the registry write, also prepend the install dir to
$env:PATH in the running session (idempotent — skip if already
present). Update the trailing message to drop the "open a new
terminal" instruction since the caller's session now has refuse
on PATH directly.

Works because `irm | iex` runs in the caller's scope; $env:PATH
mutations in the piped script propagate to the user's prompt.
@gok03 gok03 merged commit c75c68f into main Jun 8, 2026
8 checks passed
@gok03 gok03 deleted the fix/install-ps1-current-session-path branch June 8, 2026 06:06
@gok03 gok03 mentioned this pull request Jun 8, 2026
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.

1 participant