Repository navigation
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 intoOct 22, 2026
Conversation
… in the user's session (#982)
…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.
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.
Summary
Lane 46 of #949.
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 holdsGH_TOKEN's value, among them. Everything afterparam()now runs insideInvoke-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.$?is true whatever the block reported, so the check moves inside, after theInstall-DevLorecall. 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:MyInvocationis 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.Invoke-Expressioncase 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. At272e6a98, 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.Invoke-Expressionform leaves the installer's settings in the session.docs/plans/fix/982-irm-iex-leaves-install-ps1-s.md.Resolves #982
Test plan
install.ps1and pass with the fix, on Windows under 5.1 and 7make check-allWritten with AI assistance.
Signed-off-by: David Noble [email protected]
Assisted-by: Claude Code
Time
Computed by the algorithm of noblefactor-ops#188 at merge.