WSL icon indicating copy to clipboard operation
WSL copied to clipboard

The network name can not be found

Open dotnetCarpenter opened this issue 4 years ago • 12 comments

Version

Microsoft Windows [Version 10.0.19044.1415]

WSL Version

  • [X] WSL 2
  • [ ] WSL 1

Kernel Version

5.10.60.1-microsoft-standard-WSL2

Distro Version

Ubuntu 21.04

Other Software

Windows Terminal, Version: 1.11.3471.0

Repro Steps

  1. Open Windows Terminal with Windows.Terminal.Wsl

Expected Behavior

The terminal should open inside my Ubuntu distro

Actual Behavior

Sometimes I get "The network name can not be found" and the terminal immediately exits. I think it is a race condition, since this does not always happen. But when it does, I can not start Windows Terminal with Windows.Terminal.Wsl at all, until wsl is started.

My work-around is to open PowerShell and write wsl -d Ubuntu. After that, I can open Windows Terminal as usual.

Diagnostic Logs

wls2.etl.zip

dotnetCarpenter avatar Dec 19 '21 19:12 dotnetCarpenter

Same problem

gfafei avatar Jan 12 '22 07:01 gfafei

I have a same problem when startingDirectory set as "\\\\wsl$\\DISTRO NAME\\home\\USERNAME".

resolve: use commandline: wsl ~ or wsl -d DISTRO --cd ~

like this: image

fyxw avatar Jan 13 '22 07:01 fyxw

@fyxw was right. I change the Starting diretory to default value, which is %USERPROFILE%, problem solved

gfafei avatar Jan 13 '22 08:01 gfafei

I have a same problem when startingDirectory set as "\\\\wsl$\\DISTRO NAME\\home\\USERNAME".

resolve: use commandline: wsl ~ or wsl -d DISTRO --cd ~

like this: image

This seemingly solved the problem for me.

I was using Windows Terminal. In its Settings > Profiles > Ubuntu-20.04 > General, I had Command Line set to wsl.exe -d Ubuntu-20.04 and Starting Directory set to the absolute path through the windows filesystem to the wsl2 /home/[user] (with backslashes). Changing Starting Directory to %USERPROFILE% stopped the error occurring, but meant the bash opened up in my windows user directory I think. Then appending --cd ~ to the Command Line argument meant I was back to opening up the bash in my wsl2 ubuntu user directory.

DavidStanley94 avatar Jan 17 '22 10:01 DavidStanley94

thanks @fyxw - now it works for me.

I still feel this issue should stay open as this is a regression. It's not obvious why this is happening only that the work-around is to have either wsl.exe ~ or wsl.exe -d DISTRO --cd ~ in the Command line field in settings.

The default value for Command line is wsl.exe -d Ubuntu on my system.

dotnetCarpenter avatar Jan 19 '22 22:01 dotnetCarpenter

Unfortunately, I just got the following error message:

[error 0x8007010b when launching `wsl.exe -d Ubuntu --cd ~']
Could not access starting directory "\\wsl$\Ubuntu\home\dotnet"

So the work-around does not work for me. :(

dotnetCarpenter avatar Jan 21 '22 23:01 dotnetCarpenter

Unfortunately, I just got the following error message:

[error 0x8007010b when launching `wsl.exe -d Ubuntu --cd ~']
Could not access starting directory "\\wsl$\Ubuntu\home\dotnet"

So the work-around does not work for me. :(

Did you set the startingDirectory to %USERPROFILE% or other windows path, if startingDirectory is a network path, may cause it. \\wsl$\Ubuntu\xxx\ is a network path, it may not exist when wsl is closed.

fyxw avatar Jan 22 '22 02:01 fyxw

Hi @fyxw. No, I had startingDirectory sat to \\wsl$\Ubuntu\xxx\. Changing that to the default %USERPROFILE% and Command line to wsl.exe ~ seems to fix my issue. Thanks!

dotnetCarpenter avatar Jan 24 '22 18:01 dotnetCarpenter

In my case, this was caused by having \\wsl.localhost\Ubuntu\home\username set as the startingDirectory and unknowingly having Virtualisation turned off in my UEFI.

It wasn't until I changed startingDirectory back to %USERPROFILE% that WSL correctly told me that Virtualisation had been turned off.

xandora avatar Jan 26 '22 20:01 xandora

yeah i did wsl -update and thise network error happened. solution worked

Linux2021 avatar Apr 22 '22 20:04 Linux2021

I had to restart Windows after changing the commandline and startingDirectory settings. Worked perfectly after the restart.

stuffaboutpete avatar Jul 08 '22 11:07 stuffaboutpete

Make sure Virtualization is enabled in BIOS (that's what it's called for intel CPU's) especially if you've been recently messing with your BIOS settings.

dimaboychev avatar Jul 26 '22 15:07 dimaboychev