🐧

WSL2が起動できなくて困った話

2024/03/14に公開

環境

OS : Windows 11 Home 64 bit
CPU : 13th Gen Intel(R) Core(TM) i7-1355U 2.60 GHz
RAM : 32.0 GB
STORAGE :1TB

事象

  1. Windows TerminalのWSLは問題なく開くことができる
  2. WSLコマンドで入ろうとすると起動できずに以下のようなエラーが出る
PS C:\Users\tomo > wsl
<3>WSL (9) ERROR: CreateProcessParseCommon:708: Failed to translate C:\Users\tomo
<3>WSL (9) ERROR: CreateProcessParseCommon:754: getpwuid(0) failed 2
<3>WSL (9) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\PowerShell\7-preview
<3>WSL (9) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler
(環境変数順にエラーが表示される)
Processing fstab with mount -a failed.
Failed to mount C:\, see dmesg for more details.

<3>WSL (9) ERROR: CreateProcessEntryCommon:331: getpwuid(0) failed 2
<3>WSL (9) ERROR: CreateProcessEntryCommon:502: execvpe /bin/sh failed 2
<3>WSL (9) ERROR: CreateProcessEntryCommon:505: Create process not expected to return

いろいろ試した

再インストールやunregisterしたりセットアップしたりそれでも変化なし

結論


Issueを検索すると、https://github.com/microsoft/WSL/issues/9252#issuecomment-1648236238 に書いてありました。

PS C:\Users\tomo> wsl --list
Linux 用 Windows サブシステム ディストリビューション:
docker-desktop-data (既定)
Ubuntu
docker-desktop

▲ んで見てみると案の定、docker-desktopがデフォルトになっていた

PS C:\Users\tomo> wsl --setdefault Ubuntu
この操作を正しく終了しました。
PS C:\Users\tomo> wsl
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

tomo@TOMO-LIFEBOOK:/mnt/c/Users/tomo$

▲ 修正&入れた!!!!

Docker Desktopをインストールすると自分をデフォルトのディストリビューションに設定してしまうらしく、WSLコマンドで起動しようとすると、ユーザーが使うことが想定されていないdocker-distroを起動してしまうらしく強制終了するとのこと。
(Windows Terminalで直接Ubuntuを起動すると問題なく起動するのも納得)


▲ なんでLinuxのところにこれらが表示されるのか薄々疑問に思ってたけど、docker-desktop-dataやdocker-desktopもWSLディストリビューションとして登録されてた

というわけで同じような問題が発生している人に届け!
以上です~

Discussion