Installing Ruby on Rails with Mysql on Windows

No I don’t like working on Windows, but unfortunately my co-workers haven’t seen the light yet.

To make the rails setup a bit easier I needed to document the installation of Ruby on Rails on Windows with a Mysql database.
The description is about Ruby 1.9.?, Rails 3.0, Mysql 5.5 with the mysql2 gem.. and a lot of gems that got installed and compiled via “bundle install”

Here’s a raw extract of the document I build:

1. Install MySQL

In our situation MySQL was installed. But you should install MySQL with development files. (C++ headers and Libraries).
Just download the Community Server at

2. Install Ruby

Install the base Ruby version. Download the installer at
Run the installer and check the following items:

  • Add Ruby executables to your PATH
  • Associate .rb and .rbw files with this Ruby Installation

3. Install DevKit

Because a lot of Ruby plugins make use of Native extensions you need a compiler. For windows there’s devkit to the rescue. Download it at rubyinstaller:

Extract this to (for example) c:/devkit (this text assumes this location)
Open a command prompt: (cmd.exe) and enter the following commands.

cd c:/devkit 
ruby dk.rb init

DevKit wil probably find your ruby installation. But to make sure check the file c:/devkit/config.yml. It should contain the path of your Ruby installation:

- C:/Ruby192

This step installs (or updates) an operating_system.rb file into the relevant directory needed to implement a RubyGems pre_install hook and a devkit.rb helper library file into \lib\ruby\site_ruby. NOTE: you may need to use the –force option to update (with backup of the originals) the above mentioned files as discussed at the SFX DevKit upgrade FAQ entry.

Test the Devkit installation Confirm your Ruby environment is correctly using the DevKit by running.

gem install rdiscount --platform=ruby

RDiscount should install correctly and you should see:

Temporarily enhancing PATH to include DevKit… in the screen messages.

After this double check if it works by running:

ruby -rubygems -e "require 'rdiscount'; puts'**Hello RubyInstaller**').to_html" 

to confirm that the rdiscount gem is working. (This should generate HTML)
(More info: )

4. Install Git

If you not already have installed git, please do it. You will like it!
Git is required for many plugins so you need it.

  • download git at (choose a version I don’t know :P, the latest .exe ?? )
  • execute the installer, select the following options:
    • check “Run Git and included tools from the windows command prompt” (Select the option with the red letters that scream “don’t pick me” :P )
    • checkout-as-is and commit-as-it.

5. Install Rails with the mysql2 plugin

Next install Ruby on Rails. (We don’t install/generate the docs)

gem install rails --no-ri --no-rdoc

6. Install the mysql2 gem

To build mysql2 support do this: (Point the paths to your MySQL install directory!)

NOTE: When using a 64bit version of windows you probably run into issues. Thanks for mentioning Luis! (Read more about it: ).

gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

(Mysql5.1 seems to have the path: c:\Program Files\MySQL\MySQL Server 5.1\lib\opt)

Fix up Bundler (the gem management tool) to know what the mysql2 gem build settings need to be..
Else you’re “bundle install” will fail when installing or updating the mysql2 gem!!

bundle config build.mysql2 '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

As soon as you start using this installation you could get errors like ‘libmysql.dll not found.
To solve this copy this file from the mysql-installation/lib directory to the ruby/bin directory.

Slightly Unrelated, install the Rails app

Pull the rails app from git. (Or copy it). And run bundler install to install all gems..

cd /rails/app
bundle install 

I’ve recieved the following error when doing this:

Resolving deltas: 100% (3434/3434), done.
Checking out files: 100% (85/85), done.
Fetching source index for

Could not find devise-1.4.0 in any of the sources

I seems that devise was updated and the specific version in Gemfile.lock wasn’t available anymore.
You can Force the installation of this updated package

bundle update devise

These were my steps to build a working rails environment under windows…
Enough of windows, Now back to my Mac :P

Synchronization of calendar, contacts on my (windows) mobile, horde and thunderbird.

(Sorry for the format, it’s a straight copy from my DokuWiki)

This is my situation:

* I’ve got a FreeBSD server which runs PHP, Apache, Mysql, Courier Imap.
* I’ve multiple clients which run Thunderbird as my mail client. I’m using imap for mail access
* My thunderbird clients also run lightning for agenda functionality
* I also have a mobile phone HTC Touch with Windows Mobile 6.

I would like to share my contacts, agenda items, notes and tasks with all my clients.
My phone syncs all these items.
Thunderbird only the contacts an agenda..

This document describes the installation of this system. I assume you already
have a working server like described above.

Install Horde

I downloaded the Horde Groupware Webmail Edition. WARNING this **must** be at least
the 1.1 edition. At this moment it’s still a Release Candidate. (Horde Groupware Webmail Edition 1.1-RC3)

Complete Install manual of horde can be find here:

Summary of this setup:

* Extract this file to a web directory (horde-webmail-1.1-rc3.tar.gz)
* run the setup script: php scripts/setup.php
* build the database, enter the database settings etc.
* enter the name of your IMAP user that gets administrator rights for horde

Things to know:

* you can login to horde with your IMAP username and password
* The syncML url for horde is: http://yourserver/horde-setup-location/rpc.php
* Use your IMAP username and password for this synchronisation


I assume you already have thunderbird running with lightning. I’ve got the latest versions:
Lightning plugin 0.8

 * At the Thunderbird extensions site download Funambol Plugin
   * You can find it at the source:
   * Choose Funambol Mozilla PIM plugin
   * I've tested version 0.4.4: Funambol-Pim-Plugin-win32-v0.4.4.xp
 * Change the config for this plugin
   * Thunderbird Menu: Extra => Funambol Plugin
   * Choose Options
     * Enter your server details:  
     * Enter your IMAP username and password settings
     * Goto tab 'Synchronize'
       * Enable contacts, press details, 
                and enter 'contacts' (without quotes) in the remote name.
       * Enable calendar, press details, 
               and enter 'calendar' (without quotes) in the remote name.
       * tasks are not (yet) available :-(  too bad.

Make your phone support SyncML

Download Funambol:
Tested with version:

  * Install this cab file on your phone.
  * Start Funambol
  * Choose Menu / Account
    * Again enter the Server and login details
  * Choose Menu / Settings
    * Enable only: contacts, calendar, tasks and notes! Disable the others!!
    * Choose Menu / Advanced
      * Enter the following names for the items:
        * contacts: contacts
        * calendar: calendar
        * tasks: tasks
        * notes: notes

This was all that it took to sync all my devices!

Microsoft Automatic Update Reboots

After loosing some data thanks to the nice Microsoft autmatic update reboot. I’ve decided to disable these stupid reboots. Who ever invented this “great” feature should be kicked very hard!!

Disable Reboots for This Run

Execute this at the commandline:

net stop wuauserv

Or a bit more user friendly

net stop "automatic updates"

Much Better is to disable the updates

Start, Run “gpedit.msc” to bring up the group policy editor. Then navigate to the folder

Local Computer Policy   ( Dutch versions: Beleid voor lokale computer)
Computer Configuration ( Dutch versions: Computerconfiguratie )
Administrative Templates ( Dutch versions: Beheersjablonen )
Windows Components ( Dutch versions: Windows-onderdelen )
Windows Update

There are two settings and both will work, so it’s your choice. Either enable No auto-restart for schedule Automatic Updates installations or set Re-prompt for restart with scheduled installations to a long time interval, like 1440 minutes.

I found the information above on the following URL: