I filed https://github.com/jruby/jruby/issues/214. enebo said, "Try jruby-1.7.0.pre1". Okay. I am looking to see if jruby is faster for my CPU-bound long-running process (15 minutes for the short version). I installed Java 7. I did "rvm install jruby-head". I tried "bundle" to install my gems, and it barfed on "mysql" and "pg" (at least) because they are native extensions, even after I threw caution to the wind and put "cext.enabled=true" in my .jrubyrc. However, I need to access postgres and mysql. Google revealed sometimes there are alternative gems for jruby, also suggested plans for supporting native extensions in newer versions of jruby, but I can't find details on either. What is the state of this? Can I install pg and mysql gems somehow, must I abandon attempts at jruby, or is there hidden option c? Please don't ask me to significantly rewrite my source tree (e.g., change require statements), especially if it leaves it ruby-incompatible. Thanks for your attention.
on 2012-06-22 21:19
on 2012-06-22 21:21
Oh, the detailed error message: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /Users/me/.rvm/rubies/jruby-head/bin/jruby extconf.rb /Users/me/.rvm/rubies/jruby-head/lib/ruby/shared/mkmf.rb:14: Use RbConfig instead of obsolete and deprecated Config. mkmf.rb can't find header files for ruby at /Users/me/.rvm/rubies/jruby-head/lib/native/include/ruby/ruby.h
on 2012-06-22 21:24
You need to use the jdbc adapters when using jruby: https://github.com/jruby/activerecord-jdbc-adapter
on 2012-06-22 21:26
I typically use "pure java" gems or wrap JDBC myself. For rails it doesn't require "much" code change: https://github.com/jruby/activerecord-jdbc-adapter YMMV
on 2012-06-22 21:43
Thanks for your suggestions. I am using the 'sequel' gem. says: https://github.com/jruby/activerecord-jdbc-adapter "Legacy configuration: If you use one of the convenience activerecord-jdbcXXX-adapter adapters, you can still put a jdbc prefix in front of the database adapter name as below." $ gem install activerecord-jdbcpostgresql-adapter Fetching: activerecord-jdbc-adapter-1.2.2.gem (100%) Fetching: jdbc-postgres-9.1.901.gem (100%) Fetching: activerecord-jdbcpostgresql-adapter-1.2.2.gem (100%) Successfully installed activerecord-jdbc-adapter-1.2.2 Successfully installed jdbc-postgres-9.1.901 Successfully installed activerecord-jdbcpostgresql-adapter-1.2.2 3 gems installed Tried adapter of "jdbcpostgresql". I get: Sequel::AdapterNotFound: LoadError: no such file to load -- sequel/adapters/jdbcpostgresql chained_4_rescue_line_25 at /Users/me/.rvm/gems/jruby-head/gems/sequel-3.36.1/lib/sequel/database/connecting.rb:27 ... Looked in dir: $ ls /Users/me/.rvm/gems/jruby-head/gems/sequel-3.36.1/lib/sequel/adapters/jdbc/postgresql.rb /Users/me/.rvm/gems/jruby-head/gems/sequel-3.36.1/lib/sequel/adapters/jdbc/postgresql.rb So how do I choose the right adapter for sequel? Thanks for your attention.
on 2012-06-23 01:39
Hi Dan You should be asking this question on the Sequel Google group https://groups.google.com/forum/?fromgroups#!forum... Since you are using Sequel and not AR you need to install the jdbc-postgres gem, I would uninstall activerecord-jdbcpostgresql-adapter first. The uri should be of the form jdbc:postgresql://<host>/<database>. More details here http://sequel.rubyforge.org/rdoc/files/doc/opening... Rohit
on 2012-06-27 19:01
Although technically you are correct (this is about using sequel), it is a barrier to using jruby. I would think if the jruby community wants to support users, it would be good to have a ready answer to what seems a common question to me.
on 2012-06-27 19:02
Also, I am not using a URI. As stated, I am using an adapter, i.e. Sequel.connect with :host, :database, :user, :port, :adapter parameters.
on 2012-06-28 00:17
The advantage of using a uri is that you can append any connection specific options supported by the postgres jdbc driver to the uri string. Sequel.connect(:adapter => 'jdbc', :username => 'xxx', :password => 'xxx', :uri => 'jdbc:postgresql://localhost;database=xyz')