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 👇
DHH@dhhI'm many, many hours into the Windows journey so far, but still haven't been able to get my Rails apps running. At this point I'm starting to get receptive to the idea of just throwing Linux on it directly instead. Anyone running a minimum fuzz distro on Surface Laptop 3?22:14 PM - 29 Oct 2019
🤔, he is human after all!.
Interestingly enough I saw a lot of people from Microsoft jump in the thread and try to help 👇
Chad Fowler@chadfowler@dhh If you want to give any direct feedback lemme know. I know the teams behind a lot of this stuff.00:11 AM - 29 Oct 2019
👏 Props to Rich Turner for providing some very useful tips 👏
Rich Tur-minal-ner-d@dhh @chadfowler That's highly unusual. WSL2 is generally pretty quick. Can I ask you to run `wsl -l -v` in PowerShell and share the output? Also, be sure to click the battery icon and make sure you're on "Best Performance" when plugged-in?19:29 PM - 29 Oct 2019
Rich Tur-minal-ner-d@dhh @rathboma @chadfowler @craigaloewen In WSL1, all files were stored in Windows. In WSL2, each distro gets their own VHDX, and perf should be close to native. However, in WSL2 right now, cloning into e.g. /mnt/c/dev/project/ will be slower than cloning into ~/dev/project21:46 PM - 29 Oct 2019
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 👇
- Win 10 | Version 1903 (Build 18362.449)
- WSL 1
- Visual Studio Code + Remote Developer Extensions
Go to the search bar and type
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 🧠.
Head over to the Microsoft Store and install your favorite version of Linux, In my case I'll use Ubuntu.
Once installed, just run the terminal and it will ask you to setup a username and pass 👇
- ⚠ 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 👇
After a few minutes you should have Ruby installed 👏. Now we'll install Rails to get an app 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 👇