Stop the Windows build driver destroying the user's WSL distribution#212
Open
domiwar wants to merge 1 commit into
Open
Stop the Windows build driver destroying the user's WSL distribution#212domiwar wants to merge 1 commit into
domiwar wants to merge 1 commit into
Conversation
build-and-test-windows.ps1 unregisters and rebuilds its WSL distribution on
every run. It defaulted to the distro named "Ubuntu" - the default name for a
stock WSL install - and ran `wsl --unregister` on it with no confirmation.
`--unregister` deletes the distribution's virtual disk and cannot be undone,
so running this script would silently destroy a developer's main WSL
environment and everything in it.
- Default to a dedicated distro name ('openserverless-build') instead of a
name a developer is likely to be using. WSL installs the same image under
any name via `wsl --install -d <image> --name <distro>`, so the image
(Ubuntu-24.04) and the distribution name are now separate settings,
overridable with WSL_IMAGE / WSL_DISTRO.
- Write an ownership marker inside the distribution during provisioning, and
refuse to unregister a distribution that lacks it without an explicit typed
confirmation. -Force skips the prompt for CI.
- Pin the image to Ubuntu-24.04; the bare 'Ubuntu' alias tracks the latest
LTS, so the provisioned distro could drift from the intended one.
- Document the destructive behaviour at the top of the file.
Also fixes the distro never actually getting Docker installed. WSL appends
the Windows PATH, so `command -v docker` matched Docker Desktop's docker.exe
under /mnt/c and the install was skipped, leaving no daemon - surfacing later
as a missing 'docker' group and then an unreachable daemon.
- Strip /mnt/* from PATH during provisioning, and set
[interop] appendWindowsPath=false in /etc/wsl.conf to keep the distribution
isolated from the Windows toolchain at runtime.
- Only count a docker binary outside /mnt as installed; fail loudly otherwise.
- Download the get.docker.com installer to a file rather than piping curl into
sh, which hid failed downloads (sh runs an empty script and exits 0). Add
`set -o pipefail` for the same reason.
- Enable the docker service rather than a one-shot start, which was discarded
by the `wsl --shutdown` that follows provisioning, and wait for the daemon
to accept connections before running the build.
Co-Authored-By: Claude Opus 4.8 <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.
What
build-and-test-windows.ps1unregisters and rebuilds its WSL distribution onevery run. It defaulted to the distro named
Ubuntu— the default name for astock WSL install — and ran
wsl --unregisteron it with no confirmation.--unregisterdeletes the distribution's virtual disk and cannot be undone.I hit this personally: running the script would have destroyed my main
UbuntuWSL distribution and everything in it.Changes
openserverless-build) instead of one adeveloper is likely using. Image and distro name are now separate settings
(
WSL_IMAGE/WSL_DISTRO), viawsl --install -d <image> --name <distro>.that lacks it without a typed confirmation.
-Forceskips the prompt for CI.Ubuntu-24.04(the bareUbuntualias tracks latest LTS).Also fixes Docker never actually installing inside the distro: WSL appends the
Windows PATH, so
command -v dockermatched Docker Desktop'sdocker.exeandthe install was skipped. Now strips
/mnt/*from PATH, setsappendWindowsPath=false, downloads the installer to a file instead ofcurl | sh, enables the docker service, and waits for the daemon.Testing
Ran
.\build-and-test-windows.ps1to completion on Windows 11 / WSL 2.6.3:all build-and-test scripts reported SUCCESS. Ownership-guard logic verified
against real distros (correctly refuses
Ubuntu, rebuilds the marked distro).