Rails on WSL

Last year I bought a laptop that I probably didn’t need. It is an Asus ROG gaming laptop. Turns out I am not that interested in gaming that I thought I was. I now had a Windows laptop after a decade and wanted to try WSL. Since I have a side app that runs on Rails, it felt like a good candidate.
I checked out the code on Windows and fired up RubyMine. I then fired up WSL Ubuntu instance. I then mounted the windows directory on Ubuntu and installed Postgres on Ubuntu. I ran bin/dev. Now my app was running on port 3000 and accessible on the browser on the Windows. It turns out all ports are auto forwarded to the host machine! Ruby mine’s WSL support for remote SDKs and debugging worked really well too. I could debug the app on RubyMine.

However the app felt a slower than when it ran on my mac. Even the rails test command was taking half a minute to start running the tests. After a bit of digging around, found the answer. Instead of checking out code on Windows, I had to do it on the WSL Ubuntu instance. I then opened the project on RubyMine using a path like \wsl.localhost\Ubuntu\<project_path>. This meant the files were on the Linux filesystem and the mounted filesystem was where the bottleneck was.

The final hurdle was running system tests a.k.a. browser based tests. For you need to just install Chromium Chromedriver using
sudo apt-get install chromium-chromedriver
The tests actually open the chromium browser on the Windows host and you can see your tests running!

After all this, I am as productive on Windows as am I on a Mac vis a vis Rails development. My “gaming laptop” probably will see more usage 🙂
However, I still think the Mac is unbeatable as a personal/development laptop. My Windows laptop heats up and has much poorer battery life. I also don’t like the font rendering on Windows.

Leave a comment