How to run Ruby on Rails with Windows 10 and WSL 1
Tags: ruby, rails, wsl, windows
Published: 2019-10-30 02:44:39

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

{% twitter 1188937316615610368 %}

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 👇

{% twitter 1189304457894473732 %} 

🤔, he is human after all!.

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

{% twitter 1189012830873255936 %} 
{% twitter 1188971490466680832 %} 

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

{% twitter 1189262958800584704 %} 
{% twitter 1189297560315486209 %} 

Scott Hanselman shared a [pretty good blog post](https://www.hanselman.com/blog/RubyOnRailsOnWindowsIsNotJustPossibleItsFabulousUsingWSL2AndVSCode.aspx) 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
```
![Win 10 | Version 1903 (Build 18362.449)](https://thepracticaldev.s3.amazonaws.com/i/bodn3hydr529c9u88pxj.jpg)

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](https://thepracticaldev.s3.amazonaws.com/i/09n08exshla1f52c9s9a.jpg)

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

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ie03tbni2p4t1ijm1ju9.jpg)

* ⚠ 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
```

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](https://thepracticaldev.s3.amazonaws.com/i/sg918mn1buvg1svmi8om.jpg)

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

![Create a Sample App](https://thepracticaldev.s3.amazonaws.com/i/zo10c45emf14lrtb0oee.jpg)

![Run the server](https://thepracticaldev.s3.amazonaws.com/i/6y6zk5k4r6e2ro0kgklm.jpg)

🎈🎊👏

### 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](https://docs.microsoft.com/en-us/windows/wsl/wsl2-ux-changes) 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](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack), this will enable you to open up the WSL filesystem and access the app you just created 👇

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/kvopfgzmv7e4yqxnyb3l.jpg)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4im38jch72dgbeb24n11.jpg)