Install Ruby on Rails on Windows

Here we discuss Install Ruby on Rails on Windows. For installing Ruby on rails on windows, we will use Bash on Ubuntu in Windows 10 for the reason that it will run Linux on your windows system.

How to install Ruby on Rails in windows 10 ?

You will use both of the worlds i.e. Linux for Ruby on rails purpose and Windows for your day to day work.

NOTE : This will only work for 64-bit installations on your windows system.

Installing Windows Subsystem for Linux on your machine :

For installing Windows subsystem in your machine, we have to know that Windows 10 allows you to use various Linux commands on your machine like a virtual one but it should be implemented natively.

First open Powershell on Windows and run the following command :

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Next install Ubuntu from the Microsoft store : From link provided below

Install Ruby on Rails on Windows

Now open Ubuntu in the Start menu or by running ‘wsl’ in the PowerShell or in the command prompt. You’ll be asked to setup a new user for Ubuntu but remember this password as it’s what you’ll use later on when installing packages with sudo.

You’ve now Ubuntu installed on your machine and we will use it for Rails server and for further process.

Installing Ruby :

Install Ruby on Rails on Windows

We will install Ruby version 3.0.2 which is recommended and best in today’s time. The first step will be to install some 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 software-properties-common libffi-dev

Next we are going to install Ruby using one of three methods and each have their own benefits and advantages, most people prefer using rbenv, but if you are comfortable with rvm you can follow those steps as well. I have included instructions for installing from source as well but generally, you’ll want to choose either rbenv or rvm as per your choice.

We will install using ‘rbenv’ because it’s a simple two step process. First install ‘rbenv’ and then ‘ruby-build’.

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 3.0.2
rbenv global 3.0.2
ruby -v

The installation of ‘rvm’ is simple and can be done by:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E37D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 3.0.2
rvm use 3.0.2 --default
ruby -v

The last step is install Bundler.

gem install bundler

rbenv users need to run rbenv rehash after installing bundler.

Configuring the Git :


We will use Git for version control system so, we will set it and match our Github account. For this you have to make an Github account for you that will be useful for you in future as well.
We can do that by:

Cmd1: git config –global color.ui true
Cmd2: git config –global “YOUR NAME”
Cmd3: git config –global “”
ssh-keygen -t rsa -b 4096 -C “”
You can replace the name and email with yours.
Next, Take the newly generated SSH key and add it to your Github account.

cat ~/.ssh/

Once it is completed you can check by :
ssh -T
If you done all the steps right then , you will see a message like this on your screen:
Hi “Name”! You’ve successfully authenticated, but GitHub does not provide shell access.

Installing Rails:

For installing Rails we will consider some dependencies on which it worked. So, we will install Javascript runtime like NodeJS and a package called Yarn.
We will install Rails for version which is recommended.
To install NodeJS and Yarn, we’re going to use the official repository.
We use following commands:

curl -sL | sudo -E bash -
curl -sS | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt-get install -y nodejs yarn

And in the end:

gem install rails -v

If you’re using rbnev, you have to check run the following command:

rbenv rehash

Now you’ve install Rails, run ‘ rails-v’ command to chack you have everything installed correctly.

rails -v


Setting Up MySQL :

Install Ruby on Rails on Windows

You can install MySQL server and client in the Ubuntu repository. You’ll set the password for the root user. This information will feed into Rails app’s ‘database.yml’ file in the future.

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Setting Up PostgreSQL :

The easiest and effective way to set PostgreSQL in you machine is to install it by windows packager. You will be able to run it on Linux as well.
You will have to install the development header on Ubuntu so you can install the ‘pg gem’.
sudo apt install libpq-dev

Some Final Steps:

And also The best place to develop Rails the Windows is to navigate to /mnt/c that is subsystem for Linux. This is actually the C: drive on Windows and it will let you use Atom, Sublime, VS Code on Windows to edit your Rails applications.

Now, you have to run the following commands :

cd /mnt/c

Create a code directory at C:\code for your Rails apps to live

mkdir -p code
Note this will expect a postgres user with the same username
as your app, you may need to edit config/database.yml to match the
rails new myapp -d postgresql
or if you want to use SQLite
rails new myapp
Or if you want to use MySQL
rails new myapp -d mysql
Then move it into application directory
cd myapp
If you setup MySQL or Postgres with a username/password, modify the

config/database.yml file to contain the username/password that you specified

Create the database

rake db:create rails server

Firstly, To edit your code in windows : open up Sublime, Atom, VS Code, or whatever editor your prefer and point them to your folders in C:\code and you’ll be able to safely edit your Rails apps in Windows and run them in Linux.

When you create a new Rails app, you may run into the following error: parent directory is world writable but not sticky.

If you run into this issue, you can run chmod +t -R ~/.bundle and that should fix the permissions errors and let you finish the bundle install for your Rails app.

Related Articles: Install Ruby on Rails on Windows

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top