4

Trying to install mysql2 gem with ruby2.0.0-p247 on Cent OS 6.3.

This all works fine on ruby-1.9.3-p324 but using RVM to install ruby2. My test code is as follows

require "mysql2"

puts "test"

Running ruby against the above code, I get the error:

/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in require': cannot load such file -- mysql2/mysql2 (LoadError) from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in require' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.11/lib/mysql2.rb:9:in <top (required)>' from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in require' from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in rescue in require' from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:35:in require' from mysqltest.rb:1:in `'

The bundle install / gem install mysql2 works fine, it's just trying to use the gem. I've googled this and the common answer is that the libmysql-devel package etc are not installed, this is not the case as it's working fine under ruby-1.9.3.

The files are on disk

[git@rubyland-provisioner mysql2-0.3.11]$ ls lib/mysql2 client.rb em.rb error.rb result.rb version.rb [git@rubyland-provisioner mysql2-0.3.11]$ ls ext/mysql2 client.c client.o Makefile mysql2_ext.c mysql2_ext.o result.c result.o client.h extconf.rb mkmf.log mysql2_ext.h mysql2.so result.h wait_for_single_fd.h 

If I manually copy mysql2.so (which is built by the gem install, I've checked the timestamps) to the lib/mysql2 directory, everything works as expected.

I'm fairly new to Ruby; what am I missing? Why is the gem install not copying this file to the correct location.

Thanks

Andrew

0

2 Answers 2

2

This turned out to be a bug in RVM with the version of RubyGems installed by RVM. You need to make sure that the RubyGems that is installed is 2.x. This wasn't the case for me, RVM had either not installed RubyGems at all, or, not installed the correct version; we ultimately got some help from the RVM channel on IRC.

There's a bit more detail on twitter off the back of the conversation we had.

https://twitter.com/mpapis/status/357160111883563008

Sign up to request clarification or add additional context in comments.

Comments

0

just downgrade the mysql2 version. In my case, I used '0.2.6' version and it worked for me.

 gem 'mysql2', '0.2.6' 

with ruby version 2.0.0 and gem version 1.8.25

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.