Vscode-remote-release: Unable to launch vscode in remote mode from WSL2

Created on 7 Sep 2019  路  16Comments  路  Source: microsoft/vscode-remote-release

"Access is denied" error is thrown while launching vscode from WSL2. Below is the output in verbose mode

Access is denied.
cat: ./remote-wsl-loc.txt: No such file or directory
rm: cannot remove 'remote-wsl-loc.txt': No such file or directory
[main 2019-09-07T16:38:48.032Z] Sending some foreground love to the running instance: 12252
[main 2019-09-07T16:38:48.038Z] Sending env to running instance...
[main 2019-09-07T16:38:48.143Z] Sent env to running instance. Terminating...
[main 2019-09-07T16:38:48.143Z] Lifecycle#kill()


  • VSCode Version: 1.38.0
  • Local OS Version: Windows 10 - build 18975
  • Remote OS Version: Ubuntu 18.04
  • Remote Extension/Connection Type: WSL

Steps to Reproduce:

  1. Launch WSL2
  2. Navigate to any folder and type code .


Does this issue occur when you try this locally?: No
Does this issue occur when you try this locally and all extensions are disabled?: No

wsl wsl2

Most helpful comment

Yes, I have just one distro (Ubuntu). uname -r provides the same output: 4.19.59-microsoft-standard
Is there a way to update WSL to build 41959 right now, or we just need to wait for a new Windows build?

You're on 41959 already - see the 4.19.59 bit from uname -r.
I find it very odd it works in Powershell for you however. Do you only have one VSCode install? What directory is it in?


On a sidenote, I fixed the issue by simply editing code under the VScode/bin directory. Simplest is to launch Notepad as administrator, open the code file, and change the if on line 29.

Change it to if [ $WSL_BUILD -ge 41955 ] && [ $WSL_BUILD -lt 41959 ]; then. This simply only runs the workaround on the affected builds (before 41959 but after or equal to 41955).


Looks like the fix is already included in microsoft/vscode, so it's just a matter of waiting now... Here I was looking to contribute!

All 16 comments

Having the exact same issue when using Windows Terminal (Preview) app or Cmder.
However, if I start Powershell console and type wsl and then code .
it's working well

Having the exact same issue when using Windows Terminal (Preview) app or Cmder.
However, if I start Powershell console and type wsl and then code .
it's working well

Odd, I face the issue regardless of how WSL is entered. Just to check, you're running on the same WSL VM right?

You don't have any difference in the output of uname -r across PowerShell and Windows Terminal do you?

The Access Is Denied is due to the workaround for microsoft/WSL#4337. Basically trying to write to the VSCode install directory fails, which means the file isn't there for subsequent cat and rm.

cd /win/c/Program\ Files/VS\ Code/
cmd.exe /C ".\\bin\\code.cmd --locate-extension ms-vscode-remote.remote-wsl > ./remote-wsl-loc.txt"
Access is denied.

This bug has been fixed now, so from WSL build 41959 we can likely skip the whole workaround.

Yes, I have just one distro (Ubuntu). uname -r provides the same output: 4.19.59-microsoft-standard
Is there a way to update WSL to build 41959 right now, or we just need to wait for a new Windows build?

Yes, I have just one distro (Ubuntu). uname -r provides the same output: 4.19.59-microsoft-standard
Is there a way to update WSL to build 41959 right now, or we just need to wait for a new Windows build?

You're on 41959 already - see the 4.19.59 bit from uname -r.
I find it very odd it works in Powershell for you however. Do you only have one VSCode install? What directory is it in?


On a sidenote, I fixed the issue by simply editing code under the VScode/bin directory. Simplest is to launch Notepad as administrator, open the code file, and change the if on line 29.

Change it to if [ $WSL_BUILD -ge 41955 ] && [ $WSL_BUILD -lt 41959 ]; then. This simply only runs the workaround on the affected builds (before 41959 but after or equal to 41955).


Looks like the fix is already included in microsoft/vscode, so it's just a matter of waiting now... Here I was looking to contribute!

You're awesome! Your fix worked :-)
I have only one vscode installed. Path is C:Program FilesMicrosoft VS CodeCode.exe

Glad I could help!

I suppose this can be closed then, seeing as we're just waiting for a new patch of VSCode.

Very strange. It stopped working from Windows Terminal. If i try "code" I get:

Command 'code' not found, did you mean:

command 'ode' from deb plotutils
command 'tcode' from deb emboss
command 'cobe' from deb python-cobe
command 'cdde' from deb cdde
command 'node' from deb nodejs
command 'cde' from deb cde

Try: sudo apt install

But i guess this is a bug in Windows Terminal

Code should be added from your Windows path, there's no need to install it there.

Can you do an ls -lash /mnt/c/Program\ Files/Microsoft\ VS\ Code/bin.

Ok, I now understand the problem. On Powershell I was always running as Administrator (though there was no prompt). This is why I didn't get access denied. Also, for some reason code is accessible only as an administrator on my machine.

output for your command is:
ls: cannot access '/mnt/c/Program Files/Microsoft VS Code/bin': Input/output error

When running as admin powershell console (and then wsl) it does work

Did you include the backslashes?

Yup, copy pasted your command.

Seems like your path is mucked up, you're not running as root right?

Running as regular user in WSL in both cases.

Yes, I have just one distro (Ubuntu). uname -r provides the same output: 4.19.59-microsoft-standard
Is there a way to update WSL to build 41959 right now, or we just need to wait for a new Windows build?

You're on 41959 already - see the 4.19.59 bit from uname -r.
I find it very odd it works in Powershell for you however. Do you only have one VSCode install? What directory is it in?

On a sidenote, I fixed the issue by simply editing code under the VScode/bin directory. Simplest is to launch Notepad as administrator, open the code file, and change the if on line 29.

Change it to if [ $WSL_BUILD -ge 41955 ] && [ $WSL_BUILD -lt 41959 ]; then. This simply only runs the workaround on the affected builds (before 41959 but after or equal to 41955).

Looks like the fix is already included in microsoft/vscode, so it's just a matter of waiting now... Here I was looking to contribute!

This worked for me. I was able to launch vscode without any issue from Windows Terminal.

Thank you so much for your help.

So my problem probably was that I was getting hit by this bug: http://github.com/microsoft/WSL/issues/4377

The workaround is to restart WSL like this:

wsl --shutdown
wsl
Was this page helpful?
0 / 5 - 0 ratings