💊 How To Install #RubyonRails on Windows 7 / 8 / 10 — Complete Tutorial 2017 (September 2017)
Step-By-Step Tutorial on How To Install Ruby, Rails, RubyGems, Git, RMagick and MYSQL2 on Windows.
We revised this article in September 2017 to reflect new update of
RubyInstaller2 (no longer supports DevKit).
To develop Rails on Windows, you require the following components:
These are all freely available, and are required for any OS Ruby install ↴
On Windows, you need a precompiled version of Ruby.
On Linux, you can compile from source. Not Windows.
Well, actually you can. But it requires MASSIVE amounts of patience in order to get the correct dependencies / libraries installed.
The best thing to do is download a pre-built version of Ruby.
RailsInstaller does NOT keep its libraries up to date.
The best thing to do is to download the ZIP version of RubyInstaller. Whilst there is an installer, it’s better to just download the binaries in the ZIP.
If you do want to do this, there are two options:
Due to different build requirements,
Ruby 2.4.x now uses RubyInstaller2:
I would personally recommend downloading
Ruby 2.4.x (the latest), but if you have an application designed for
Ruby 2.3.x you’re also able to use that:
1) Identify Windows Version:
The first step is to know your Windows version (
- Press “Windows” + “R” buttons on the keyboard
- Type “dxdiag” and press “OK”
- Identify the “System Type” from the list:
2) Download ZIP From RubyInstaller (you may need to install 7Zip):
3) Save The Zip To Your Hard Drive
4) Unzip To PERMANENT Folder:
5) Add to
The Windows PATH allows your system to load applications be referencing their name. To call
ruby from CMD, you’ll need to add it to the
- Click on “Start”
- Right-click on “Computer” — select “Properties”
- From the “System” dialogue, select “Advanced system settings”:
- Select “Advanced” tab — “Environment Variables”:
- From here, select the “PATH” variable from the “SYSTEM Variables” panel, and select “Edit”:
When the “path” variable setting loads, paste the path to the
/bin directory of Ruby into it (keeping the other paths intact). After this, click “OK” to exit.
- Right-click on “Start” / “Windows” button (bottom left)
- Select “System”:
- From the right menu, select “System Info”
- From the new menu that appears, select “Advanced system settings”:
- Select “Advanced” tab
- Select “Environment Variables”:
- The following should appear:
- Next, click “New” to add the
bindirectory for the new ruby directory you created (also add the devkit
bindirectory if you’ve installed that):
- Click OK and exit any
CMDinstances you have open.
🔨 Build Tools 🔨
Next, you need to install “build tools”.
These are used to compile gems that rely on external libraries
(nokogiri / rmagick / mysql2):
All operating systems require build tools as extra downloads. They are applications, files and libraries which help your system compile gems.
In Ubuntu, you’d install the
In Windows, you need to download the tools separately.
Ruby 2.3.x (Devkit) (Good tutorial)
For older versions of RubyInstaller, you need to install “DevKit” ↴
After downloading ONE of the above files, load the self extracting archive and “unzip” to a temporary directory:
Once complete, you need to initialize DevKit and bind it to your Ruby installation:
- Load up
cdinto the RubyGems directory
- Type the following:
ruby init.rb& press
- Next, load up the
- Add the directory for your
# - C:/ruby19trunk
# - C:/ruby192dev
- "C:/Program Files/Ruby200-x64"
- Next, in
cmdyou should type
ruby setup.rb& press
- This should bind DevKit to your Ruby installation, allowing it to call all the libraries.
Ruby 2.4.x (MSYS2)
Ruby 2.4.x (RubyInstaller2) uses “MSYS2” ↴
Setting up MSYS2 is slightly more involved than DevKit, but more effective.
The point is that both install a series of files or applications which allow
you to perform build / compilation operations:
- Download the appropriate version of MSYS2
- Save the installer to your hard drive
- Double-click the installer to get it to load:
- After the installer completes, you need to set up
- Load a new
MSYS2console and type the following:
pacman -Sy pacman
You should see something similar to the following:
Using the above commands,
pacman will be installed and ready to use.
Now, you need to install the various build dependencies. This used to be
done from within MSYS2 itself, but now it’s part of the RubyInstaller2 installation process:
- Open up CMD
- The following screen should appear:
Press 3 and Enter.
From here, it should work to install the various components of the MSYS2 development toolchain. If this process fails (we had a Windows 8 user where the process hung randomly), you’ll want to switch back to MSYS2 and run one of the following commands (installs the build tools manually):
pacman -S base-devel mingw-w64-i686-toolchain #32-bit
pacman -S base-devel mingw-w64-x86_64-toolchain #64-bit
If this does not work (in Windows 8), you should continually resize the MSYS2 window. This is what it took to get it working on a reader’s system.
Installing C-dependent Gems (Nokogiri / SQLite3 etc)
The RubyInstaller2 repo has a good tutorial on how to do this:
📋 RubyGems 📋
Next, you need to install RubyGems.
RubyGems is the repository which stores all the “gems” you can install on Ruby. These gems are the “plugins” for the language, providing functionality.
As this is a separate package to Ruby, it has to be installed manually:
To install RubyGems, you need to download the ZIP and
unzip to a temporary folder:
From there, you will need to open
cd into the TEMPORARY folder. You should then type
ruby setup.rb and RubyGems willinstall:
If successful, you’ll be able to type
gem -v in a new instance of
🚀 Rails 🚀
With RubyGems installed, you need to install the
This should be a very simple procedure (in
gem install rails)
- You also need
bundlerbecause without it, you cannot use a
- You need
railsbecause that’s the framework you’re using.
Installing Rails as a system-wide gem will give you the ability to call it whenever needed, not just as part of a Rails application:
🚦 GIT 🚦
You then need to install GIT.
Git is a source code management system (SCM), basically allowing you to sync your development source with production and staging environments.
It has taken over the role of FTP, allowing you to “push” code to “repositories”. If this sounds alien, you need to read up on it. It’s an essential part of modern web development — especially Rails. Github is a very good place to start:
The installation process should be performed as follows:
Once installed, you should load a new instance of
cmd.exe and type the command
git — version. If it returns a value, the installation was a success:
💻 IDE (Code Editor) 💻
Finally, you need an IDE (Integrated Development Environment).
Whist you’re free to use Notepad to edit code, the best system is to use a dedicated code editor. The old favorite was Sublime Text, however it was
not updated enough and cost.
You can download here (free).