Getting Rails up and Running on Windows Subsystem for Linux
--
As part of #hacktoberfest 2019 I’ve noticed a lot of interesting teams/companies/projects are still using Rails. In the spirit of learning I decided I’d setup a rails environment give it a whirl on a test app to see how it compares to my server-side tool of choice, ASP.NET core.
Since I’m part of the ever shrinking world of developers that don’t work on a MacBook I decided first to try the native window install. I immediately ran into a bunch of conflicts and an out of date installer for windows. Not looking to spend two hours just getting a dev environment running I decided to change tactics.
I thought perhaps it would be best to try to do what the rest of the rails world is doing I opted to switch over to the WSL and try this experiment from a more *nix perspective. Unfortunately, WSL still isn’t quite a normal distro setup and I ran into a few more issues attempting the Ubuntu standard setup.
After a bit of research and struggle I finally landed on a working combination of packages that got things up and going. In the interest of saving the next poor developer some of that effort I’m documenting those steps here:
- Add the Yarn Repo for apt-get to find the latest Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
2. Install all Rails development dependencies
sudo apt-get install make gcc zlib1g-dev ruby ruby-dev sqlite3 libsqlite3-dev yarn
3. Install Rails
sudo gem install rails
4. Once the rails install is finished you can run your rails new
command:
rails new myprojectname
5. Now we can startup the new rails project
cd ./myprojectnamerails server
Open a browser and navigate to http://localhost:3000
A few steps, but nothing too crazy. I hope this helps someone else out, and saves some time so you can just get coding!