Skip to content

fix: open the editor on Windows - #567

Open
fushanbobfan wants to merge 2 commits into
leanprover-community:mainfrom
fushanbobfan:fix/windows-editor-process-platform
Open

fushanbobfan wants to merge 2 commits into
leanprover-community:mainfrom
fushanbobfan:fix/windows-editor-process-platform

Conversation

@fushanbobfan

Copy link
Copy Markdown
Contributor

What was wrong

On Windows the level editor never opens (#451, #445). The console shows Unable to write file '\workspace.code-workspace' (NoPermissions (FileSystemError): Not allowed) and the same for the level file, e.g. '\TestWorld\1.lean'. It also makes 16 of the 20 game-features.cy.ts tests fail on the windows-latest CI job.

There are two causes:

  1. Client. vite-plugin-node-polyfills installs a global process without platform. The VS Code libraries under lean4monaco treat a process without versions.node as absent when deciding isWindows, so in a Windows browser they take it from the user agent and build fsPath with backslashes. Their path module, however, reads process.platform from that same polyfill, finds no 'win32', and uses the POSIX implementation. resources.dirname(file:///TestWorld/1.lean) then evaluates posix.dirname('\\TestWorld\\1.lean'), which is '.', so the in-memory file system looks for the parent directory /., does not find it, and the overlay provider reports NoPermissions. This is the failure users hit on adam.math.hhu.de with a Windows browser, whatever OS the server runs on.
  2. Relay (only when the relay itself runs on Windows). The relay builds the document URI as `file://${gameDir}/Game/Metadata.lean`, which on Windows gives file://D:\...\TestGame/Game/Metadata.lean. That is not a valid file URI, so the Lean server never answers for the level.

What this changes

  • client/src/process-platform.ts, imported first in index.tsx, sets process.platform on the polyfill from the user agent when it is missing, the same way VS Code's own process fallback does (win32 / darwin / linux). Both code paths then agree on the platform.
  • The relay builds the URI with pathToFileURL(path.join(gameDir, 'Game', 'Metadata.lean')). On Linux and macOS this gives the same file:///... URI as before, except that characters such as spaces are now percent-encoded.

How it was tested

On Windows 11 (Chrome-based browser and Cypress Electron):

  • Before: opening a TestGame level shows the errors above and no goal, as in the CI Windows job of run 37186423826 (16 failing, all Expected to find content: 'Assumptions:').
  • After: npm run test: 01-basic-interface.cy.ts 6/6 pass; game-features.cy.ts 17 pass, 3 fail. The 3 failures (Current Goal, Invalid rewrite argument, unsolved goals) are the same ones that fail on the macOS and Linux CI jobs on main.
  • npx tsc --noEmit -p client adds no errors in the changed files; the relay builds with tsc -b.
  • npm run build:client: succeeds; serving that build with npm run prod (NO_BWRAP=true) on Windows, the TestGame level shows the goal and the first hint.

I did not test on macOS or Linux locally; there the polyfill fix sets platform to darwin/linux, which matches what VS Code already assumed from the user agent.

Fixes #451
Fixes #445

The process polyfill has no platform, so the VS Code path module used POSIX paths while VS Code built Windows file paths from the user agent, and every editor file write failed. Set process.platform from the user agent before the editor loads.

The relay also built the Metadata.lean URI by string concatenation, which is not a valid file URI on Windows; use pathToFileURL.
…ocess-platform

# Conflicts:
#	relay/src/serverProcess.ts
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.

Editor has stopped opening (Windows) Running locally: can't write answer (no typewriter)

1 participant