- 1 year ago
How do I run VSCode in WSL in X server environment?
Comment
1 / 1
To run Visual Studio Code (VS Code) in the Windows Subsystem for Linux (WSL) with an X server environment, you'll need to set up an X server on your Windows system and configure the necessary settings in both Windows and WSL. Here's a step-by-step guide:
Install an X Server on Windows:
- Download and install an X server application on your Windows system. Some popular options are Xming (https://sourceforge.net/projects/xming/) and VcXsrv (https://sourceforge.net/projects/vcxsrv/).
- Run the X server application and make sure it is running and ready to accept incoming connections.
Configure WSL:
- Open your WSL distribution (e.g., Ubuntu) and install the required packages for running GUI applications. In the terminal, run the following commands:sql
sudo apt update
sudo apt install -y dbus-x11 x11-apps
- Open your WSL distribution (e.g., Ubuntu) and install the required packages for running GUI applications. In the terminal, run the following commands:
Set Display Environment Variable:
- In your WSL terminal, run the following command to set the
DISPLAY
environment variable to point to the IP address of your Windows system and the display number of the X server. Replace<Windows-IP>
with the IP address of your Windows system:arduinoexport DISPLAY=<Windows-IP>:0.0
- In your WSL terminal, run the following command to set the
Test X Server Connection:
- In your WSL terminal, run the following command to test the X server connection:
xeyes
- If everything is set up correctly, you should see a new window with a pair of eyes displayed by the X server running on your Windows system.
- In your WSL terminal, run the following command to test the X server connection:
Install and Run VS Code in WSL:
- In your WSL terminal, follow the instructions to install VS Code using the package manager or download the
.deb
package from the official website and install it manually. - Once installed, you can launch VS Code by running
code
in the terminal. - VS Code will run in the X server environment provided by the X server running on your Windows system.
- In your WSL terminal, follow the instructions to install VS Code using the package manager or download the
By following these steps, you should be able to run Visual Studio Code in your WSL environment with an X server running on Windows. This allows you to leverage the GUI capabilities of VS Code and use it with your WSL setup.