views:

419

answers:

2

If I call:

gem install sqlite3-ruby --v 1.2.3

it works for MRI

but if I call:

jruby -S gem install sqlite3-ruby --v 1.2.3

it says it's trying to build a native extension (for Windows) and fails.

Why are JRuby and MRI different in the way they treat gems?

+3  A: 

Because anything that is building native extensions is compiling something in C, and I believe that JRuby isn't compatible with these things that have parts written in C although I am not across the technical reasons for this.

railsninja
+3  A: 

JRuby gems that C code must use FFI. FFI is a pretty new thing and most ruby gems that use C do not use it (actually I'm not aware of any that do).

http://blog.headius.com/2008/10/ffi-for-ruby-now-available.html

Anyway, you dont need this for SQLite3 under jruby - use this:

jruby -S gem install jdbc-sqlite3

or if running rails:

jruby -S gem install activerecord-jdbcsqlite3-adapter
Rob
Also remember to change the database.yml entry to use the jdbc adapter:development: adapter: jdbcsqlite3 database: db/jdbc-development.sqlite3 pool: 5 timeout: 5000
kfitzpatrick