Shyam Visamsetty
Shyam Visamsetty

Reputation: 444

Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (mysql2 is not part of the bundle. Add it to Gemfile.) (LoadError)

I get the folllowing error when starting my rails server using WEBrick on Windows 7:

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integ ration.rb:214:in block in replace_gem': Please install the mysql2 adapter:gem install activerecord-mysql2-adapter` (mysql2 is not part of the bundle. Add it to Gemfile.) (LoadError)

I have made sure the database.yml had adapter as mysql2, gemfile lists mysql2. Below is my database.yml file and also gem file

    development:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: elearn3_development
      pool: 5
      username: root
      password: password
      host: 127.0.0.1
      port: 3306

    test:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: elearn3_test
      pool: 5
      username: root
      password: passsword
      host: 127.0.0.1
      port: 3306

    production:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: elearn3_production
      pool: 5
      username: root
      password: passsword
      host: 127.0.0.1
      port: 3306

Gem file: source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
    end

gem 'jquery-rails'

I have tried all the various options posted in other threads having the same issue, such as adding gem 'mysql2' 'version no'. It does not resolve the issue. I have the same issue while issuing sql-lite also.

Your help is appreciated. Thanks in advance.

EDIT: When I run bundle install, I get the following in the window. Please observe that mysql2 is not part of the using list. Is that normal?

    Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.7.2)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.2)
Using tilt (1.4.0)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Using json (1.7.7)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using coffee-rails (3.2.2)
Using jquery-rails (2.2.1)
Using bundler (1.3.5)
Using rails (3.2.13)
Using sass (3.2.8)
Using sass-rails (3.2.6)
Using uglifier (2.0.1)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

EDIT After trying the instructions from http://www.mohanarun.com/how-to-install-mysql-adapter-ruby-gem-in-windows/, I see that bundle install is picking up mysql. But, I get the following erros, when I do rails server.

/* many more errors before */

pport/core_ext/load_error.rb 369 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/name_error.rb 370 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/uri.rb 371 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_contr oller.rb 372 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_view/ railtie.rb 373 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_con troller/railties/routes_helpers.rb 374 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_contr oller/railties/paths.rb 375 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_contr oller/railtie.rb 376 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_rec ord/railtie.rb 377 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-3.2.13/lib/action_mai ler/version.rb 378 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/class/delegating_attributes.rb 379 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/module/reachable.rb 380 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/class/subclasses.rb 381 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/class.rb 382 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/array/uniq_by.rb 383 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-3.2.13/lib/action_mai ler.rb 384 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-3.2.13/lib/action_mai ler/railtie.rb 385 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activeresource-3.2.13/lib/active_r esource/exceptions.rb 386 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activeresource-3.2.13/lib/active_r esource/version.rb 387 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activeresource-3.2.13/lib/active_r esource.rb 388 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activeresource-3.2.13/lib/active_r esource/railtie.rb 389 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/test_uni t/railtie.rb 390 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/sprockets/ra iltie.rb 391 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/all.rb 392 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/string_inquirer.rb 393 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/version.r b 394 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/error.rb 395 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/result.rb

[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: bugreport

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

Upvotes: 0

Views: 10677

Answers (3)

user2638707
user2638707

Reputation: 316

Make Sure to Add Following to your Gemfile:

gem 'mysql'
gem 'mysql2', "~> 0.3.10"

Then run

bundle install

Question is too old but this may help others.

Upvotes: 3

carbonr
carbonr

Reputation: 6067

The same problem happened in Production and the following was the problem.

  1. Had to move sqlite gem to development in Gemfile
  2. Had to add mysql2 gem to deployment in Gemfile
  3. Had to run bundle install to update Gemlock
  4. Had to commit these changes to git and update remote git repo.

These were steps quite specific to my production setup but i hope they would be helpful for someone else as well.

Upvotes: 0

jsvisa
jsvisa

Reputation: 3227

After you modified Gemfile and bundle install, you should have restart Rails server, which can reload the bundle gems

Upvotes: 0

Related Questions