Skip to content

Fix install failure when the execution policy is Restricted - #271

Merged
zanjonke merged 1 commit into
Codeplain-ai:mainfrom
sunasrd-byte:fix/powershell-restricted-execution-policy
Aug 6, 2026
Merged

Fix install failure when the execution policy is Restricted#271
zanjonke merged 1 commit into
Codeplain-ai:mainfrom
sunasrd-byte:fix/powershell-restricted-execution-policy

Conversation

@sunasrd-byte

Copy link
Copy Markdown
Contributor

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

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
@zanjonke
zanjonke self-requested a review August 3, 2026 13:31
@zanjonke zanjonke self-assigned this Aug 3, 2026
@zanjonke zanjonke added the bug Something isn't working label Aug 3, 2026

@zanjonke zanjonke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@zanjonke
zanjonke merged commit b1e38e4 into Codeplain-ai:main Aug 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install script fails on Windows when downloading plainlang-examples Windows install fails on default execution policy (Restricted) when installing uv

3 participants