Posted on Nov 26, 2011

RubyConf Argentina and Fenix

Recently I had the honor to speak at RubyConf Argentina 2011 (which I must say was a blast).

My talk was titled Tirando Ruby por la Ventana, which translates to Throwing Ruby through the Window

The talk was aimed at highlight a few issues with Ruby on Windows, ranging from the community to the implementation.

Here are the slides:

While the slides are in spanish, you might get the idea from the profiling to all the other charts 😉

But ranting without something to back you up is silly, so I’ve tried to proof that platform is not the issue.

On my slides I showed Fenix a proof-of-concept of harness the power of Windows API just re-implementing File.expand_path function, which was considered one of the culprits of performance issues on Windows.

Fenix as an experiment is a nice sandbox to play with Ruby without the lengthy compilation times on building Ruby from scratch on Windows.

It also helped to have a side-by-side comparison of Ruby own implementation.

But, most important, it served the purpose of document File.expand_path behavior through specs.

Ruby itself has no code to ensure that File.expand_path behave consistently across versions.

The goals were simple:

  • * Figure out what Ruby it is supposed to do and document it (specs)
  • * Implement the minimum code that make those specs pass
  • * Harness the power of newer Windows API
  • * Benchmark and compare always

So I have only done the minimum set of requirement to make Rails run, and run faster. There are plenty of corner cases that I didn’t cover and some that I’ve acknowledge in the specs but require its implementation.

The end result is use Fenix as playground to start working on better internals for Ruby itself, but without the tedious build process.

Also, all the work is aiming at Ruby 2.0, since the inner changes on Ruby to accommodate something similar are too big to be included back in 1.9.3

How I’m supposed to test this out?

So I guess you don’t believe in my slides… neither other developer’s conclusions

You can take a look to TheCodeShop builds that already include Fenix and test for your self.

Want to join us make Ruby better?

Please, try out and send us your feedback at TheCodeShop group.

A faster Ruby is possible, we just need to get rid of the legacy stuff and build for the future.

Posted on Jul 7, 2011

Installing MySQL on Windows 7 x64 and using Ruby with it

Recently I reinstalled by entire Windows installation due a SSD migration and wanted to take the opportunity to document the configuration process, specially in the light of the known issues with making it work with Ruby.

It is important to mention that most of these issues in Ruby land are generated due the lack of documentation associated on how to properly install MySQL and its related dependencies.

Most of us expect things to Just Work, and we often compare the installation process to installing to Linux or OSX which works out of the box.

What is not mentioned in the documentation installation is that development tools (a compiler) and specific headers and libraries are required. Unless you’ve already installed them, these development artifacts are usually missing from a Windows computer.

What I’m going to describe next is how I installed and configured my environment and how I made it work properly. YMMV if you decided to use different versions of the components I used for this.

Let’s get started:

Download the right version of MySQL

As I mentioned before, I’m using a 64bits version of Windows, so I think it will be best if I download a matching bits version.

So went ahead and visited MySQL download site:

And selected MySQL Community Server 5.5.13.

From the versions offered, downloaded Windows (x86, 64-bit), MSI Installer

Install MySQL

Invoked the installer and presented with the normal installation wizard.

You can follow the next sequence of images to use my same settings.

Is good to always install your Data files outside the default program installation directory, that way, you can safely upgrade your installation and not to worry about an installer removing your data files.

Ok, so let’s move to the next thing…

Before installing MySQL/Ruby bindings

Update: mysql gem version `2.9.0` already fix the issues shown here. Install it normally and follow the on-screen instructions.

In order to use my brand new MySQL installation, now I need to install the MySQL bindings for it.

But, there is a small detail: Ruby is 32bits and my MySQL is 64bits, this means I can’t use MySQL provided libraries from Ruby.

Bummer! You told me to install the 64bits version!

Don’t despair! MySQL Connector to the rescue!

That is right, MySQL has something called Connector, the purpose of that library is to avoid a complete MySQL installation when you just need to connect to a remote one.

It comes in different flavors, we are interested in C language support, since that is the language Ruby uses for it’s extensions.

We are going to download a 32bits connector and use it!

So, at my web browser again, decided to visit the MySQL Connector/C download page:

Since I’m not interested in installing this Connector and pollute my clean 64bits installation, I’m going to download the non-installer version.

I scrolled down the listing until I saw the noinstall 32bits version:

Decided to extract it to the root of my disk, so I ended with a folder named mysql-connector-c-noinstall-6.0.2-win32 in there.

Remember: extract into a folder without spaces. The same goes for your Ruby installation and the DevKit installation.

Time to install MySQL/Ruby bindings

So, now that all MySQL prerequisites are in place, will open a new command prompt and prepare to install the gem.

This time I’m going to use Ruby 1.9.2, properly installed and configured with the complementary Development Kit (DevKit) which is provided at RubyInstaller website (In case you haven’t installed yet, don’t forget to follow the installation instructions in the wiki)

OK, so in a Command Prompt, will type the gem installation command:

gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32

Note the use of forward slashes for the directory where MySQL Connector/C was extracted.

The above command contains two special things:

First, we are telling RubyGems that we want the ruby platform of mysql gem. This particular platform is the one that contains the source code and this will allow us to skip the pre-compiled version of the gem.

The second part, which is added after two dashes, are the additional arguments that we are giving to the gem configuration process to locate our MySQL headers and libraries for successful compilation.

As result of this command, you will see something like this:

Fetching: mysql-2.8.1.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed

Which indicates the gem installed successfully.

In case you obtained a different result, please refer to RubyInstaller Troubleshooting page:

And try the proposed solutions there.

Using the bindings

Now that we installed the gem, we can remove the connector folder we first extracted. Before do that, first we need to take out a file from there: libmysql.dll. This file is required by the gem we compiled and needs to be available for it.

You can find it inside the lib directory of MySQL Connector.

I personally recommend you place it along your Ruby installation, inside the bin directory.

If you have multiple Ruby installations and you use Pik to change between them, you can place the library in the same directory Pik is installed. You need to remember that it is important the libmysql.dll file is on the PATH when you need to use it.

OK, after all that big red warning, let’s test this thing on a IRB console:

irb> require "rubygems"
irb> require "mysql"
irb> conn = Mysql.connect "localhost", "root", "abc123"
irb> result = conn.query "SELECT 1"
irb> result.num_rows
=> 1
irb> result.fetch_row
=> ["1"]
irb> conn.close
irb> exit

Great!, now you have not just a working MySQL installation but also Ruby configured to talk to it!

Hope you enjoyed this post as I did enjoy creating it. Hope this ease your path on using MySQL with Ruby on Windows.

Posted on Apr 14, 2011

A thank you to Ruby Masters Conf and Brazilian community

Back in January I posted about Ruby Masters Conf online conference.

I must say that I’m happy to inform that not only was a blast, but RubyInstaller received some financial backing!

Yes, along with Phusion Passenger, RubyInstaller project received donations from the amazing Brazilian Community that attended to Ruby Masters Conf.

Thanks goes to e-Genial too, the company behind the conference.

This contribution is well received, specially in the light of upcoming changes to the project that will be soon announced.

As lead developer of RubyInstaller, to all Brazilians who participated: Muito obrigado!

Posted on Jan 25, 2011

Ruby Masters Conf

In case nobody noticed, but next February 25 and 26 there will be a huge conference, called Ruby Mastesr Conf (See the banner bellow)

And yes, the conference will be online with an excellent line up of speakers

Video, chat, slides and interaction with the speakers all using e-Genial online platform, kinda cool, isn’t?

Is cheap! R$ 35 (Brazil reais) is around 21 USD. You gain access to all the talks and if you couldn’t watch them live, you can see the videos 15 days later.

And the awesome part? Their objective is collect money for open source projects, like Phusion Passenger and, wait for it… RubyInstaller !!!

What are you waiting for?

Posted on Jan 22, 2011

rake-compiler: Updated list of supported Ruby versions (for cross-compilation)

Been a while since the last list of supported Ruby versions was published. So, time of updates!

Ruby Version Works? Command line
1.8.6-p398 Yes1 rake-compiler cross-ruby
1.8.7-p330 Yes rake-compiler cross-ruby VERSION=1.8.7-p330
1.9.2-p136 Yes rake-compiler cross-ruby VERSION=1.9.2-p136

All of the above results were obtained using rake-compiler 0.7.5.


All the tests of compilation where performed against the following compilers:

Platform Compiler Installation rake-compiler flag
OSX GCC 3.4.5 sudo port install i386-mingw32-gcc HOST=i386-mingw32
Linux/Ubuntu GCC 3.4.5 sudo apt-get install mingw32 HOST=i586-pc-mingw32
Linux/OSX MinGW-w64 GCC 4.5.2 Download2 HOST=i686-w64-mingw32

While there are other cross compilers available out there, I haven’t done any testing against them, so can’t verify it’s correctness in the above results.

I would personally recommend the usage of mingw-w64 compilers since are fresh and updated quite often.


If you’re creating extensions, it is recommend you use both 1.8.7 and 1.9.2 as test-beds for your extensions. That will ensure maximum compatibility with future versions of Ruby.

Next version of rake-compiler will bump the default version to 1.8.7, so is better you start preparing now.

1 1.8.6 compilation fails when used with mingw-w64 compiler (i686-w64-mingw32 host)

2 You can download mingw-w64 compiler from SourceForge Automated Builds

Latest Tweets