Wednesday, April 1, 2009

Jruby on XP


Visit the Jruby site. Follow those directions. http://wiki.jruby.org/wiki/Getting_Started
Download a copy of the Jruby distribution, a .zip, for XP from that site. Version 1.2.0, which is ruby 1.8.6 patchlevel 287. Extract that archive into a directory, e:\jruby-1.2.0.
  • Add e:\jruby-1.2.0\bin to the %PATH% variable.
  • Add %JAVA_HOME% variable and set to c:\Program Files\Gava\jre1.6.0_07
Try to run jruby script\server. An error message: Please 'gem install -v2.0.2 rails'. Success. All the action* stuff is installed. All the ri and RDoc stuff reports successful installation. This is good stuff so far.

Try jruby script\server again. Failed because it could not run sqlite3. Fair enough. The app was built with MySQL. Let's gem install mysql.
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
Rummaging around searching for solutions ... perhaps the MySQL connection is supported through the Java layer? Others say the JDBC adapter must be used. Let's try,
jruby -S gem install activerecord-jdbcmysql-adapter

Three things seem to have installed successfully, along with the ri and RDoc doc; activerecord-jdbc-adapter-0.9.1, jdbc-mysql-5.0.4, activerecord-jdbcmysql-adapter-0.9.1

Enough for today. More tomorrow.

3 comments:

Janos Hardi said...

With JRuby you cannot use native (C based) gems so you can forget the native mysql gem. Use the jdbc connectors from JRuby Extras collection: http://rubyforge.org/projects/jruby-extras/
You don't have to bind to activerecord btw, there are other good orms like sequel. Good luck!

Mortimer Agustus Stanley said...

Thanks Janos!

Why would one not want to use activerecord and use something like sequel? Is the interface and behavior identical?

Janos Hardi said...

No problem :)

Well ActiveRecord is just one of the good ORMs around. If don't want to bound to it you have a good selection of choices. Just take a look on github.com for Ruby/Rails ORMs.

For myself I like the API of Sequel thats all :) For JRuby I used the H2 database its pretty fast and beats sqlite in every way.

Have fun with Ruby/Rails ;)