If you managed to get here then I’m assuming you also have problems using Jetbrains tools with Windows Subsystem for Linux 2 (WSL2). Here’s a list of the problems I myself encountered when using WebStorm with WSL2 (the problems are the same in any of their tools - WebStorm, PyCharm and IntelliJ):

Example problems

  1. Poor Git performance under /mnt/... This problem has been described well by a lot of blog posts and bug reports, and everyone suggests to keep your project files on native Linux filesystem, for example /home/<user>/projects like I do. This however causes a number of problems listed below

  2. Opening a file from \\wsl$\... raises a warning “External file changes sync may be slow” From what I gathered it’s because WebStorm can’t start the fsnotifier64 on a network drive, which it thinks our Linux is on.

  3. “Filesystem Case-Sensitivity Mismatch” This can be easily fixed by going to “Help” -> “Edit Custom Properties”, and setting idea.case.sensitive.fs=true as described here: https://confluence.jetbrains.com/display/IDEADEV/Filesystem+Case-Sensitivity+Mismatch One thing to watch out with this setting is that you’re going to get that same warning when you open a project from your windows partition, so setting it to true might not be the optimal option.

  4. Incorrect line endings By default WebStorm/IntelliJ/PyCharm assume that the files you write should be using the line endings from the OS you’re in. This however can cause problems when editing files on WSL. On Windows the git client does the conversion between CRLF and LF for you when pulling and committing changes, so this is not an issue. This will not be the case on WSL, and could get you into some problems down the line. Line endings can be changed in Jetbrains tools to whatever you prefer, but that might not be ideal when dealing with projects on WSL and Windows from the same setup

  5. .idea folder gets corrupted by Windows version of Jetbrains tools This particular problem can be observed by opening freshly pulled project from repository, opening it in Jetbrains editor, closing the project and re-opening it. What happened for me is that my project files disappeared.

The solution

Well, if using a Windows version of WebStorm with WSL2 is such a pain, why don’t I just run WebStorm inside WSL2.

An image showing mind being blown

To do this we’ll need to add support for X11 to our WSL with the help of X11 Port Forwarding.

There are a few different options to achieve this:

I tried a few of them to see which one works for me before settling on Cygwin/X, which turned out to be the most stable to me, even though the setup procedure is a bit more involved.

Installing Cygwin/X on Windows

As there’s already a great documentation page dedicated to installing Cygwin/X on Windows, I’m not going to repeat these instructions here. Please head over to https://x.cygwin.com/docs/ug/setup.html#setup-cygwin-x-installing for detailed instruction on how to get it installed. Make sure to select all required packages from the section 15.

Once that is done we’re going to add the Cygwin/X launcher to our startup applications - this will start the X11 server any time we start our system.

Firstly, right click on an empty space on your desktop, select “New” then “Shortcut”.

Right click on the desktop, in the menu New select the Shortcut option.

Then in the “Create shortcut” popup in the location box enter:

C:\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin -- -ac -multiwindow -wgl -clipboard -noprimary -listen tcp"

A Create Shortcut popup with populated location field.

Then click “Next” and “Finish” buttons.

Finally move the newly created shortcut over to the Start-up position of your Start Menu. You can get there by opening this location in Windows Explorer:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

Once the shortcut is in the “StartUp” position of your Start Menu, double-click on that shortcut to start the Cygwin/X with the correct options.

Installing XFCE4 in WSL

The next step is to install a Desktop Environment, as WSL doesn’t come with any desktop environment. The environment I chose is XFCE4 as its use with WSL is well documented (e.g. https://autoize.com/xfce4-desktop-environment-and-x-server-for-ubuntu-on-wsl-2/)

In the WSL terminal run

sudo apt-get update && sudo apt-get upgrade -y

sudo apt-get install xfce4

The next step is to configure your X11 Display forwarding to the Windows Host X11. I’m using zsh shell, so the file I’m editing is ~/.zshrc, but in your case it could be the default ~/.bashrc or ~/.bash_profile depending on the shell you use.

# Get the IP address of the host from /etc/resolv.conf
export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
# Set the display path
export DISPLAY=$WSL_HOST:0.0

Once you save these changes make sure to re-load them in your shell by doing source ~/.zshrc (if you’re using ZSH like me), or by re-opening your WSL terminal.

First start of XFCE4 in WSL

The next logical step is to see if everything works fine. In the WSL terminal run:

startxfce4

After a few seconds you should be greeted in XFCE4 desktop. You can use it to change your system settings like key repeat speed, which is different to your Windows.

Starting WebStorm/IntelliJ/PyCharm

The last step is to head over to Jetbrains website, and download a linux version of WebStorm/IntelliJ/PyCharm, extract it and finally running /home/tmikus/WebStorm-193.6015.40/bin/webstorm.sh. If everything worked correctly it should open a new window of your editor.

Good luck, and happy coding!