Fix install failure when the execution policy is Restricted - #271
Merged
zanjonke merged 1 commit intoAug 6, 2026
Merged
Conversation
On a fresh Windows machine the execution policy is Restricted. Piping this installer to iex sidesteps that, but scripts it invokes in turn do not get the same free pass: - uv's installer checks Get-ExecutionPolicy and refuses to run unless it reports Unrestricted, RemoteSigned or Bypass, so the install fails with "PowerShell requires an execution policy in [Unrestricted, RemoteSigned, Bypass] to run uv". - Invoke-SubScript executes walkthrough.ps1 and examples.ps1 from disk with & $path, which is blocked outright. - npm ships npx.ps1, which PowerShell prefers over npx.cmd, so `npx plain-forge install` is subject to the policy too. Add Invoke-WithBypassedExecutionPolicy, which sets Bypass for the Process scope only, runs the given script block, and restores the previous value in a finally block. Process scope applies to this process and its children, is discarded when the process exits, and leaves the user's CurrentUser and LocalMachine policies untouched, so the workaround of running Set-ExecutionPolicy -Scope CurrentUser RemoteSigned by hand is no longer needed. The helper is a no-op on non-Windows, where Set-ExecutionPolicy throws, and tolerates Group Policy lockdowns: when MachinePolicy or UserPolicy override the Process scope it reports the problem and still runs the block, letting the child script surface its own error. & $editor.Cmd is deliberately left unwrapped: cursor and code resolve to .cmd shims, which the execution policy does not apply to. Fixes Codeplain-ai#263
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.
Please merge the PR that fixes #264 first.
On Windows PowerShell 5.1, install.ps1 fails to parse before this fix can run, so this PR has no effect until that one is merged.
Fixes #263