Issue with Rails 2.2.2 + Jruby for mysql adapter

I am trying to create a simple Rails 2.2.2 app using jruby 1.1.5. The
application is using mysql DB. The gems installed are:
$jruby -S gem list

*** LOCAL GEMS ***

actionmailer (2.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (2.2.2)
glassfish (0.9.0)
jdbc-mysql (5.0.4)
rack (0.4.0)
rails (2.2.2)
rake (0.8.3)
rspec (1.1.11)
sources (0.0.1)
[/c/dev/rails/book]

During migration I get this error from Rails that 2.2.2 no longer ships
mysql.rb:

$jruby -S rake db:create
(in C:/dev/rails/book)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please
install t
he mysql gem and try again: gem install mysql.
rake aborted!
no such file to load – mysql

When I try to do: jruby -S gem install mysql, it can’t install as jruby
does
not support native extension. So the only option I have is to
install activerecord-jdbcmysql-adapter or someone got any better way to
go
past these errors?


$jruby -S gem install mysql
JRuby limited openssl loaded. gem install jruby-openssl for full
support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Building native extensions. This could take a while…
C:/tools/jruby/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native
extensions.
Check wiki.jruby.org for alternatives. (NotImplementedError)
from C:/tools/jruby/lib/ruby/1.8/mkmf.rb:1:in `require’
from extconf.rb:1
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

-vivek.

Hi Vivek -

As I understand it (and I’m no expert), what you’ve done is the
correct way to fix that. I also have a Rails 2.2.2 app that I run with
JRuby 1.1.5, and I have these gems installed to support it:

activerecord-jdbcmysql-adapter (0.8.2)
jdbc-mysql (5.0.4)

In my database.yml file, the adapter is configured like this:

development:
host: localhost
adapter: jdbcmysql
database: tt_dev
port: 3306
username: root
password:

Hope that’s helpful (or at least not wrong). :slight_smile:

Vivek P. wrote:

activerecord (2.2.2)

rake aborted!
no such file to load – mysql

When I try to do: jruby -S gem install mysql, it can’t install as
jruby does not support native extension. So the only option I have is
to install activerecord-jdbcmysql-adapter or someone got any better
way to go past these errors?

I think another option is to copy the Ruby MySql driver to /lib. You can download it from Ruby/MySQL,
or just copy it from an older version of activerecord (e.g.
gems/activerecord-2.1.2/lib/active_record/vendor/mysql.rb). Probably
better to use the jdbc adapter anyway, just wanted to point out this
option too.

Erno


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Vivek

Seems like you’re missing the jdbc adapter

gem install activerecord-jdbcmysql-adapter
and change the adapters entry in database.yml to: adapter: jdbcmysql

/Mikael

Vivek P. wrote:

activerecord (2.2.2)

rake aborted!
JRuby limited openssl loaded. gem install jruby-openssl for full support.

-vivek.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Erno M. wrote:

I think another option is to copy the Ruby MySql driver to /lib. You can download it from Ruby/MySQL,
or just copy it from an older version of activerecord (e.g.
gems/activerecord-2.1.2/lib/active_record/vendor/mysql.rb). Probably
better to use the jdbc adapter anyway, just wanted to point out this
option too.

Which raises another question; other than age/support, what IS the
reason for
not using the old mysql adapter? Is the JDBC one better in any way?


Twitter: http://twitter.com/campbellmichael


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Wel, the mysql adapter works fine on JVM on windows platform. Although
for
some reason it does not work on ubuntu.

-vivek.

Yeah. The MySql adapter has native code that does not run in the JVM.
And
the pure Ruby variant does not work on 4.1 or 5.x.

On Mon, Dec 1, 2008 at 7:24 AM, Michael C. <

If you got an error on Ubuntu like this:

/home/ryan/opt/jruby-1.1.5/lib/ruby/1.8/mkmf.rb:7: JRuby does not
support
native extensions. Check wiki.jruby.org for alternatives.
(NotImplementedError)
from /home/ryan/opt/jruby-1.1.5/lib/ruby/1.8/mkmf.rb:1:in `require’
from extconf.rb:1
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

It’s because JRuby doesn’t run the native extensions. Your only real
choice
in that case it to install the jdbc variant.