Blog

How to Install Rails on Windows in Less Than Ten Minutes

Placeholder Avatar
Rachelle LeQuesne
February 9, 2016

In three years of Installfest, there is one thing that is guaranteed to strike fear in the hearts of our dedicated mentors: a Windows user having difficulty with their install. Well, it did up until now…

I have been lucky in Brisbane to have a wonderful mentor, Freibuis, who travels all the way from the Gold Coast to help out. Not only is he a great mentor, he is a bona fide out-of-the-closet Windows enthusiast with a background in Ops! Almost too good to be true. :-)

With the introduction of Chocolatey, the whole “setting up a Rails environment on Windows” thing has become stupid-simple. Now we are all able to share the Freibuis magic courtesy of a chocolatey process he has developed for us to use at all our Installfests.

The first step is, of course, to install Chocolatey. You do that by running the following command in your terminal (be sure to open it as administrator)

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

Once we have chocolatey installed, we can use it to install Ruby. Unfortunately Ruby 2.3 on Windows is currently broken with a lot of gems, so we use Ruby 2.2 which has better support.

choco install ruby -y -version 2.2.4

We also need to add Ruby to PATH so that our operating system knows where to find it. We do that with the following command:

PATH=%PATH%;C:\tools\Ruby22\bin

Once we have Ruby, there are a few other useful tools we need to install:

  • curl
    cUrl is a command line tool for transferring data with URL syntax.
    Run choco install curl -y.
  • wget
    GNU Wget is a software package for retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols.
    Run choco install wget -y.
  • git
    Git is a powerful distributed Source Code Management tool.
    Run choco install git -y.
  • nodejs
    This package is used to install nodejs.commandline.
    Run choco install nodejs -y.
  • sublime
    Sublime is a text editor especially designed for writing code. If you already have a preferred text editor you can skip this step.
    Run choco install sublime -y.
  • ruby2.devkit
    Ruby Development Kit (DevKit) is a toolkit that makes it easy to build and use native C/C++ extensions for Ruby on Windows.
    Run choco install ruby2.devkit -y.
    To configure Ruby DevKit, we also need to run the following commands:
    cd c:\tools\DevKit2
    echo - c:/tools/Ruby22 > config.yml
    ruby dk.rb install

So now we have everything set up and ready to go. All that remains is to install Rails! And it is as simple as running gem install rails in your terminal.

Ta da! How easy was that?

The whole process should take less than ten minutes and is as straightforward as installing on a Mac. However, if you do encounter any problems, come along to an Installfest near you and get some expert help.