Thanks a lot to mredbishop and others for their insturctions posted here. This is just a recap of what they figured out.
This process was tested on WSL Ubuntu 18.04.
- Dowload the VcXsrv installer from https://sourceforge.net/projects/vcxsrv/
- Install the software on Windows
On your linux terminal, execute the following commands to install some required dependences:
sudo apt-get install libgtk2.0-0
sudo apt-get install libxss1
sudo apt-get install libasound2
Then run the following commands to add the VS Code repos for apt:
cd ~
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'
Run the following to install VS Code on Linux:
sudo apt update
sudo apt install code
sudo apt install code-insiders
Add the following at the end of your .bashrc
(or .zshrc
if using ZSH):
# X Server
export LIBGL_ALWAYS_INDIRECT=1
export DISPLAY=0:0
sudo /etc/init.d/dbus start &> /dev/null
Note: to edit your bashrc file you can run nano ~/.bashrc
(or nano ~/.zshrc
if using ZSH).
Now reload the file by executing source ~/.bashrc
(or source ~/.zshrc
if using ZSH).
We now need to add a sudoers file to grant our user password-less root access to the dbus service.
- Run the following command:
sudo visudo -f /etc/sudoers.d/dbus
- Then paste the following text inside the Nano editor that will launch (Replace
your_username
with your linux username):
your_username ALL = (root) NOPASSWD: /etc/init.d/dbus
- Press
CTRL+O
to save the file, then pressEnter
to confirm. Finally, pressCTRL+X
to close the Nano editor. - Now close you Linux terminal and open a new one.
- On Windows launch the recently installed XLaunch app.
- In the dialog, always choose Next and then Finish. NOTE: uncheck the Primary selection checkbox in the 3rd step otherwise everything you select in VS Code will also be copied in the clipboard.
- Finally, on your linux terminal, navigate to your desired folder and run
code .
(orcode-insiders .
) - VS Code for Linux should launch
If you use a 4K monitor, chances are your VS Code appears blurry. There is a workaround for this but, at least on my machine, it makes VS Code laggy and a bit unresponsive. Anyways, here it is:
On windows:
- Open the
C:\Program Files\VcXsrv
folder. - Right click on the
vcxserver.exe
file and chooseProperties
. - From the
Compatibility
tab, click theChange hi DPI settings
button. - Turn on the
Override high DPI scaling behaviour
checkbox and chooseApplication
in the dropdown menu just below. - Press
OK
and save. - Close VcXserver and re-launch it.
On Linux, add the following at the end of your .bashrc
(or .zshrc
if using ZSH):
export GDK_SCALE=2
Note: to edit your bashrc file you can run nano ~/.bashrc
(or nano ~/.zshrc
if using ZSH).
Then reload the file by executing source ~/.bashrc
(or source ~/.zshrc
if using ZSH).
Maybe it is a little late, but I also had the same issue as @panteluke and @seffyroff with extension installation.
It worked though via manual vsix download and install. (just my 2 cents).
However code crashes randomly and sometimes has a very bad windows redrawing.
(tested under Mobaxterm, under vcxsrv it did not work at all).
Also sublime text worked like a charm and very quick...