Skip to content

Can't find activerecord-mysql-adapter #3147

Closed
hadmut opened this Issue Sep 27, 2011 · 20 comments

6 participants

@hadmut
hadmut commented Sep 27, 2011

Hi,

since upgrading through gems to activerecord/rails 3.1.0 from 3.0.10, my ruby scripts using activerecord don't work anymore and issue the error message

Error Please install the mysql adapter: gem install activerecord-mysql-adapter (Could not find RubyGem mysql (~> 2.8.1)
)

However, gem could not find this module anywhere, even if I add the common sources to my gems:

http://rubygems.org/
http://gems.rubyforge.org/
http://gems.github.com/

Asking on IRC or the mailing list for help did not bring any usable answer.

Where would I find that module?

@arunagw
Ruby on Rails member
arunagw commented Sep 27, 2011

Ok. can you paste your database.yml here.

I am sure you have mysql in database.yml and mysql2 in gemfile.

@hadmut
hadmut commented Sep 27, 2011

What gemfile?

My database.yml states mysql as an adapter, but even setting it to mysql2 does not help, just changes the error message.

It looks like

applicationDB:
:adapter: mysql
:database: applicationDB
:username: hadmut
:host: 127.0.0.1

I am not seeing what exactly you're trying to tell me.

@arunagw
Ruby on Rails member
arunagw commented Sep 27, 2011

Also please give Gemfile.

@hadmut
hadmut commented Sep 27, 2011

I repeat the question: What "Gemfile"? What are you talking about?

Can you please elaborate your questions in a way that allows others to follow you?

I do not know what "Gemfile" means. Maybe that's part of the problem that rails is going ways that others can't follow?

@alpha123

There's a file named "Gemfile" in your root directory for your Rails app (the one with the Rakefile and the README).

A Gemfile isn't Rails specific, so this isn't just a Rails thing.

@hadmut
hadmut commented Sep 27, 2011

Most of my Rails apps do not have a Gemfile at all. Just in the latest rails app I found one (which does not mention mysql at all). But that's not relevant, since I am not talking about a rails application here.

I am talking a about a simple ruby application which simply uses activerecord. No Gemfile. Just using activerecord.

@arunagw
Ruby on Rails member
arunagw commented Sep 28, 2011

@hadmut sorry about that question. I missed that you said about Ruby Scripts. Can you give a example of configuration of your ruby script. How you are loading the database.yml file. And how you are maintaining the gems. I might solve the problem.

@guilleiguaran
Ruby on Rails member

@hadmut can you provide a minimal failing script to reproduce your problem?

@hadmut
hadmut commented Sep 28, 2011

Here's a stripped down example. I just found that the problem occurs only if I run this example with ruby1.9.1 , but not with ruby1.8. However, since the (now removed for the example) program makes use of ruby1.9 features, I cannot simply move back to ruby 1.8:

-- coding: utf-8 --

require 'yaml'
require 'rubygems'
require 'active_record'

module NetworksDB

def self.establish_connection()

arg = {:adapter => "mysql" , :database => "SomeDatabase", :username => "hadmut" , :host => "127.0.0.1"}

Networkv4.establish_connection(arg)

end

class Networkv4 < ActiveRecord::Base
end

end

NetworksDB.establish_connection

@hadmut
hadmut commented Sep 28, 2011

Grrr, this forum just turned my script into garbage. Isn't there a button for attachments anywhere here?

@hadmut
hadmut commented Sep 28, 2011

BTW, I just used gem install rails to get rails3 and later gem update. At that time I had only http://rubygems.org/ in the sources list of gem (using ubuntu linux).

@arunagw
Ruby on Rails member
arunagw commented Oct 1, 2011

@hadmut Ok so got the problem. you need to add

require 'mysql' 

or

require 'mysql2'

Install gem mysql2 if you are using mysql2 otherwise mysql gem is fine.
You can also check current gem list if you have mysql gem installed
After adding there will be no error.

@hadmut
hadmut commented Oct 3, 2011

Thanks for the hint.

But does this make sense or is that just an ugly workaround for a bug in activerecord?

putting such a require into the ruby code would load that on every program run, even if the database configuration would use a different database. So it should be activerecord that requires that if needed, instead of the program code using activrecord...

@arunagw
Ruby on Rails member
arunagw commented Oct 3, 2011

Actually activerecord don't know which adapter you are going to use. But yeah may be you can propose the change if you think it's possible.

@hadmut
hadmut commented Oct 3, 2011

Doesn't work.

Both mysql and mysql2 gems crash with a stack backtrace.

( ruby and rails once had a much better code quality...)

@arunagw
Ruby on Rails member
arunagw commented Oct 3, 2011

@hadmut, Can you paste the stacktrace..?? You are going to need some libmysql-dev i think. Which you might not have.

@hadmut
hadmut commented Oct 6, 2011

with require 'mysql':

-- C level backtrace information -------------------------------------------
/usr/lib/libruby-1.9.1.so.1.9(rb_vm_bugreport+0x5f) [0x7f8668a6a58f]
/usr/lib/libruby-1.9.1.so.1.9(+0x5a7be) [0x7f86689717be]
/usr/lib/libruby-1.9.1.so.1.9(rb_bug+0xa6) [0x7f8668972136]
/usr/lib/libruby-1.9.1.so.1.9(rb_check_type+0x16c) [0x7f8668973edc]
/home/hadmut/.gem/gems/mysql-2.8.1/lib/mysql_api.so(+0x70c5) [0x7f8662f170c5]
/usr/lib/libruby-1.9.1.so.1.9(+0x14c93e) [0x7f8668a6393e]
/usr/lib/libruby-1.9.1.so.1.9(+0x143f61) [0x7f8668a5af61]
/usr/lib/libruby-1.9.1.so.1.9(+0x148b44) [0x7f8668a5fb44]
/usr/lib/libruby-1.9.1.so.1.9(+0x149c0b) [0x7f8668a60c0b]
/usr/lib/libruby-1.9.1.so.1.9(rb_class_new_instance+0x30) [0x7f86689b4520]
/usr/lib/libruby-1.9.1.so.1.9(+0x14c93e) [0x7f8668a6393e]
/usr/lib/libruby-1.9.1.so.1.9(+0x143f61) [0x7f8668a5af61]
/usr/lib/libruby-1.9.1.so.1.9(+0x148b44) [0x7f8668a5fb44]
/usr/lib/libruby-1.9.1.so.1.9(+0x14e439) [0x7f8668a65439]
/usr/lib/libruby-1.9.1.so.1.9(rb_rescue2+0x16b) [0x7f866897674b]
/usr/lib/libruby-1.9.1.so.1.9(+0x13fcae) [0x7f8668a56cae]
/usr/lib/libruby-1.9.1.so.1.9(+0x14c93e) [0x7f8668a6393e]
/usr/lib/libruby-1.9.1.so.1.9(+0x143f61) [0x7f8668a5af61]
/usr/lib/libruby-1.9.1.so.1.9(+0x148b44) [0x7f8668a5fb44]
/usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval_main+0xb1) [0x7f8668a66c81]
/usr/lib/libruby-1.9.1.so.1.9(+0x5ecca) [0x7f8668975cca]
/usr/lib/libruby-1.9.1.so.1.9(ruby_exec_node+0x1d) [0x7f86689762ed]
/usr/lib/libruby-1.9.1.so.1.9(ruby_run_node+0x1e) [0x7f8668977e3e]
/usr/bin/ruby1.9.1(main+0x4b) [0x40092b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xff) [0x7f8667ab9eff]
/usr/bin/ruby1.9.1() [0x400819]

@hadmut
hadmut commented Oct 6, 2011

with require 'mysql2':

-- C level backtrace information -------------------------------------------
/usr/lib/libruby-1.9.1.so.1.9(rb_vm_bugreport+0x5f) [0x7f779963e58f]
/usr/lib/libruby-1.9.1.so.1.9(+0x5a7be) [0x7f77995457be]
/usr/lib/libruby-1.9.1.so.1.9(rb_bug+0xa6) [0x7f7799546136]
/usr/lib/libruby-1.9.1.so.1.9(rb_check_type+0x16c) [0x7f7799547edc]
/home/hadmut/.gem/gems/mysql-2.8.1/lib/mysql_api.so(+0x70c5) [0x7f7793af60c5]
/usr/lib/libruby-1.9.1.so.1.9(+0x14c93e) [0x7f779963793e]
/usr/lib/libruby-1.9.1.so.1.9(+0x143f61) [0x7f779962ef61]
/usr/lib/libruby-1.9.1.so.1.9(+0x148b44) [0x7f7799633b44]
/usr/lib/libruby-1.9.1.so.1.9(+0x149c0b) [0x7f7799634c0b]
/usr/lib/libruby-1.9.1.so.1.9(rb_class_new_instance+0x30) [0x7f7799588520]
/usr/lib/libruby-1.9.1.so.1.9(+0x14c93e) [0x7f779963793e]
/usr/lib/libruby-1.9.1.so.1.9(+0x143f61) [0x7f779962ef61]
/usr/lib/libruby-1.9.1.so.1.9(+0x148b44) [0x7f7799633b44]
/usr/lib/libruby-1.9.1.so.1.9(+0x14e439) [0x7f7799639439]
/usr/lib/libruby-1.9.1.so.1.9(rb_rescue2+0x16b) [0x7f779954a74b]
/usr/lib/libruby-1.9.1.so.1.9(+0x13fcae) [0x7f779962acae]
/usr/lib/libruby-1.9.1.so.1.9(+0x14c93e) [0x7f779963793e]
/usr/lib/libruby-1.9.1.so.1.9(+0x143f61) [0x7f779962ef61]
/usr/lib/libruby-1.9.1.so.1.9(+0x148b44) [0x7f7799633b44]
/usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval_main+0xb1) [0x7f779963ac81]
/usr/lib/libruby-1.9.1.so.1.9(+0x5ecca) [0x7f7799549cca]
/usr/lib/libruby-1.9.1.so.1.9(ruby_exec_node+0x1d) [0x7f779954a2ed]
/usr/lib/libruby-1.9.1.so.1.9(ruby_run_node+0x1e) [0x7f779954be3e]
/usr/bin/ruby1.9.1(main+0x4b) [0x40092b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xff) [0x7f779868deff]
/usr/bin/ruby1.9.1() [0x400819]

@johannesh

( ruby and rails once had a much better code quality...)

@hadmut, What are you basing this comment on?

@jeremy
Ruby on Rails member
jeremy commented Oct 9, 2011

Those crashes are due to using a gem compiled on Ruby 1.8.7 with Ruby 1.9.

Get your gem installs sorted out and you should be fine.

@jeremy jeremy closed this Oct 9, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.