As I’ve noted before, in addition to running Ruby and Rails on my Linux boxes, I’m also running them on my Windows boxes. Dave Keener, a colleague from NovaRUG, e-mailed me asking for advice on how to set them up under Windows. Here is an expanded version of what I told him. Note that this is geared for setting up a Ruby on Rails development environment on Windows, not a production server.
Permissions
First, you’ll need administrator privileges to install most or all of this software, depending on how your system is configured. In the case of WAMP, you’ll also need to either run it as administrator or create a separate account with the necessary privileges.
Apache and MySQL
If you need these (as opposed to Nginx, Mongrel, etc.), you want WAMP. WAMP is a management application that installs and manages Apache, PHP and MySQL on Windows boxes. It’s intended for developers and allows you to have multiple versions of each and switch among them. It looks like it supports SQLite also, though I haven’t played with it.
Apache Conflicts with IIS


You may have problems getting Apache up and running on the box. If so, make sure that you have clicked on Start -> All Programs -> WampServer -> start WampServer. You should get a small gauge icon in the System Tray that looks like a speedometer. Left click on that, select Apache -> Service -> Test port 80. If it says that IIS is running on the box, go to Start -> Control Panel -> Administrative Tools -> Internet Information Services. In that applet, expand Internet Information Services -> [Computer name](local computer) -> Web Sites. Click on “Default Web Site” and then click on the stop button on the toolbar (it’s a black square, like on a CD player or VCR). Then try starting Apache again.
If you need to use both, then you’ll have to reconfigure one of them to run on a different port.
Installing Ruby
After you’ve installed WAMP, you need to install Ruby. The easiest way to do this is to download the RubyInstaller for Windows. They have versions 1.8.6, 1.8.7, 1.9.1 and 1.9.2. I’ve used this on my Windows boxes, and it’s gone smoothly, thanks to Luis Lavena and the RubyInstaller team.
Path Issues
Note that the Ruby bin directory will not be added to the path by default. The installer has a couple of checkboxes that you can check off to do this; keep an eye out for them. After installation, close any open command shells, as they’ll still have the old environment.
Verify Installation
Once you’ve completed the installation, open a new command shell and type:
ruby -v
You should see something like this:
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
If you don’t, check to make sure that you checked off the checkboxes to add Ruby to your path. If so, go back and try the installation again, keeping an eye out for error messages.
Installing Rails on Windows
Now that you have installed Ruby, installing Rails is next. In the command shell, type
gem update --system
to make sure that your RubyGems installation is current. Once that has finished, type
gem install rails
and you’re in business.
No Shebang
Keep in mind that Windows doesn’t have the equivalent of the shebang or the executable permission that POSIX systems like Linux and OS X do. You can associate the “.rb” extension with the Ruby executable to allow execution of scripts by clicking on them via the Windows Explorer shell. When executing them via the command shell, however, you’re going to have to pass the script as an argument to Ruby:
ruby script.rb
Note that you can work around this by using a port of a UNIX shell, like cygwin’s bash or WinZsh.
MySQL Problems
I ran into a couple of problems with MySQL while running migrations. I documented the solutions in these two blog posts:
- rake db:create – this application has failed to start because libmysql.dll was not found
- rake db:migration – Segmentation fault
Multiple Versions of Ruby on Windows
Ruby Version Manager (rvm) is a great way to manage multiple versions of Ruby and gems. Unfortunately, it doesn’t work on Windows. Try the pik project. It’s not as advanced as rvm, but it’s coming along.
Help
Once you’re up and running, you can get help from the community via the newsgroup comp.lang.ruby, ruby-forum.com, or the mailing list ruby-talk. All of these feed into each other, so you can select your preferred interface. I prefer accessing comp.lang.ruby via Usenet, because Usenet was designed from the beginning to facilitate discussion and has lots of cool features that mailing lists and web fora can’t match.