Here is our tutorial on how to install Ruby on Rails on Windows 10 using the Windows Subsystem for Linux. This tutorial uses code from a post by Go Rails, which can be found here, with some minor tweaks.

For this installation, we will be installing PostgreSQL as our database, which is great if you run your app on Heroku.

Setting Up Ruby

Installing the Ruby Dependencies:

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Install Ruby using rbenv:

git clone ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.4.1
rbenv global 2.4.1
ruby -v

Installing Bundler:

gem install bundler

To install Git, follow the Go Rails guide here.

Setting up and installing Rails

First install NodeJS:

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Now install Rails:

gem install rails -v 5.0.1
rbenv rehash
rails -v
# Rails 5.0.1

Next we need to install the dependencies for the pg gem, but not PostgreSQL itself:

sudo apt-get install libpq-dev

Once this is complete, download and install PostgreSQL on Windows - not on the Windows Subsystem for Linux. Click Here to download and install the latest version of PostgreSQL.

Follow the instructions and create a new password. Also remember your default username is postgres.

Awesome - Now let's set up your new Rails app:

Note: In order for PostgreSQL to work, you will need to create your new app outside of the Bash environment.

Here's an example:

cd /mnt/c/Users/your-computer-user-name/Desktop
mkdir Rails
cd Rails

rails new appname -d postgresql

Now open and modify your database.yml file using your favourite text editor. Add your username and password as well as host.

username: postgres #Or a new user you set up inside pgadmin
password: your-password
host: localhost

Last step:

cd appname
rake db:create

rails s

Congrats! Your new app should be up and running on localhost:3000.


To navigate to the folder where Ubuntu is installed, follow this path:

C:\Users\Your-Computer-Username\AppData\Local\lxss\home #App folder for SQLite

To purge or remove the Windows Subsystem for Linux, including your Rails install, open command prompt, not Bash and type:

 lxrun /uninstall # This will leave your home folder intact
 lxrun /uninstall /full # This will delete everything

To learn more about deleting your Bash environment, Click Here.