Repository navigation
fix(desktop): detect the WSL restart Windows still needs - #273
Merged
Merged
Conversation
Installing WSL 2 on a machine that never had VirtualMachinePlatform ends with dism/msiexec exit 3010 (ERROR_SUCCESS_REBOOT_REQUIRED), but the elevated script mapped that to 0 and the follow-up probe was `wsl --version`, which answers from the freshly installed MSI before the feature is active. The app then declared WSL installed and went straight to creating the sandbox, whose `wsl --import` needs the WSL2 utility VM and failed — as "exited 4294967295" with no explanation, because wsl.exe prints its diagnostics to stdout while the provider only surfaced stderr. The elevated script now re-raises 3010 (the exit code is the only signal that crosses the RunAs boundary); the sandbox installer turns it into the existing restart-required state and the Code side's install-wsl job into pendingRestart. WSL command failures now include the stdout diagnostic, and an import failure in the VM-unavailable error family adds a hint to restart Windows or enable virtualization in firmware. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A restart-required install left the user with a sentence and a trip to the Start menu. The create-sandbox dialogs now show a Restart Windows button in that state: it arms an inline confirm step — restarting closes CoDev and every other open application, and the hint says so — and then runs shutdown.exe /r /t 0 via a new sandbox-wsl-restart channel. No /f, so an application holding unsaved work can still hold the restart, and a refusal (shutdown policy, an already pending shutdown) surfaces as a toast instead of a restart that never comes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
On the affected Windows 10 machine the import failure survived the restart, and `wsl --status` named the real cause: Wsl/WSL_E_WSL_OPTIONAL_COMPONENT_REQUIRED. Windows 10 requires the Microsoft-Windows-Subsystem-Linux optional component even for the standalone MSI, and the elevated install script only ever enabled VirtualMachinePlatform — while `wsl --version`, the availability probe, kept passing straight from the MSI. The script now enables both features (dism is a no-op where the component already exists, so no build gate), with 3010 from either re-raised as before. The sandbox provider's availability probe becomes `wsl --status`, which fails — and says why — exactly when running a distro would, so a half-installed machine is offered the now complete installer instead of a doomed import; its message is surfaced over the generic install prompt, which remains for a missing wsl.exe. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
On a Windows 10 machine that never had WSL 2, installing it from the create-sandbox dialog reported success, and creating the sandbox then failed — including after a restart — with:
Confirmed on the affected machine:
wsl --versionreports 2.x whilewsl --statusfails withWsl/WSL_E_WSL_OPTIONAL_COMPONENT_REQUIRED. Three bugs compound:Microsoft-Windows-Subsystem-Linuxeven for the standalone WSL MSI; the script only enabledVirtualMachinePlatform, so every distro command could only fail.ERROR_SUCCESS_REBOOT_REQUIRED) was mapped to 0, and the follow-up probe waswsl --version— which answers straight from the MSI before any feature is active.exited 4294967295(-1 unsigned).Fix
install-bundle.ts: the elevated script enables both Windows features (dism is a no-op where a feature already exists, so no build gate) and re-raises 3010 instead of mapping it to 0 — the exit code is the only signal that crosses theStart-Process -Verb RunAsboundary. Exported asWSL_INSTALL_REBOOT_REQUIRED.sandbox/wsl-install.ts: exit 3010 → therestart-requiredstate; the availability probe stays only as backstop for thewsl --installfallback path. NewrestartWindows()runsshutdown.exe /r /t 0(no/f, refusals reject).sandbox-wsl-restartchannel; newsandbox.wsl.restart*i18n keys (en/es).@codev/sandboxwsl/provider.ts: the availability probe becomeswsl --status, which fails — and says why — exactly when running a distro would; its message is surfaced (e.g. the component-required error), so a half-installed machine is offered the now complete installer instead of a doomed import. NewwslFailureDetail()includes the stdout diagnostic in every WSL error, and an import failure in the VM-unavailable HCS family appends a restart/enable-virtualization hint.wsl/servers.ts(upstream-tracked): the Code side'sinstall-wsljob treats 3010 as success withpendingRestart: true. DIVERGENCES rows updated ("Dual-path WSL install", "WSL auto-install from the sandbox dialogs").Tests
restart-requiredwithout consulting availability;restartWindowsinvokesshutdown.exe /r /t 0, surfaces refusals, refuses off-Windows.WSL_E_WSL_OPTIONAL_COMPONENT_REQUIREDfrom a fake wsl.exe whose--versionpasses but--statusfails (the affected machine's exact shape); a failing--importsurfaces its UTF-16LE stdout diagnostic plus the restart hint; missing wsl.exe still gets the generic install prompt.@codev/sandbox, 145 indesktop, 702 inapp; workspaceturbo typecheckclean.CHANGELOG entry added under Unreleased → Sandbox.
🤖 Generated with Claude Code