Mysql2 (0.3.2) is not shipped with the ActiveRecord adapter, as it is now part of Rails 3.1

Hi, I am using rails version 3.0.7 when I start the rails by creating a model name: string i m gets the following warning

WARNING: This version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it now part of Rails 3.1 WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `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 /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection' from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection' from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/railtie.rb:59 from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook' from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks' from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:42:in `each' from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks' from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/base.rb:1904 from /home/sun/railsapp/dog/vendor/plugins/attribute_fu/init.rb:1 from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/plugin.rb:81 from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `run_initializers' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `send' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing' from /home/sun/railsapp/dog/config/environment.rb:5 from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:103:in `require' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:103:in `require_environment!' from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:16 from script/rails:6:in `require' from script/rails:6 

when I try to install activerecord-mysql2-adapter: gem install activerecord-mysql2-adapter ERROR: Could not find a valid gem "activerecord-mysql2-adapter" (> = 0) in any repository

please help me thanks

+32
mysql ruby-on-rails-3
Apr 30 2018-11-11T00:
source share
5 answers

The problem is that you are trying to install the latest version of mysql2, which is not compatible with rails 3.0.x

SO, in your Gemfile, change the line for mysql2 gem for this:

 gem 'mysql2', '< 0.3' 

then bundle command

and then when the new mysql2 gem file (I think it is 0.2.7), you will solve the problem

+90
Apr 30 2018-11-18T00:
source share

if still not working, try this too:

 sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Users/YOUR_USER_NAME/.rvm/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle 
+2
Sep 11 '11 at 10:25
source share

gem 'mysql2', '<0.3' is the only way for Rails 3.0.7 (up to 3.1)

UPDATE: sorry, this is also not the case, does not work, there is a better way:

vendor / bundle / ruby ​​/1.9.1/gems/mysql2-0.3.2/lib/active_record/connection_adapters $ [rails307] $ ls em_mysql2_adapter.rb mysql2_adapter.rb

take the mysql2_adapter.rb file from mysql2 gem version 0.2.x and copy it to the specified location

now it works for me only with gem 'mysql2' in the gemfile

+1
May 6 '11 at 10:40
source share

After trying the solution suggested by @eveevans, I still had version issues. Then, after reading the @rubyconvict sentence, I thought instead of using the -v option for gem, rather than pushing files.

Here is what I found eventually resolving my fight against the awful "mysql2 (0.3.2) message" on DreamHost:

 # in mysql, create example_app & example_app_test ... # ... for the purposes of this example only, production == development db rails new example_app --database=mysql --freeze cd example_app vim config/database.yml # change settings for host, user, password ... # ... database for test (example_app_test) ... # ... & database for production & development (example_app) vim Gemfile # gem 'mysql2', '< 0.3' gem uninstall mysql2 # if installed: gem list -d mysql2 gem install mysql2 -v 0.2.7 rake db:migrate 

From there, I can switch to another RoR fun, for example, perhaps change routes (vim config / routes.rb ... however your mileage may vary).

+1
May 15 '11 at 15:12
source share

WARNING: use 0.2.x if you plan to use it in Rails <= 3.0.x

so briefly use the latest version in the 0.2.x branch for the mysql2 gem.

0
Apr 30 '11 at 9:08
source share



All Articles