microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.32k stars 814 forks source link

Installing Any Distro on WSL2 Fails with "WslRegisterDistribution failed with error: 0x80070002" #5107

Open spaceraccoon opened 4 years ago

spaceraccoon commented 4 years ago

Your Windows build number: Microsoft Windows [Version 10.0.19041.207]

What you're doing and what's happening:

  1. Updated to Release Preview Ring Version 10.0.19041.207
  2. Installed kernel from https://aka.ms/wsl2kernel
  3. Upgraded current Debian WSL1 distro to WSL2 with wsl --set-version Debian 2`
  4. On reboot, Debian starts failing with Error: 0x80070002 The system cannot find the file specified.
  5. Tried to unregister Debian with wslconfig /u Debian then reinstall it. Launching Debian from Store leads to same error WslRegisterDistribution failed with error: 0x80070002.

What I've tried:

  1. Uninstall Debian, restart, remove WSL, restart, add WSL, restart, install Debian from Store
  2. Installing Debian manually
  3. Installing Ubuntu instead
  4. Tried the solution from #4618 (Null service)
  5. Tried restarting LxssManager (interestingly, I also have two other services LxssManagerUser_3c782 and MessagingService_3c782``.

Output of wslconfig /list /all:

Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore

However, in Microsoft Store, Debian is installed. When I click Launch, it leads to the same WslRegisterDistribution failed with error: 0x80070002.

If I try to initialize any distro by clicking Launch from the store or starting the app, I get

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070002
Error: 0x80070002 The system cannot find the file specified.

Press any key to continue...

It should just allow me to install a new distro.

lxcore_logs.zip - when trying to launch Debian

spaceraccoon commented 4 years ago

Update: WSL 1 works fine; this error is WSL 2 specific.

wsl --set-version Debian 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The system cannot find the file specified.
spaceraccoon commented 4 years ago

Realized this is extremely similar to what happened with #4959, including the initial errors after upgrading.

patrick330602 commented 4 years ago

Hi,

Just saw the report on the launchpad. That bug on launchpad is more related to an external drive installation issue. It could be related, and I will look into it.

On the same time, can you try to do the following to see if that works?

  1. remove WSL from Optional features and restart;
  2. recheck WSL from Optional features and restart.
spaceraccoon commented 4 years ago

Thanks @patrick330602, I've done this and unfortunately it still happens. Seems like a recurrent issue across some WSL2 installs but this and #4959 haven't received any dev support yet. I appreciate you checking in on this.

afallenhope commented 4 years ago

Not to bump but.... also having this issue. Windows 10.0.19041.264

seanwash commented 4 years ago

Adding more data here, I had this issue as well and following @patrick330602's steps seemed to work from me.

benhillis commented 4 years ago

Thanks for the pings, and sorry I didn't get a change to take a look earlier. I took a look at the traces that @spaceraccoon filed and we're failing to create our virtual network. If possible, could somebody who is still running into this issue collect a trace via feedback hub? Our category is "Developer Platform > Windows Subsystem for Linux". That trace will include networking logs so we can dig into why creating the network is failing.

spaceraccoon commented 4 years ago

Thanks @benhillis, I’d like to add that I fixed this after uninstalling Checkpoint VPN and Docker. I’m not sure what was the cause of this, but I strongly suspect it was due to Checkpoint due to the way it modifies existing routing tables on Windows which can cause the virtual network issues.

Additionally, after fixing it I faced issues where internet would fail after connecting to the Checkpoint VPN again. You can see my fix in the related issue #4246, but basically I switched over from Checkpoint’s standard client to the Checkpoint Capsule client from the windows store, which handles routing table changes differently (probably in a saner way than setting priority to 1 for all checkpoint routes).

All in all I think the change in WSL2’s network stack is clashing with VPNs; perhaps there’s a way to solve this from WSL2.

lzs commented 4 years ago

I wonder if there are any further developments on this? I have this problem now. I've uninstalled Docker, and 3rd party VPNs, but to no avail. I did have WSL2 running fine, but it stopped working after I installed VMware Workstation Player. I've since uninstalled the latter, all the Linux distributions, WSL, Virtual Machine Platform, etc, and reinstalled WSL/Virtual Machine Platform, new Ubuntu distribution, but have that same error. Installing into WSL1 still works fine.

mcipekci commented 4 years ago

I encountered same problem today after rebooting my computer after a long time and noticed I didn't have Ethernet for WSL on my network settings, after removing WSL feature from Windows and rebooting system and re adding it back to system fixed my problem, noticed Ethernet for WSL is back in my adapters.

I'm certain it's related with Ethernet for WSL is missing.

pavel-a commented 4 years ago

Same here, on AMD Brazos PC Updated Win10 to version 2004, updated wsl to v2. Unregistered my old Ubuntu 18.04 for wsl v1. Restarted. Set default version to 2. Installed Debian from the store.

C:\Users\Public\Downloads>debian
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070002
Error: 0x80070002 The system cannot find the file specified.
Press any key to continue...

The logs are attached.

Then set default back to v1 and the debian installed successfully.

logs.zip

mcipekci commented 4 years ago

Same here, on AMD Brazos PC Updated Win10 to version 2004, updated wsl to v2. Unregistered my old Ubuntu 18.04 for wsl v1. Restarted. Set default version to 2. Installed Debian from the store.

C:\Users\Public\Downloads>debian
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070002
Error: 0x80070002 The system cannot find the file specified.
Press any key to continue...

The logs are attached.

Then set default back to v1 and the debian installed successfully.

logs.zip

Could you please check if Ethernet for WSL is in present on your network connections? I'm strongly believing issue related with it.

pavel-a commented 4 years ago

@mcipekci you're right on the problem! As you wrote, after removing WSL and reinstall, "Ethernet adapter vEthernet (WSL)" is added and then install of v.2 distros seems to work. Thanks!

However, networking in V.2 distros does not work - but this is another problem. (DNS resolution fails in Ubuntu 18 but ping to numeric address works, in Debian even ping to numeric address fails) Bottom line... WSL v2 is not ready yet, back to VirtualBox.

tmontana commented 4 years ago

patrick330602's solution worked for me. I was able to keep all my files and configuration.

jamestalbot3 commented 4 years ago

I've been having this issue while trying to use WSL2 as well. It was working fine for me (minus KVM execution when trying to use qemu), but I enabled Trusted Execution in my bios by accident and that bricked it. Tried everything under the sun with no success.

@pavel-a if you're still having issues with DNS in Ubuntu, add wsl.conf in /etc/ and add

[network] generateResolvConf = false`

then edit your resolv.conf with your chosen DNS server

pavel-a commented 4 years ago

@jamestalbot3 Thanks, already noticed relation to the resolv.conf #5336

sgraf812 commented 4 years ago

I tried disabling and enabling the WSL2 feature several times now, to no avail. I removed my VirtualBox and Docker installations after the first try to do so, hoping the issue would go away, which it didn't.

It's probably related to the fact that there is no network adapter named Ethernet adapter vEthernet (WSL). I have no clue why it's not created.

CollapsedMetal commented 3 years ago

Same problem here!

I also think that it is related to the absence of vEthernet (WSL) adapter. No matter how much I try reinstalling WSL stuff in different order, there is no way the nic adapter being installed again.

Iv'e also tried to "manually" install the adapter via Hyper-V with no luck. 😥

ssklavos-ed commented 3 years ago

same here. This issue occurred out of blue. Possibly due to some docker update. IS there any plan to fix this issue soon?

shockogit commented 3 years ago

So for me this was due to the following group policy setting being set to Disabled. Setting it to Enabled resolved. The setting is:

sgraf812 commented 3 years ago

Thanks for the suggestion! Happy to hear that it works for you, unfortunately my PC already had the setting enabled.

evenoa commented 3 years ago

If I look at Adapter Settings during install of ubuntu 2004, the WSL device is created and removed. It is created with no properties, so I tried adding IPv4, and got a bit furter, Not sure which settings I should have for this device

ghost commented 3 years ago

I followed the instructions (wpr -start wsl.wprp) at the bottom of this page ... https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md#8-detailed-logs and thereby got the decisive hint that I could get rid of this problem, which I have been stuck with for a few weeks.

The file that was not found is my custom kernel file that I used in previous installations (and also on another computer / Windows installation, but possibly restored by Microsoft account ...) - the bzImage

I specified this path in a .wslconfig file. I commented out the bold line below, ran the command again, and the conversion from WSL1 to WSL2 was successful.

[wsl2] #kernel=%userprofile%\bzImage memory=3GB processors=1 localhostForwarding=false swap=2.25GB swapFile=%USERPROFILE%\AppData\Local\Temp\swap.vhdx

pageReporting=true

idleThreshold=1

Screenshot 2021-04-22 224504

Hopefully this will help someone.

sgraf812 commented 3 years ago

Following the suggestion to record a log file for the feedback hub as per the last comment (https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md#8-detailed-logs), I tried to wsl --set-version Distro 2 and after taking a while, the resulting Distro successfully booted! It didn't last time I checked, so it might also be fixed for others.

My build number is 19042.928, I'm not on Fast Ring.

dencelkbabu commented 3 years ago

I uninstalled Debian from my start menu and got an error when reinstalling it from the MS Store. I tried reinstalling multiple times.

But, after clearing folders and file (s) which included the word 'Debian' from '%USERPROFILE%\AppData\Local\Packages\', Debian was again successfully installed via MS Store.

Hope this works for someone.

amchii commented 3 years ago

Same,I can not open wsl2 after uninstall Microsoft Office,then I tried to reinstall wsl2, then same problem occured.

jphilli22 commented 3 years ago

I followed the instructions (wpr -start wsl.wprp) at the bottom of this page ... https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md#8-detailed-logs and thereby got the decisive hint that I could get rid of this problem, which I have been stuck with for a few weeks.

The file that was not found is my custom kernel file that I used in previous installations (and also on another computer / Windows installation, but possibly restored by Microsoft account ...) - the bzImage

I specified this path in a .wslconfig file. I commented out the bold line below, ran the command again, and the conversion from WSL1 to WSL2 was successful.

[wsl2] #kernel=%userprofile%\bzImage memory=3GB processors=1 localhostForwarding=false swap=2.25GB swapFile=%USERPROFILE%\AppData\Local\Temp\swap.vhdx

pageReporting=true

idleThreshold=1

Screenshot 2021-04-22 224504

Hopefully this will help someone.

It did! I've been bashing my head against this problem for weeks and you're the first person to suggest that! My kernel was set to a file in my TEMP folder of all places. No clue how that happened, but commenting out that line allowed me to register Ubuntu again. Thank you for the solution.

liataian commented 3 years ago

Commenting out all lines except "[wsl2]" in my C:\Users\vincent_chu\.wslconfig solve this problem. Now there is no 0x80070002 error and WSL2 works fine. Hopefully this will help.

Florimond commented 3 years ago

I just deleted the .wslconfig file in the user directory, which seemed to be some kind of sample, and it worked.

jackie1santana commented 3 years ago

I followed the instructions (wpr -start wsl.wprp) at the bottom of this page ... https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md#8-detailed-logs and thereby got the decisive hint that I could get rid of this problem, which I have been stuck with for a few weeks.

The file that was not found is my custom kernel file that I used in previous installations (and also on another computer / Windows installation, but possibly restored by Microsoft account ...) - the bzImage

I specified this path in a .wslconfig file. I commented out the bold line below, ran the command again, and the conversion from WSL1 to WSL2 was successful.

[wsl2] #kernel=%userprofile%\bzImage memory=3GB processors=1 localhostForwarding=false swap=2.25GB swapFile=%USERPROFILE%\AppData\Local\Temp\swap.vhdx

pageReporting=true

idleThreshold=1

Screenshot 2021-04-22 224504

Hopefully this will help someone.

@jphilli22 method with the .wslconfig file helped me !! it instantly worked!!

AKEOPLUS-boris-bocquet commented 2 years ago

Dear you all, I had a similaire issue. See WslRegisterDistributionFailed A lot of answers on the web are not efficient. Especially the answers saying to uninstall windows updates (KB...). The "good idea" came to me while reading this github issue comment

The trick was to start the Linux distribution installation (in my case, Ubuntu 20.04) using the microsoft store. Very quickly you have to edit the "vEthernet (WSL)" ETH adapter via your windows control pannel. There were a red cross on the adapter. And then I dissabled all particular pluggins / filters (that I got from Camera / Vision sensors libraries, in my case TeliGev Driver and UEYE driver). After applying the changes, a green check appeared on the adapter and the Linux installation could end correctly.

DisableFiltersAndPlugginsOnVEthWsl

Maybe this can help you. B.R.

jsc-beep commented 2 years ago

I have a same problem,and thanks for the @max-a, I remember i used to create a .wslconfig file in my user folder, when i delet it, wsl2 works again.

xepherys commented 2 years ago

So, I had been having this issue since upgrading to Windows 11. I tried a Windows Reset (soft reinstall), tried uninstalling and reinstalling WSL (with a reboot). Turns out it was an issue with my .wslconfig file (in C:\Users[user]\AppData\Local\Temp). It had a path to a non-existent swapfile and a non-existent custom kernel. I just commented out both of those lines and everything seems to be moving along.

For whatever it may be worth, I also do not have the vEthernet adapter installed but network passthrough seems to be working fine for me, at least in kali.

muratcanakcay commented 2 years ago

.wslconfig

Thank you! After 3 hours I finally made it work. Apparently there was this line "kernel=C:\temp\myCustomKernel" in my .wslconfig file and that was causing the problem. I deleted it and now wsl sees my actual kernel.

echoxxzhang commented 2 years ago

I can not found ".wslconfig" in directory, why?

jsc-beep commented 2 years ago

I can not found ".wslconfig" in directory, why?

You can refer to this link, https://docs.microsoft.com/zh-cn/windows/wsl/wsl-config

echoxxzhang commented 2 years ago

I can not found ".wslconfig" in directory, why?

You can refer to this link, https://docs.microsoft.com/zh-cn/windows/wsl/wsl-config Thank you for your reply. I have read this article, but I still can't solve my problem. I use "everything" to search, whether it's “wsl.conf” or “.wslconfig” can't be found on my PC.

JAlbertoGonzalez commented 9 months ago

Same here. Deleting .wslconfig doesn't resolve the problem, when we don't even have that file.

I can not found ".wslconfig" in directory, why?

You can refer to this link, https://docs.microsoft.com/zh-cn/windows/wsl/wsl-config

UsmanDevCraft commented 1 week ago

Same here, on AMD Brazos PC Updated Win10 to version 2004, updated wsl to v2. Unregistered my old Ubuntu 18.04 for wsl v1. Restarted. Set default version to 2. Installed Debian from the store.

C:\Users\Public\Downloads>debian
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070002
Error: 0x80070002 The system cannot find the file specified.
Press any key to continue...

The logs are attached.

Then set default back to v1 and the debian installed successfully.

logs.zip

I also faced this problem several times, what worked for me was first setting wsl to version 1 and then installing ubuntu

UsmanDevCraft commented 1 week ago

Same here, on AMD Brazos PC Updated Win10 to version 2004, updated wsl to v2. Unregistered my old Ubuntu 18.04 for wsl v1. Restarted. Set default version to 2. Installed Debian from the store.

C:\Users\Public\Downloads>debian
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070002
Error: 0x80070002 The system cannot find the file specified.
Press any key to continue...

The logs are attached. Then set default back to v1 and the debian installed successfully. logs.zip

I also faced this problem several times, what worked for me was first setting wsl to version 1 and then installing ubuntu

after that once ubuntu is installed as version 1, to convert it to version 2: wsl --set-version Ubuntu 2

if it might five error that .wslconfig file not found or extension=none; follow these steps: Steps to Rename the File Correctly Enable File Name Extensions:

Open File Explorer. Click on the View tab at the top of the window. Check the box labeled File name extensions. This will allow you to see the full file name, including extensions. Locate the .wslconfig.txt File:

Navigate to C:\Users\Usman. Rename the File:

Right-click on wslconfig.txt and select Rename. Change the name to .wslconfig. Make sure to remove .txt entirely. If Windows prompts you about changing the file extension, click Yes. Verify the File:

Make sure the file is now named .wslconfig without any extension. Open it with Notepad to ensure it contains the correct content: ini Copy code [wsl2] networkingMode=None Retry the Conversion Process Once you’ve corrected the filename:

Open PowerShell as Administrator.

Run the command to shut down WSL:

bash Copy code wsl --shutdown Then, attempt to convert Ubuntu to WSL 2 again:

bash Copy code wsl --set-version Ubuntu 2

CatalinFetoiu commented 1 week ago

can you please collect networking logs using instructions at https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues?

this will generate a zip with name starting with "WslNetworkingLogs"

thanks