Skip to content

fix(install): install.ps1 runs in a scope of its own and leaves nothing in the user's session - #1137

Merged
David-Noble-at-work merged 3 commits into
developfrom
fix/982-irm-iex-leaves-install-ps1-s
Oct 22, 2026
Merged

David-Noble-at-work merged 3 commits into
developfrom
fix/982-irm-iex-leaves-install-ps1-s

Conversation

@David-Noble-at-work

@David-Noble-at-work David-Noble-at-work commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Lane 46 of #949.

  • install.ps1 runs in a scope of its own (irm | iex leaves install.ps1's settings in the user's session: the preference, strict mode, and the script's functions and variables #982; ruled 2026-10-21, "run in its own scope"). Run as Invoke-RestMethod <url>/install.ps1 | Invoke-Expression, the installer ran in the user's own scope, and what it set stayed in their session after it ended: Set-StrictMode -Version Latest, its functions, and its variables, $AuthToken, which holds GH_TOKEN's value, among them. Everything after param() now runs inside Invoke-Command -ScriptBlock { ... }, so all of it ends with that scope, in every form the installer is run in. The layers' fallback reads the environment as [string], so an unset variable is '', as before.
  • Run as a file, a failure still exits 1. After the block $? is true whatever the block reported, so the check moves inside, after the Install-DevLore call. Whether the script runs as a file is decided outside, from the script's own $MyInvocation, and passed in through -ArgumentList, so it sets no variable in the caller's scope; in the block $script:MyInvocation is whichever script called the script-block form. Both were measured: the suite's existing 'as a file: a failure exits 1' and its in-session cases caught each.
  • The suite. Its Invoke-Expression case runs everywhere the suite runs on Windows, not in CI alone, in a child session whose home is scratch, and checks after the run that the session goes on, strict mode is off, and no installer function or variable is left. At 272e6a98, under Windows PowerShell 5.1: 132 pass, 3 fail, the three new checks. With the fix: 135 pass, 0 fail, under 5.1 and 7, on danoble-wd11-3.
  • Getting started no longer says the Invoke-Expression form leaves the installer's settings in the session.
  • Plan: docs/plans/fix/982-irm-iex-leaves-install-ps1-s.md.

Resolves #982

Test plan

  • The suite's new checks fail against the old install.ps1 and pass with the fix, on Windows under 5.1 and 7
  • This script's pre-flight: make check-all
  • CI on this pull request, every leg

Written with AI assistance.

Signed-off-by: David Noble [email protected]
Assisted-by: Claude Code

Time

Marker UTC Elapsed
opened (first commit) 2026-10-22T04:08:38Z —
submitted (PR opened) 2026-10-22T04:38:59Z 0.5 h after opened
merged 2026-10-22T04:56:50Z 0.3 h after submitted; 0.8 h in all

Computed by the algorithm of noblefactor-ops#188 at merge.

…ng in the user's session (#982)

The installer's body runs inside Invoke-Command -ScriptBlock, so under Invoke-RestMethod | Invoke-Expression its strict
mode, functions and variables ($AuthToken among them) end with it. Run as a file, a failure still exits 1: whether it
runs as a file is decided outside the block and passed in, and the check follows the Install-DevLore call. The suite's
Invoke-Expression case runs everywhere on Windows in a scratch home and checks nothing is left; getting started no
longer says the form leaks.
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.

irm | iex leaves install.ps1's settings in the user's session: the preference, strict mode, and the script's functions and variables

1 participant