New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running VSCode for Linux in WSL #2760

Closed
mredbishop opened this Issue Dec 18, 2017 · 27 comments

Comments

Projects
None yet
@mredbishop

mredbishop commented Dec 18, 2017

I'm creating a new issue for this as the previous two got way off track talking about the windows version of VS Code from WSL.

I now have VS Code for Ubuntu installed in the Ubuntu WSL in windows at version 1.19.0-insider

To get to the point at which I am at, install an XServer for windows, I use VcXsrv with the following settings:
image
image
image

Then, in WSL you need at least the creators update, do the following:
Install the required libs

ed@ed-surface-book: sudo apt-get install libgtk2.0-0
ed@ed-surface-book: sudo apt-get install libxss1
ed@ed-surface-book: sudo apt-get install libasound2

Add VS Code repository

ed@ed-surface-book: curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
ed@ed-surface-book: sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
ed@ed-surface-book: sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'

Install VS Code Insiders (and code itself if you like)

ed@ed-surface-book: sudo apt-get update
ed@ed-surface-book: sudo apt-get install code
ed@ed-surface-book: sudo apt-get install code-insiders

Set the environmental paramaters

ed@ed-surface-book: export LIBGL_ALWAYS_INDIRECT=1
ed@ed-surface-book: export DISPLAY=0:0

NOTE At this point you need the DBUS service to be running (thanks @KinmanLam, I forgot :) ):

sudo service dbus start

Attempt to run VS Code Insiders with verbose logging so you see any issues

ed@ed-surface-book: code-insiders --verbose
[6398:1218/130534.978077:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
[6398:1218/130534.978163:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected

I now have only two warnings about multiple instances of AudioManager being detected and no errors. When clicking exit in XServer, it reports that there are clients connected so VS Code seems to be attaching to the XServer instance however the app does not display in the XServer window.
image

As there are no further errors in the verbose output I am stuck as to where to go next to debug this, are there any other logs/output sources I can look into?

Related:
Running VS Code native in WSL
Support launching VS Code from Bash on Ubuntu on Windows

@commanderturner

@jack-guy

This comment has been minimized.

Show comment
Hide comment
@jack-guy

jack-guy Dec 18, 2017

@therealkenc Has done a lot of investigating on this. Two recent comments by him that shed some light on why this is happening:
#2293 (comment)
#2293 (comment)

FWIW in my time experimenting with running my own electron app on WSL, I believe I encountered the same event loop problem. Ultimately, the addition of

setInterval(() => {}, 1);

to the main process kept the event loop spinning in the background. I have no clue why that worked, however. Maybe someone could try plugging that line into a custom VSCode build to see if it works?

jack-guy commented Dec 18, 2017

@therealkenc Has done a lot of investigating on this. Two recent comments by him that shed some light on why this is happening:
#2293 (comment)
#2293 (comment)

FWIW in my time experimenting with running my own electron app on WSL, I believe I encountered the same event loop problem. Ultimately, the addition of

setInterval(() => {}, 1);

to the main process kept the event loop spinning in the background. I have no clue why that worked, however. Maybe someone could try plugging that line into a custom VSCode build to see if it works?

@khuongduybui

This comment has been minimized.

Show comment
Hide comment
@khuongduybui

khuongduybui Dec 19, 2017

Wait, so someone planned to close the issue in Microsoft/vscode#13138 and link here because (s)he thought the issue had nothing to do with VSCode and instead a problem with WSL.

I followed the link here only to find out what the next step is probably a PR to Microsoft/vscode ???

khuongduybui commented Dec 19, 2017

Wait, so someone planned to close the issue in Microsoft/vscode#13138 and link here because (s)he thought the issue had nothing to do with VSCode and instead a problem with WSL.

I followed the link here only to find out what the next step is probably a PR to Microsoft/vscode ???

@jack-guy

This comment has been minimized.

Show comment
Hide comment
@jack-guy

jack-guy Dec 19, 2017

@khuongduybui The one-liner I recommended would be a hack that could help verify the underlying event loop issue in running VS Code (if it even works). This is 100% a problem with WSL, as is elaborated on in the comments I linked.

jack-guy commented Dec 19, 2017

@khuongduybui The one-liner I recommended would be a hack that could help verify the underlying event loop issue in running VS Code (if it even works). This is 100% a problem with WSL, as is elaborated on in the comments I linked.

@khuongduybui

This comment has been minimized.

Show comment
Hide comment
@khuongduybui

khuongduybui Dec 19, 2017

ok thanks for the clarification.

khuongduybui commented Dec 19, 2017

ok thanks for the clarification.

@mredbishop

This comment has been minimized.

Show comment
Hide comment
@mredbishop

mredbishop Dec 19, 2017

@khuongduybui Yeh sorry for not being clearer, based on what @therealkenc and @harangue have found out, it looks like the event loop locks up on WSL where this doesn't happen in "clean" Linux.

mredbishop commented Dec 19, 2017

@khuongduybui Yeh sorry for not being clearer, based on what @therealkenc and @harangue have found out, it looks like the event loop locks up on WSL where this doesn't happen in "clean" Linux.

@khuongduybui

This comment has been minimized.

Show comment
Hide comment
@khuongduybui

khuongduybui Dec 20, 2017

Guys, I just updated to 17063. Code is running now, wow!

2017-12-20

khuongduybui commented Dec 20, 2017

Guys, I just updated to 17063. Code is running now, wow!

2017-12-20

@mredbishop

This comment has been minimized.

Show comment
Hide comment
@mredbishop

mredbishop Dec 20, 2017

mredbishop commented Dec 20, 2017

@mredbishop

This comment has been minimized.

Show comment
Hide comment
@mredbishop

mredbishop Dec 20, 2017

Do I close this issue now or wait until it's in the mainstream release?

mredbishop commented Dec 20, 2017

Do I close this issue now or wait until it's in the mainstream release?

@DarthSpock

This comment has been minimized.

Show comment
Hide comment
@DarthSpock

DarthSpock Dec 20, 2017

I think it's safe to say you can close it but @therealkenc or somebody will need to add the "fixed in insiders build" tag. Question is if the fix for this can be backported to 16299.

DarthSpock commented Dec 20, 2017

I think it's safe to say you can close it but @therealkenc or somebody will need to add the "fixed in insiders build" tag. Question is if the fix for this can be backported to 16299.

@NellyWhadsDev

This comment has been minimized.

Show comment
Hide comment
@NellyWhadsDev

NellyWhadsDev Dec 24, 2017

Hey guys (espeically @khuongduybui ), been trying to set this up as well. Few questions:

  1. When running code through WSL, (natively installed in WSL), will I be able to safely edit linux files? I know you can launch the windows-installed vscode from WSL, but this will not allow for safe editing since windows doesn't handle all of the permission setting required by linux.
  2. Can someone test if this works with the regular version of VSCode (non-insiders)? If so, how'd you get it to work? I'm currently struggling with it (Windows Insiders build 17063)

NellyWhadsDev commented Dec 24, 2017

Hey guys (espeically @khuongduybui ), been trying to set this up as well. Few questions:

  1. When running code through WSL, (natively installed in WSL), will I be able to safely edit linux files? I know you can launch the windows-installed vscode from WSL, but this will not allow for safe editing since windows doesn't handle all of the permission setting required by linux.
  2. Can someone test if this works with the regular version of VSCode (non-insiders)? If so, how'd you get it to work? I'm currently struggling with it (Windows Insiders build 17063)
@AndrewPardoe

This comment has been minimized.

Show comment
Hide comment
@AndrewPardoe

AndrewPardoe Dec 25, 2017

Thanks for all the investigation! I've verified that this works with non-insiders Code, on Windows Insider build 17063.

I'm running VCXsrv, multiwindow, no special configuration. I added the LIBGL line to my .bashrc, in addition to the DISPLAY line that's always been there. You also need to be running dbus: sudo service dbus start

export DISPLAY=0:0
LIBGL_ALWAYS_INDIRECT=1

I installed Code (non-insiders) using the commands from above:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install code

Running Code is slow, but it works. A few times Code failed to launch completely and I had to kill it using Task Manager. As expected, it can create and edit files in your Linux paths.

AndrewPardoe commented Dec 25, 2017

Thanks for all the investigation! I've verified that this works with non-insiders Code, on Windows Insider build 17063.

I'm running VCXsrv, multiwindow, no special configuration. I added the LIBGL line to my .bashrc, in addition to the DISPLAY line that's always been there. You also need to be running dbus: sudo service dbus start

export DISPLAY=0:0
LIBGL_ALWAYS_INDIRECT=1

I installed Code (non-insiders) using the commands from above:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install code

Running Code is slow, but it works. A few times Code failed to launch completely and I had to kill it using Task Manager. As expected, it can create and edit files in your Linux paths.

@mredbishop

This comment has been minimized.

Show comment
Hide comment
@mredbishop

mredbishop Jan 8, 2018

Interestingly, this has stopped working for me again now 😢 with a Pulseaudio issue:

ed@ed-surface-book:~$ code --verbose
Assertion 'pthread_mutex_unlock(&m->mutex) == 0' failed at pulsecore/mutex-posix.c:108, function pa_mutex_unlock(). Aborting.

Up to now (for the last 19 days) this was working almost flawlessly and was my main coding environment.

mredbishop commented Jan 8, 2018

Interestingly, this has stopped working for me again now 😢 with a Pulseaudio issue:

ed@ed-surface-book:~$ code --verbose
Assertion 'pthread_mutex_unlock(&m->mutex) == 0' failed at pulsecore/mutex-posix.c:108, function pa_mutex_unlock(). Aborting.

Up to now (for the last 19 days) this was working almost flawlessly and was my main coding environment.

@therealkenc

This comment has been minimized.

Show comment
Hide comment
@therealkenc

therealkenc Jan 8, 2018

Collaborator

Assertion 'pthread_mutex_unlock(&m->mutex) == 0' failed at pulsecore/mutex-posix.c:108, function pa_mutex_unlock(). Aborting.

That is #486 aka #1006, as explained in #648 (message) and Microsoft/vscode#13138 (message).

Collaborator

therealkenc commented Jan 8, 2018

Assertion 'pthread_mutex_unlock(&m->mutex) == 0' failed at pulsecore/mutex-posix.c:108, function pa_mutex_unlock(). Aborting.

That is #486 aka #1006, as explained in #648 (message) and Microsoft/vscode#13138 (message).

@sunilmut

This comment has been minimized.

Show comment
Hide comment
@sunilmut

sunilmut Jan 8, 2018

Member

Marking this a discussion only thread again.

Member

sunilmut commented Jan 8, 2018

Marking this a discussion only thread again.

@mredbishop

This comment has been minimized.

Show comment
Hide comment
@mredbishop

mredbishop Jan 31, 2018

Ok, it's fixed again in insiders (Windows insiders that is)

mredbishop commented Jan 31, 2018

Ok, it's fixed again in insiders (Windows insiders that is)

@KinmanLam

This comment has been minimized.

Show comment
Hide comment
@KinmanLam

KinmanLam Feb 8, 2018

Hello all, I have followed your exact instructions and have got to this point:

surface:~$ code --verbose [2591:0207/181309.146481:ERROR:bus.cc(427)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory [2591:0207/181309.199349:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected [2591:0207/181309.199398:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected

I get the same error with: code-insiders --verbose

KinmanLam commented Feb 8, 2018

Hello all, I have followed your exact instructions and have got to this point:

surface:~$ code --verbose [2591:0207/181309.146481:ERROR:bus.cc(427)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory [2591:0207/181309.199349:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected [2591:0207/181309.199398:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected

I get the same error with: code-insiders --verbose

@mredbishop

This comment has been minimized.

Show comment
Hide comment
@mredbishop

mredbishop Feb 8, 2018

@KinmanLam Sorry, I missed out the instruction to start the DBUS service as I have that running in WSL from startup, I've added this to the notes now too but here's the command for reference.

sudo service dbus start

mredbishop commented Feb 8, 2018

@KinmanLam Sorry, I missed out the instruction to start the DBUS service as I have that running in WSL from startup, I've added this to the notes now too but here's the command for reference.

sudo service dbus start
@alexanderdevm

This comment has been minimized.

Show comment
Hide comment
@alexanderdevm

alexanderdevm Feb 17, 2018

I have following the instructions on this issue, and from clean wsl ubuntu installed and display=:0 exported. I am able to run xeyes, firefox, gedit, etc...

when i start code or code-insiders, code just runs in the background without any windows GUI starting.

code --verbose -s --disable-gpu [364:0217/023541.956859:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected [364:0217/023541.956913:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected

code --verbose [428:0217/024131.817155:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected [428:0217/024131.817256:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected [456:0217/024132.114776:ERROR:gl_implementation.cc(245)] Failed to load libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory [456:0217/024132.116547:ERROR:gpu_child_thread.cc(324)] Exiting GPU process due to errors during initialization

If I understand correctly, I need to install windows insiders build to run code is wsl or there another solution to get the gui up and running.

alexanderdevm commented Feb 17, 2018

I have following the instructions on this issue, and from clean wsl ubuntu installed and display=:0 exported. I am able to run xeyes, firefox, gedit, etc...

when i start code or code-insiders, code just runs in the background without any windows GUI starting.

code --verbose -s --disable-gpu [364:0217/023541.956859:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected [364:0217/023541.956913:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected

code --verbose [428:0217/024131.817155:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected [428:0217/024131.817256:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected [456:0217/024132.114776:ERROR:gl_implementation.cc(245)] Failed to load libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory [456:0217/024132.116547:ERROR:gpu_child_thread.cc(324)] Exiting GPU process due to errors during initialization

If I understand correctly, I need to install windows insiders build to run code is wsl or there another solution to get the gui up and running.

@mredbishop

This comment has been minimized.

Show comment
Hide comment
@mredbishop

mredbishop Feb 18, 2018

mredbishop commented Feb 18, 2018

@Xixi20160512

This comment has been minimized.

Show comment
Hide comment
@Xixi20160512

Xixi20160512 Feb 23, 2018

@khuongduybui hi,can you tell me which way that you get the 17063 insider build?thanks!

Xixi20160512 commented Feb 23, 2018

@khuongduybui hi,can you tell me which way that you get the 17063 insider build?thanks!

@jawjop

This comment has been minimized.

Show comment
Hide comment
@jawjop

jawjop Feb 23, 2018

@Xixi20160512
Win key + I
Search for "insider"
Click "Windows Insider Programme settings"
Sign up to Insider builds. The settings you want to select are "Active development of Windows" and "Slow" ring.

I just did this to test the solution. My PC is currently downloading version 17074.1002

EDIT:
And it works :) VS Code is running perfectly on WSL (aside from a bunch of dbus/pulseaudio errors). Thanks lads!

jawjop commented Feb 23, 2018

@Xixi20160512
Win key + I
Search for "insider"
Click "Windows Insider Programme settings"
Sign up to Insider builds. The settings you want to select are "Active development of Windows" and "Slow" ring.

I just did this to test the solution. My PC is currently downloading version 17074.1002

EDIT:
And it works :) VS Code is running perfectly on WSL (aside from a bunch of dbus/pulseaudio errors). Thanks lads!

@cyokodog cyokodog referenced this issue Mar 31, 2018

Open

install #3

@therealkenc

This comment has been minimized.

Show comment
Hide comment
@therealkenc

therealkenc May 25, 2018

Collaborator

Ran course.

Collaborator

therealkenc commented May 25, 2018

Ran course.

@jgoux

This comment has been minimized.

Show comment
Hide comment
@jgoux

jgoux Aug 6, 2018

Hello,

it seems that of today (Windows 10 build 17730.1000 + Code Insiders 1.26.0), the settings are a little different than the one you provided to make it works.

I didn't need to make these 2 instructions :

sudo apt-get install libgtk2.0-0
export LIBGL_ALWAYS_INDIRECT=1

And I needed to install the following :
sudo apt-get install libgl1

Also, to get rid of the error libGL error: failed to load driver: swrast, I needed to launch VcXserver with the -nowgl option : vcxsrv.exe :0 -ac -terminate -lesspointer -multiwindow -clipboard -nowgl

I've put these at the end of my ~/.bashrc so they get started automatically :

# WSL
sudo /etc/init.d/dbus start &> /dev/null
export DISPLAY=:0

Hope this helps! 😄

I still have a lot of these warnings :

[952:0806/112602.063993:ERROR:bus.cc(395)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[952:0806/112602.066028:ERROR:bus.cc(395)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

Does anyone have any idea if it's solvable?

jgoux commented Aug 6, 2018

Hello,

it seems that of today (Windows 10 build 17730.1000 + Code Insiders 1.26.0), the settings are a little different than the one you provided to make it works.

I didn't need to make these 2 instructions :

sudo apt-get install libgtk2.0-0
export LIBGL_ALWAYS_INDIRECT=1

And I needed to install the following :
sudo apt-get install libgl1

Also, to get rid of the error libGL error: failed to load driver: swrast, I needed to launch VcXserver with the -nowgl option : vcxsrv.exe :0 -ac -terminate -lesspointer -multiwindow -clipboard -nowgl

I've put these at the end of my ~/.bashrc so they get started automatically :

# WSL
sudo /etc/init.d/dbus start &> /dev/null
export DISPLAY=:0

Hope this helps! 😄

I still have a lot of these warnings :

[952:0806/112602.063993:ERROR:bus.cc(395)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[952:0806/112602.066028:ERROR:bus.cc(395)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

Does anyone have any idea if it's solvable?

@sworisbreathing

This comment has been minimized.

Show comment
Hide comment
@sworisbreathing

sworisbreathing Aug 21, 2018

I don't quite understand why this issue was closed. It's not working for me.

sworisbreathing commented Aug 21, 2018

I don't quite understand why this issue was closed. It's not working for me.

@fdmnio

This comment has been minimized.

Show comment
Hide comment
@fdmnio

fdmnio Aug 28, 2018

This is working for me, thanks!

I've written a more detailed and beginners-proof version of the installation steps you provided here.

Still, VS Code is blurry on High DPI monitors. Anyone knows how to fix that?
Overriding Windows' DPI settings for VcXserver works but makes VS Code very unresponsive for me.

fdmnio commented Aug 28, 2018

This is working for me, thanks!

I've written a more detailed and beginners-proof version of the installation steps you provided here.

Still, VS Code is blurry on High DPI monitors. Anyone knows how to fix that?
Overriding Windows' DPI settings for VcXserver works but makes VS Code very unresponsive for me.

@spences10

This comment has been minimized.

Show comment
Hide comment
@spences10

spences10 Sep 14, 2018

This is working for me, thanks!

I've written a more detailed and beginners-proof version of the installation steps you provided here.

Still, VS Code is blurry on High DPI monitors. Anyone knows how to fix that?
Overriding Windows' DPI settings for VcXserver works but makes VS Code very unresponsive for me.

That Gist you linked is a 404 @fdmnio 😢

spences10 commented Sep 14, 2018

This is working for me, thanks!

I've written a more detailed and beginners-proof version of the installation steps you provided here.

Still, VS Code is blurry on High DPI monitors. Anyone knows how to fix that?
Overriding Windows' DPI settings for VcXserver works but makes VS Code very unresponsive for me.

That Gist you linked is a 404 @fdmnio 😢

@fdmnio

This comment has been minimized.

Show comment
Hide comment
@fdmnio

fdmnio Sep 14, 2018

That Gist you linked is a 404 @fdmnio 😢

Updated the link, sorry for that!

fdmnio commented Sep 14, 2018

That Gist you linked is a 404 @fdmnio 😢

Updated the link, sorry for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment