Skip to content
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 · 32 comments
Closed

Running VSCode for Linux in WSL #2760

mredbishop opened this issue Dec 18, 2017 · 32 comments
Labels

Comments

@mredbishop
Copy link

@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
Copy link

@jack-guy 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
Copy link

@khuongduybui 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
Copy link

@jack-guy 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
Copy link

@khuongduybui khuongduybui commented Dec 19, 2017

ok thanks for the clarification.

@mredbishop
Copy link
Author

@mredbishop 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
Copy link

@khuongduybui khuongduybui commented Dec 20, 2017

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

2017-12-20

@mredbishop
Copy link
Author

@mredbishop mredbishop commented Dec 20, 2017

@mredbishop
Copy link
Author

@mredbishop mredbishop commented Dec 20, 2017

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

@WSLUser
Copy link

@WSLUser WSLUser 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
Copy link

@NellyWhadsDev 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
Copy link

@AndrewPardoe 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
Copy link
Author

@mredbishop 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
Copy link
Collaborator

@therealkenc 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
Copy link
Member

@sunilmut sunilmut commented Jan 8, 2018

Marking this a discussion only thread again.

@mredbishop
Copy link
Author

@mredbishop mredbishop commented Jan 31, 2018

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

@kinmanlam
Copy link

@kinmanlam 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
Copy link
Author

@mredbishop 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
Copy link

@alexanderdevm 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
Copy link
Author

@mredbishop mredbishop commented Feb 18, 2018

@Xixi20160512
Copy link

@Xixi20160512 Xixi20160512 commented Feb 23, 2018

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

@jawjop
Copy link

@jawjop 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!

@therealkenc
Copy link
Collaborator

@therealkenc therealkenc commented May 25, 2018

Ran course.

@jgoux
Copy link

@jgoux 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
Copy link

@sworisbreathing sworisbreathing commented Aug 21, 2018

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

@fedme
Copy link

@fedme fedme 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
Copy link

@spences10 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 @fedme 😢

@fedme
Copy link

@fedme fedme commented Sep 14, 2018

That Gist you linked is a 404 @fdmnio 😢

Updated the link, sorry for that!

@ScheissSchiesser
Copy link

@ScheissSchiesser ScheissSchiesser commented Nov 3, 2018

I cannot get this to work. I have followed the instructions, but nonetheless, code-insiders does not show any activity in the XWindow and nails my CPU.

Here is the output. Seems to be multiple errors, but I am having trouble tracking down how to fix any of them. Help would be appreciated.

me@mypc:~$ code-insiders --verbose
shared memfd open() failed: Function not implemented
[main 12:48:20 PM] Starting VS Code
[main 12:48:20 PM] from: /usr/share/code-insiders/resources/app
[main 12:48:20 PM] args: { _: [],
  help: false,
  h: false,
  version: false,
  v: false,
  wait: false,
  w: false,
  diff: false,
  d: false,
  add: false,
  a: false,
  goto: false,
  g: false,
  'new-window': false,
  n: false,
  'unity-launch': false,
  'reuse-window': false,
  r: false,
  'open-url': false,
  performance: false,
  p: false,
  'prof-startup': false,
  verbose: true,
  logExtensionHostCommunication: false,
  'disable-extensions': false,
  disableExtensions: false,
  'list-extensions': false,
  'show-versions': false,
  nolazy: false,
  issue: false,
  'skip-getting-started': false,
  'skip-release-notes': false,
  'sticky-quickopen': false,
  'disable-restore-windows': false,
  'disable-telemetry': false,
  'disable-updates': false,
  'disable-crash-reporter': false,
  'skip-add-to-recently-opened': false,
  status: false,
  s: false,
  'file-write': false,
  'file-chmod': false,
  'driver-verbose': false,
  trace: false }
[main 12:48:20 PM] Resolving machine identifier...
[main 12:48:20 PM] Resolved machine identifier: [myidentifier]
[main 12:48:20 PM] update#setState idle
[main 12:48:20 PM] windowsManager#open
[main 12:48:21 PM] telemetry/optInStatus { optIn: true }
[3783:1103/134829.985597:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3812:1103/134844.482518:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3817:1103/134857.953995:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3822:1103/134911.182410:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3827:1103/134914.499644:ERROR:gl_implementation.cc(245)] Failed to load /usr/share/code-insiders/swiftshader/libGLESv2.so: /usr/share/code-insiders/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory
[3827:1103/134914.501255:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3831:1103/134917.610325:ERROR:gl_implementation.cc(245)] Failed to load /usr/share/code-insiders/swiftshader/libGLESv2.so: /usr/share/code-insiders/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory
[3831:1103/134917.612414:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3835:1103/134920.852607:ERROR:gl_implementation.cc(245)] Failed to load /usr/share/code-insiders/swiftshader/libGLESv2.so: /usr/share/code-insiders/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory
[3835:1103/134920.854210:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3839:1103/134923.549052:ERROR:gl_implementation.cc(245)] Failed to load /usr/share/code-insiders/swiftshader/libGLESv2.so: /usr/share/code-insiders/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory
[3839:1103/134923.550639:INFO:child_thread_impl.cc(839)] ChildThreadImpl::EnsureConnected()
[3751:1103/134923.642853:ERROR:browser_gpu_channel_host_factory.cc(103)] Failed to launch GPU process.
@ScheissSchiesser
Copy link

@ScheissSchiesser ScheissSchiesser commented Nov 3, 2018

What does winver tell you?

Windows 10 Pro
Version 1803 (OS Build 17134.345)

@therealkenc
Copy link
Collaborator

@therealkenc therealkenc commented Nov 3, 2018

[3827:1103/134914.499644:ERROR:gl_implementation.cc(245)] Failed to load /usr/share/code-insiders/swiftshader/libGLESv2.so: /usr/share/code-insiders/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory

sudo apt install mesa-utils

Also don't export LIBGL_ALWAYS_INDIRECT, and it is DISPLAY=localhost:0 not 0:0.

The memfd open() thing is a red herring, unrelated to vscode proper, and basically dupe #1209.

Version 1803 (OS Build 17134.345)

You're better off on 17763 aka 1809 for unrelated reasons but it should fly alright on 17134. If you subsequently get the audio_manager.cc fail that's #1006 aka #486.

@ScheissSchiesser
Copy link

@ScheissSchiesser ScheissSchiesser commented Nov 4, 2018

@therealkenc after a restart, it is now working. Though, I still see the following error, even though code-insiders is displayed.

[199:1104/131300.762260:ERROR:gl_implementation.cc(245)] Failed to load /usr/share/code-insiders/swiftshader/libGLESv2.so: /usr/share/code-insiders/swiftshader/libGLESv2.so: cannot open shared object file: No such file or directory
[199:1104/131300.766015:ERROR:gpu_child_thread.cc(252)] Exiting GPU process due to errors during initialization

Another red herring perhaps?

@therealkenc
Copy link
Collaborator

@therealkenc therealkenc commented Nov 4, 2018

Another red herring perhaps?

Hard to say. Something thinks that missing .../swiftshader/libGLESv2.so is part of the VSCode package (strictly speaking, a distant dependency thereof) but it isn't there. I don't have that path on my 1.29.0-insider either, but I also don't get the ERROR:gl_implementation.cc line out of code-insiders --verbose. So we'll call that difference between my run and your run "odd" and/or "unexplained". I can't (won't?) speculate on the cause. It would take a deep dive to see how your run makes it to gl_implementation.cc(245), and, I can't do that myself because I don't get there. It's a dive that probably isn't worth the trouble unless/until it becomes some kind of hard fail. I am sure there is a "good explanation", but it won't be one that has anything to do with WSL (with usual caveat that anything is possible). Make sure you have 'native opengl` unchecked in VcXsrv, but I don't think that will matter. Happy to hear you got it running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.