
我作為普通用戶在 Windows 終端機中運行 Ubuntu for WSL2 時遇到問題。
我沒有得到 bash 提示符,而是得到了以下內容,我認為這是因為我有多個同名的 Ubuntu 發行版,請參見下文:
Windows 版本: 微軟Windows [版本10.0.19044.1586]
WSL 版本:0.0.0.0
您使用的是 WSL1 還是 WSL2:WSL2
核心版本:Linux 版本 5.10.102.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0、GNU ld (GNU Binutils) 2.34.0.20200222) #1 SMP 00:30:59 世界標準時間2022 年
重現步驟:
以非管理員帳戶開啟 Windows 終端機。
點擊頂部的向下箭頭標籤並選擇 Ubuntu。
將出現一個新選項卡,並顯示以下錯誤訊息:
當文件已存在時無法建立該文件。
[進程已退出,代碼為 4294967295 (0xffffffff)] 您現在可以使用 Ctrl+D 關閉此終端,或按 Enter 重新啟動。
我認為這個問題與以下事實有關:有兩個名為 Ubuntu 的 Ubuntu 發行版,但在登錄中具有不同的 GUID/UUID:
wsl -l -v
NAME STATE VERSION
* Ubuntu Running 2
Ubuntu Stopped 2
PS C:\Users\me-user> reg query hkcu\software\microsoft\windows\currentversion\lxss
HKEY_CURRENT_USER\software\microsoft\windows\currentversion\lxss
DefaultVersion REG_DWORD 0x2
DefaultDistribution REG_SZ {c329c2ee-fd20-4986-873a-351737eaf399}
HKEY_CURRENT_USER\software\microsoft\windows\currentversion\lxss\AppxInstallerCache
HKEY_CURRENT_USER\software\microsoft\windows\currentversion\lxss\{97307d71-8998-42a4-9600-ff372b6ec1ee}
HKEY_CURRENT_USER\software\microsoft\windows\currentversion\lxss\{c329c2ee-fd20-4986-873a-351737eaf399}
如果您注意到第一個有值,但第二個沒有:
第一:
PS C:\Users\me-user> reg query "hkcu\software\microsoft\windows\currentversion\lxss\{97307d71-8998-42a4-9600-ff372b6ec1ee}" /v DistributionName
HKEY_CURRENT_USER\software\microsoft\windows\currentversion\lxss\{97307d71-8998-42a4-9600-ff372b6ec1ee}
DistributionName REG_SZ Ubuntu
PS C:\Users\me-user> reg query "hkcu\software\microsoft\windows\currentversion\lxss\{97307d71-8998-42a4-9600-ff372b6ec1ee}"
HKEY_CURRENT_USER\software\microsoft\windows\currentversion\lxss\{97307d71-8998-42a4-9600-ff372b6ec1ee}
State REG_DWORD 0x1
DistributionName REG_SZ Ubuntu
Version REG_DWORD 0x2
BasePath REG_SZ C:\Users\me-user\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState
Flags REG_DWORD 0xf
DefaultUid REG_DWORD 0x0
PackageFamilyName REG_SZ CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
第二個
PS C:\Users\me-user> reg query "hkcu\software\microsoft\windows\currentversion\lxss\{c329c2ee-fd20-4986-873a-351737eaf399}" /v DistributionName
HKEY_CURRENT_USER\software\microsoft\windows\currentversion\lxss\{c329c2ee-fd20-4986-873a-351737eaf399}
DistributionName REG_SZ Ubuntu
(沒有其他鍵/值)
我注意到預設的 wsl 設定為第二個c329c2ee-fd20-4986-873a-351737eaf399
:
DefaultDistribution REG_SZ {c329c2ee-fd20-4986-873a-351737eaf399}
將預設分佈更改為“第一個”是否安全,{97307d71-8998-42a4-9600-ff372b6ec1ee}
以便我在嘗試在 Window 終端機中打開它時不再看到錯誤訊息?
另請參閱: https://github.com/microsoft/WSL/issues/7998
Cannot create a file when that file already exists.
[process exited with code 4294967295 (0xffffffff)]
You can now close this terminal with Ctrl+D, or press Enter to restart.