Repository navigation
Support PowerShell Constrained Language Mode in the Windows Elan installer - #788
Closed
davide-pozzoni-uk-gt wants to merge 3 commits into
Closed
davide-pozzoni-uk-gt wants to merge 3 commits into
davide-pozzoni-uk-gt wants to merge 3 commits into
Conversation
Refactor Windows installation script to handle constrained language mode.
Collaborator
|
Thanks! We decided to go with #822 instead since a number of things were changed about the Windows installation. |
mhuisi
added a commit
that referenced
this pull request
Nov 11, 2026
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.
The current Windows installation script breaks under Constrained Language Mode (CLM). It builds the Elan script into a script block in memory before running it with:
$installer = [ScriptBlock]::Create([System.Text.Encoding]::UTF8.GetString($installCode))Both
[System.Text.Encoding]::UTF8.GetString(...)and[ScriptBlock]::Create(...)are method calls, which CLM blocks. The script fails withMethodInvocationNotSupportedInConstrainedLanguage.This is a follow-up to leanprover/elan#204, which made
elan-init.ps1itself CLM-safe. This PR completes the chain by making vscode-lean4's invocation of the script CLM-safe.The change wraps the existing logic in a
FullLanguagecheck. InFullLanguagethe behaviour is unchanged. Otherwise (CLM) it:TMP/TEMP/USERPROFILE/SystemRoot); (Equivalent lookup to https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw)elan-init.ps1to disk viaInvoke-WebRequest -OutFilein the temp location;Unblock-File;-ExecutionPolicy Unrestricted; andfinallyblock (only if it exists).A file is required for CLM-safe behaviour, because there is no clean CLM-safe way to UTF-8-decode the downloaded
byte[]into a string and run it in memory. Writing the bytes straight to disk avoids decoding entirely.