Prerequisites for Installing Rails on Windows

Setup

I tested on:

Where it failed

Running

gem install rails

from the prompt threw an error complaining that msys2 was missing, and gem list --local confirmed the install never completed. Naturally rails -v did not work either.

Root cause and fix

msys2.png

After reinstalling Ruby, a prompt opens automatically. Do not press Enter immediately—follow these steps:

  1. Type 1 and press Enter to install.
  2. Type 2 and press Enter to update.
  3. Type 3 and press Enter to install the MINGW toolchain.

I do not know every detail, but it seems required so Ruby can compile native extensions written in C.

Finally, rerun:

gem install rails

and the installation succeeds.