Windows 10 added a new feature called windows subsystem for Linux. Suprisingly, it keeps evolving, now in version 2 and supposedly will be even better in windows 11 with easier install and more features. Also my IDE of choice IDEA is supporting it. And as I had a bit of time on my hands in new job as I was waiting on a new Mac to arrive to replace my windows machine, I figured I will give it a try.
As the new code base, run environment and built tools of my new project was not compatible with windows, I had the following idea:
Have the code, java, git and runtime in WSL2 and leave the IDEA in windows. The installation was fine, using the apputility to install everything in a jiffy.
- Go to windows store :). Search for Ubuntu. Install latest version.
- Start ubuntu from start menu.
- Install git, java, install docker in Ubuntu (manually or by using Docker Desktop which sets it up)
sudo apt install git
sudo apt install openjdk-11-jdk
sudo docker pull postgres:11sudo docker run --name postgres11 -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:11
Checked out the code on WSL2 subsystem using the WSL2 git.
Then I went to IDEA and configured it to use git from the WSL. This works surprisingly well and gives you the option to skip git installation on windows which is a weird linux/win hybrid.
Then I opened the project on WSL2 subsystem. Yes it is possible and should work fine … but it does not. My project was maven multi-module and all maven projects were marked with error message:
Connection refused to host: 127.0.0.1 in WSL maven connector
Apparently this is a known bug in IDEA: https://youtrack.jetbrains.com/issue/IDEA-266222 and as of writing this it should be fixed, but not released. But in my case this was a blocker and it rendered the project unusable.
Plan B was to install IDEA in WSL2 and use its UI through XServer
Install XServer: https://techcommunity.microsoft.com/t5/windows-dev-appconsult/running-wsl-gui-apps-on-windows-10/ba-p/1493242
Then follow: https://nirisarri.github.io/2020-11-03-how-to-install-and-run-intellij-idea-for-linux-in-wsl2/
I had to install idea from a zip/tar file as apparently snap utility is not supported on wsl. See https://github.com/microsoft/WSL/issues/5126.
The ide ran fine, IDEA ran in WSL, UI was being stream to xserver in windows. But the UI experience was rather poor. Icons had a strange outline, popup windows did not render correctly, some of the popups were not rendered at just displaying some bufferend UI fragment. Otherwise it was usable, project imported correctly), UI speed through xserver was OK. I managed to fix the icons by setting some obscure idea parameter, but not the bad popups.
And then I finally received my Mac and could give up on this. So the outcome is that the WSL IDEA support is not there yet.
WSL on its own is awesome and provides much needed full linux support on windows.