RuntimeError with mysql2 and rails3 (bundler)

2019-01-21 06:14发布

I get this error

`establish_connection': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError)
  from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord-

Here is dump of whole error and my config and gemfile.

11条回答
来,给爷笑一个
2楼-- · 2019-01-21 06:45

I had the same error after upgrading from Ubuntu 11.10 to 12.04. This is how I fixed the problem:

gem uninstall mysql2
bundle

I think the key here is the 'native extensions' -- I suppose when I installed last, I was using a different version of mysql.

Installing mysql2 (0.3.11) with native extensions
查看更多
冷血范
3楼-- · 2019-01-21 06:45

Same issue for me too. Upgraded to Rails 3.1.rc4 then downgraded to 3.0.3. Worked for me.

查看更多
在下西门庆
4楼-- · 2019-01-21 06:45

as of 0.3.0, and ActiveRecord 3.1 - the ActiveRecord adapter has been pulled out of this gem and into ActiveRecord itself. If you need to use mysql2 with Rails versions < 3.1 make sure and specify gem "mysql2", "~> 0.2.7" in your Gemfile

the missing file (no such file to load) can be found in the pre 0.3.0 versions of mysql2.

quoted from the documentation of mysql2

查看更多
SAY GOODBYE
5楼-- · 2019-01-21 06:46

This also fixed the issue I had with:

Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter)

You actually need to run: gem install mysql2 and add the gem to your config.

查看更多
Root(大扎)
6楼-- · 2019-01-21 06:49

I was getting the same error while using rails 3.0.7 and mysql2 0.3.2. The solution, which I found here, is to use an older version of mysql2. Thus edit your gemfile to

gem 'mysql2', '< 0.3'

and run

bundle install 
查看更多
Fickle 薄情
7楼-- · 2019-01-21 06:51

Did you include the mysql2 gem in your gemfile instead of the old mysql gem, and ran bundle install afterwards?

查看更多
登录 后发表回答