I was recently introduced to an great little framework called Padrino. I want to try out for a spin, and as I’m still a newb to JRuby I hit a few snags. Here are the steps I went through to get Padrino running using JRuby on OSX. Note, you need to have XCode installed because JRuby needs the JDK.
First, install RVM so you don’t go crazy manging differnt ruby dependencies for your projects.
$ curl -L https://get.rvm.io | bash -s stable
Next, install JRuby using RVM. I went for the Ruby 1.9 version because JRuby recommends it.
$ rvm install jruby --1.9
Install bundler and padrino gemsets.
$ gem install bundler padrino
Now, I hit an error in one of my gems complaining about a C extension. I am thinking my solution wasn’t the best, because JRuby I don’t think should be using cext, but here it is anyway. I found this solution documented in a ticket here. It looks like this will go away with a newer version of RVM.
$ cd ~/.rvm/rubies/jruby-1.6.7.2/
$ ant clean cext
If you are getting warnings about openssl, it has to do with packaging issues currently in JRuby.
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
To get full openssl support, you need to not only install the gem like the message says, but add it to you Gemfile to make it visible to your project.
gem "jruby-openssl", :platforms => :jruby
I was up and running, but every time I tried to access the database, my app would crash and burn.
dyld: lazy symbol binding failed: Symbol not found: _rb_check_safe_obj
Referenced from: /Users/bbergstrom/.rvm/gems/jruby-1.6.7.2/gems/sqlite3-1.3.6/lib/sqlite3/sqlite3_native.bundle
Expected in: flat namespace
dyld: Symbol not found: _rb_check_safe_obj
Referenced from: /Users/bbergstrom/.rvm/gems/jruby-1.6.7.2/gems/sqlite3-1.3.6/lib/sqlite3/sqlite3_native.bundle
Expected in: flat namespace
Trace/BPT trap
I threw the question out on the JRuby mailing list and quickly got a response that I needed to use Java database adapter gems instead of the default C extensions.
I added this to my Gemfile:
gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
Now, I am up and running. Padrino has taken the JRuby stage.