Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

June 9, 2008

Setting Up Rails Development Environment on Windows Vista/XP

Filed under: Ruby/Rails, Web — tabrez @ 2:53 pm

There are different ways in which you might want to set up a complete development environment for Ruby on Rails on a Windows machine. I am going to cover how to setup Rails on a Windows machine using Ruby, RubyGems, Rails, Mongrel, MySQL, NetBeans and Subversion as part of the development stack. I will be using Windows Vista as the reference OS but most of the instructions work for Windows XP too.

  1. Installing Ruby: Download and install the latest final version of the Ruby installer(currently 1.8.6) from the rubyforge.net website: One-Click Ruby Installer for Windows

    Leave all the default settings as they are and proceed with the installation wizard. It is important that you install Ruby in a path which doesn’t contain any spaces in it(the path c:\ruby selected in the wizard by default works fine).

    After the installation is complete, confirm that the ruby commands are added to the system path. Start the Command Prompt(Start -> Accessories -> Command Prompt) and type the following command:

    C:\> ruby -v
    ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
    C:\> gem -v
    0.9.4

    If you get the “not recognized as an internal or external command” error, add the path to the ruby bin directory(e.g. c:\ruby\bin) to the system PATH environment variable(Control Panel -> System -> Advanced System Settings).

  2. Updating RubyGems:
    The above installer also installs RubyGems package and SciTE editor as part of the “one-click” installation process. Unfortunately though, the installed version of RubyGems may be a bit old(~0.9.4), so run the following command to update it to the latest available version(currently 1.1.1):

    C:\> gem update ––system
    C:\> gem -v
    1.1.1

    Note: Add “-p http://proxy:port” to all gem install commands if you are connecting to the Internet through a proxy.

  3. Installing Rails:
    Now it is time to install the Rails package. Run the following command to install Rails as a ruby gem:

    C:\> gem install rails
    C:\> rails -v
    2.1.0

    In future, whenever you want to update Rails to a newer version, simply run the following command:

    C:\> gem update rails

The basic Rails development environment is now installed on your system and you can skip the rest of the post if you are happy with WEBrick as the web server, SQLite as the database server and SciTE as the editor(or your favourite text editor/IDE already installed on your system). The following instructions cover installing an alternate web server called Mongrel; MySQL database server and its GUI tools; NetBeans IDE, Subversion and their integration.

  1. Installing Mongrel:
    Installing the Rails gem also installs the WEBrick web server which is ideally suited for development purposes. Another much recommended web server for Rails development as well as production environment is the Mongrel web server. To install the Mongrel web server, run the following gem command:

    C:\> gem install mongrel
    C:\> gem list mongrel

    *** LOCAL GEMS ***

    mongrel (1.1.5)

    After installing Mongrel, Rails automatically starts the Mongrel instead of WEBrick web server when you run the Rails applications in development mode. (Refer to Mongrel documentation to know more about runing Rails applications under Mongrel in production mode.)

  2. Installing MySQL:
    This step covers the installation of MySQL database server and its GUI tools. Skip this step if you want to use some other database server.

    Download and install the MySQL 5 database server. You can safely accept all the default settings of the installation wizard. After MySQL database server is installed, you need to run its configuration wizard to configure the MySQL installation.

    • If you are a Windows XP user, run the configuration wizard directly from Start -> MySQL -> MySQL Server 5.0 -> MySQL Server Instance Config Wizard.
    • If you are a Windows Vista user, you first need to patch the configuration wizard before running it. Follow these instructions to patch the MySQL configuration executable using ResHack utility. Once that is done, you can run the configuration wizard from Start -> MySQL -> MySQL Server 5.0 -> MySQL Server Instance Config Wizard.

    One important step during the configuration process is to select a root password(you will need to enter it in the database.yml configuration file of your Rails application).

    Now download and install the MySQL GUI tools. This step can be skipped if you want to use mysql command line tools or if you prefer other GUI front-ends like HeidiSQL.

  3. Installing Netbeans:
    You can use your favourite text editor or IDE to code your Rails application. Two of the most popular, Free Rails IDEs are NetBeans and Eclipse. NetBeans in particular has shown great improvement in its support for Ruby programming language and the Rails framework. I am going to cover configuring Netbeans for developing applications with Rails, so feel free to skip this step if you want to go with some other IDE(Aptana, IntelliJ IDEA etc.).

    Go to the download page of Netbeans IDE and download either the “Ruby” version(~29MB) or the “All” version(~219MB). (Ruby version supports only Ruby where as the All version supports Java, C++, etc. in addition to Ruby.)
    Install NetBeans. Run it. When creating a new Rails project in NetBeans, remember to select “Ruby” as the default instead of the default “JRuby” and then select Mongrel as the web server.
    Ruby on Rails configuration dialog box in NetBeans

    For more information on developing Ruby on Rails applications using the NetBeans IDE, refer to the following links:

    There are many alternative IDEs that you can checkout, like Aptana Studio, Komodo, IntelliJ IDEA, etc.

  4. Installing Subversion:
    Go to the Subversion download page, scroll down to the Windows section and click the “Win32 packages built against Apache 2.2″ link and download and install the ‘basic win32 binaries’ package.

    Download Subversion package for Windows Download Subversion package for Windows

    You can now work with the Rails applications stored in subversion repositories. You can also install and use TortoiseSVN which is a GUI subversion client that integrates very well with the Windows Explorer. I couldn’t find a way to integrated it with NetBeans though, so I install the subversion command line version to use with NetBeans even if I have TortoiseSVN installed on my system.

  5. Configuring Subversion in NetBeans:
    Start the NetBeans IDE and go to Versioning -> Subversion -> Checkout. If you see a dialog box as shown in the screenshot below, it means subversion is properly installed and configured on your system. You can enter the repository details in the fields shown by the wizard, checkout a Rails application and work on it from the NetBeans IDE.

    Subversion configuration dialog box in NetBeans

    (If you see an error instead, then you need to either add the subversion bin directory to the system PATH variable or enter the path in the shown NetBeans configuration window.)

    NetBeans has direct support for CVS, Subversion and Mercurial and NetBeans support for Git is currently under development.

Now you can create/checkout rails applications, edit them and run them under Mongrel from within the NetBeans IDE. One crucial item missing from this development environment is an alternative, more powerful automated build tool CruiseControl, which can also be integrated with NetBeans. Perhaps a topic for another post. In the next post I will explain how to create a basic “Hello World” application in Rails using the above development tools.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Setting Up Rails Development Environment using Aptana Studio
  • Setting Up Rails Development Environment on Fedora GNU/Linux
  • “Hello, World” Web Application in Ruby on Rails using console
  • Setting Up Rails Development Environment on Ubuntu GNU/Linux
  • “Hello, World” Web Application in Ruby on Rails using Aptana Studio
  • Setting Up Ruby on Rails Projects with Git and Github
  • Setting Up Development Environment For Grails on Windows Vista/XP

  • Readers who viewed this page, also viewed:


    18 Comments »

    1. Or you can install BitNami RubyStack which is a Windows-like installer for Windows, Linux and OSX and already has Ruby, Rails, Mongrel and other gems, along with MySQL and Subversion. Then, you only have to add NetBeans. See http://bitnami.org/stack/rubystack

      PS: Beta version bundles Ruby 1.8 and 1.9, and it will be released for Windows too this week

      Quote

      Comment by wottam — June 11, 2008 @ 11:22 am

    2. Nice tutorial. One minor correction, though. The Ruby One-Click Installer is hosted on rubyforge.org, not sourceforge.net (however, the link you provide is correct).

      Quote

      Comment by Curt Hibbs — June 11, 2008 @ 9:50 pm

    3. @wottam, BitNami RubyStack is very good indeed. WEBrick, Mongrel and Apache 2.2; PHPMyAdmin; ImageMagic & RMagic; and tons of gems. There is JRubyStack too! Hope users demand for a Grails stack too. But the new beta doesn’t seem to be available for the Windows platform yet.

      @Curt thanks for pointing that out, I have corrected the post.

      Quote

      Comment by tabrez — June 11, 2008 @ 10:37 pm

    4. @tabrez,

      Yes, I pointed out that it isn’t available at the moment, but it’s almost there and should be out by the end of the week

      Kind regards

      Quote

      Comment by wottam — June 12, 2008 @ 12:06 am

    5. Small correction for Step #2:

      gem update ?system

      should be:

      gem update ?-system

      (Two dashes are needed or you get an error.)

      Quote

      Comment by Ben Kimball — June 21, 2008 @ 12:40 am

    6. Ooops, it ate the first dash.

      Should be (dash)(dash)system

      Quote

      Comment by Ben Kimball — June 21, 2008 @ 12:41 am

    7. Ha,
      So you see how difficult it is to get two dashes in a web browser ;)
      Thanks for point it out, I have now replaced the two hyphens with ndash html entity. It reads correctly now.

      Quote

      Comment by tabrez — June 21, 2008 @ 10:31 am

    8. [...] in another different article, Setting Up Rails Development Environment on Windows Vista/XP, it suggests… In future, whenever you want to update Rails to a newer version, simply run the [...]

      Quote

      Pingback by Upgrading to Rails 2.1 on Windows « Chronicling My Ruby on Rails Journey — June 28, 2008 @ 5:43 am

    9. Thanks, a guide like this was exactly what I was looking for!

      Quote

      Comment by JJ Ele — July 13, 2008 @ 10:04 am

    10. You are welcome JJ.

      Quote

      Comment by tabrez — July 21, 2008 @ 11:06 pm

    11. [...] Setting Up Rails Development Environment on Ubuntu GNU/Linux Filed under: Ruby/Rails, Ubuntu — tabrez @ 7:38 pm This is an adaptation to Ubuntu GNU/Linux platform of my previous post which was meant for the Windows platform: Setting Up Rails Development Environment on Windows Vista/XP [...]

      Quote

      Pingback by Setting Up Rails Development Environment on Ubuntu GNU/Linux — July 22, 2008 @ 7:39 pm

    12. [...] Länken till guiden hittar du här => Länken [...]

      Quote

      Pingback by WebBiz » Installera Rails Development Environment i Ubuntu GNU / Linux — July 25, 2008 @ 12:21 am

    13. [...] — tabrez @ 5:37 pm You first need to complete the first five steps of my earlier post “Setting Up Rails Development Environment on Windows Vista/XP” which explain how to install Ruby, RubyGems, Ruby on Rails, Mongrel web server and MySQL database [...]

      Quote

      Pingback by Setting Up Rails Development Environment using Aptana Studio — September 3, 2008 @ 5:37 pm

    14. [...] “Setting Up Rails Development Environment on Windows Vista/XP” [...]

      Quote

      Pingback by “Hello, World” Web Application in Ruby on Rails using Aptana Studio — September 6, 2008 @ 2:34 pm

    15. [...] Setting Up Rails Development Environment on Windows Vista/XP [...]

      Quote

      Pingback by Setting Up Ruby on Rails Projects with Git and Github — December 9, 2008 @ 4:15 pm

    16. [...] to Fedora GNU/Linux platform of my previous posts meant for the Windows Ubuntu platforms: Setting Up Rails Development Environment on Windows Vista/XP and Setting Up Rails Development Environment on Ubuntu [...]

      Quote

      Pingback by Setting Up Rails Development Environment on Fedora GNU/Linux — December 17, 2008 @ 10:52 pm

    17. [...] Setting Up Rails Development Environment on Windows Vista/XP [...]

      Quote

      Pingback by “Hello, World” Web Application in Ruby on Rails using console — January 11, 2009 @ 6:19 pm

    18. Correction - You can integrate Netbeans with Subversion and it really is cool having netbeans with it. It requires a different subversion though - Collabnet Subversion. My Netbeans version is 6.5.

      It also worked with Netbeans 6.1. With the other versions, I don’t have any idea.

      BTW, Thanks for the tutorial! =D

      Quote

      Comment by J. Allen — March 6, 2009 @ 10:08 am

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost