DEV Community

Cover image for How to run Ruby on Rails with Windows 10 and WSL 1
Hector Minaya
Hector Minaya

Posted on

How to run Ruby on Rails with Windows 10 and WSL 1

Today I saw a twitter thread from DHH, which reminded me that even great developers struggle once in a while 👇

No, it's not that he bought a new Surface Laptop 3. It's that he was having trouble running Ruby on Rails on Windows 10 👇

🤔, he is human after all!.

Interestingly enough I saw a lot of people from Microsoft jump in the thread and try to help 👇


👏 Props to Rich Turner for providing some very useful tips 👏


Scott Hanselman shared a pretty good blog post about running RoR on Windows using WSL2. Which is fabulous!, but I would need to reformat my laptop, get on the windows insider (beta) fast ring, then enable WSL2.

Which as tempting as it may sound, I'm sure a lot of people don't want to commit their main laptop to a windows beta build.

Can you get this working right now, on your current Win10 install? Absolutely. I'll guide you through the process 👇

What are we going to use?

  • Win 10 | Version 1903 (Build 18362.449)
  • WSL 1
  • Visual Studio Code + Remote Developer Extensions

Step #1 - 👀 Make sure Win 10 is updated

Go to the search bar and type

winver
Enter fullscreen mode Exit fullscreen mode

Win 10 | Version 1903 (Build 18362.449)

If you are running a version older than Version 1903 (Build 18362.449), go ahead and take the time to update windows, it will save you a lot of headaches 🧠.

Step #2 - 🔨 Install WSL1 + Ruby

Head over to the Microsoft Store and install your favorite version of Linux, In my case I'll use Ubuntu.

Ubuntu @ The Microsoft Store

Once installed, just run the terminal and it will ask you to setup a username and pass 👇

Alt Text

  • ⚠ Disclaimer #1: For the sake of brevity I'll take some shortcuts installing Ruby on Ubuntu, I do recommend installing RVM or rbenv and following proper protocol.*

First I'll install some prerequisites so I don't run into issues later on, just run the following commands 👇

sudo apt-get install software-properties-common
sudo apt-get install -y nodejs
sudo apt-get install gcc g++ make
sudo apt-get install libxml2-dev
sudo apt-get install libsqlite3-dev
sudo apt-get install yarn
Enter fullscreen mode Exit fullscreen mode

Next, I'll just go ahead and install Ruby, you can use RVM or rbenv, but I'll keep it simple for this post 👇

Install Ruby

After a few minutes you should have Ruby installed 👏. Now we'll install Rails to get an app running 👇

Create a Sample App

Run the server

🎈🎊👏

Step #3 - 💻 Let's get VSCode running 🔥

Basically we are going to use VsCode to access the file system in WSL and make changes to our app.

  • ⚠ Disclaimer #2: WSL1 and WSL2 are very different beasts. Follow the official Microsoft recommendations on where exactly to place your files. For now, I'm just trying to make the point of working in Windows while accessing the Ubuntu file system in WSL.*

So now, head over to VSCode and install the fabulous Remote Development Pack, this will enable you to open up the WSL filesystem and access the app you just created 👇

Alt Text

Alt Text

Top comments (4)

Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

Thank you for sharing DHH's tweet. It's really good to see that our "dev heroes" are struggling with the same things as we do. And concerning Microsoft - looks like the days of "cancerous Linux" are long gone now. I really like the new Microsoft.

Collapse
 
hminaya profile image
Hector Minaya

Yeap, they too get stuck, google, hang out on stackoverflow.

Collapse
 
jsalvador profile image
Juanjo Salvador

WSL is one of the most useful features for developers (and non-developers!) included on Windows 10.

I've been using the new Windows Terminal for this purpose too, but actually to run a Hanami server :P It also supports Jekyll pretty nice and other server-side tools and frameworks that you usually see on Linux or Mac. So, welcome back to the developers environment, Windows.

Collapse
 
dylanesque profile image
Michael Caveney

Did you have issues setting up the database? SQLite isn't an issue, but I've tried to get both MySQL and Postgres working to no avail.