can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2 in Rails 3.1

can definition
can synonym
can.'' acronym
can band
meaning of can in hindi
can y
can pronunciation

I'm just trying to get the most basic of basic shell of a rails app running under 3.1, and I'm getting this weird error when I run bundle exec rake db:migrate-

Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2. Make sure all dependencies are added to Gemfile.)

All the posts that I've read here and elsewhere say I should be using the newer mysql2 adaptor for rails 3.1, so I have-

gem 'mysql2', '0.3.2'

in my gemfile. Some post have suggested using-

gem 'mysql2', '~> 0.3'

but that gets me the same error. The gem is installed at-


It was suggested that I switch up that line in my gemfile again, this time to be-

gem 'mysql2', '< 0.3'

but when I do that, run bundle install, and then try to run migrations again, I get-

An error has occurred, all later migrations canceled:
undefined method `rows' for nil:NilClass

My complete migration file looks like this-

class CreatePlaces < ActiveRecord::Migration
  def change
    create_table :places do |t|
      t.string :title
      t.string :meta_description
      t.string :permalink, :limit => 60
      t.string :name, :limit => 60
      t.string :address
      t.string :state, :limit => 2
      t.string :region, :limit => 3
      t.float :latitude
      t.float :longitude
      t.text :description
      t.boolean :active, :default => true

    add_index :places, [:permalink, :state, :region, :latitude, :longitude, :active], :name => 'places_index'

And the full output of running that migration is-

==  CreatePlaces: migrating ===================================================
-- create_table(:places)
   -> 0.0925s
-- add_index(:places, [:permalink, :state, :region, :latitude, :longitude, :active], {:name=>"places_index"})
   -> 0.1097s
==  CreatePlaces: migrated (0.2023s) ==========================================

rake aborted!
An error has occurred, all later migrations canceled:

undefined method `rows' for nil:NilClass

There are no later migrations, that's the only one, as this is an app that I'm just starting to try to get Rails 3.1 running properly. Dropping the database and recreating it gets me to the same place.

I am able to access Places from the console-

ruby-1.9.2-p180 :001 > Place
   (0.3ms)  SHOW TABLES
   (0.1ms)  SHOW TABLES
   (1.1ms)  describe `places`
 => Place(id: integer, title: string, meta_description: string, permalink: string, name: string, address: string, state: string, region: string, latitude: float, longitude: float, description: text, active: boolean, created_at: datetime, updated_at: datetime) 

But when I actually try to do a find or anything on Places, I get the following error-

ArgumentError: wrong number of arguments (3 for 2)
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/mysql2-0.2.7/lib/active_record/connection_adapters/mysql2_adapter.rb:634:in `select'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/activerecord-3.1.0.rc5/lib/active_record/connection_adapters/abstract/database_statements.rb:9:in `select_all'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/activerecord-3.1.0.rc5/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:470:in `find_by_sql'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/activerecord-3.1.0.rc5/lib/active_record/relation.rb:111:in `to_a'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/activerecord-3.1.0.rc5/lib/active_record/relation/finder_methods.rb:155:in `all'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/activerecord-3.1.0.rc5/lib/active_record/relation/finder_methods.rb:105:in `find'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:437:in `find'
    from (irb):2
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:45:in `start'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:8:in `start'
    from /Users/mark/.rvm/gems/ruby-1.9.2-p180@rails310pre/gems/railties-3.1.0.rc5/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Anyone have any ideas? I've been digging for like 18 hours now, and just running in circles.

Thanks, --Mark

Active Record has it's own requirements on which versions of mysql2 are compatible. Here's the line of code for Rails 3.1. You must use a version of mysql2 that satisfies these requirements.

Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2. Make sure all dependencies are added to Gemfile.)

This is saying Rails expects a mysql2 version greater than 0.3.6 and less than 0.4.0, but found version 0.3.2. If you change your Gemfile to request a version in this range then Active Record should be happy. Perhaps

gem 'mysql2', '0.3.6'

Don't forget to update your bundle after changing your Gemfile.

bundle update mysql2

Can, Can was the leading avant-garde rock group of the 70s. Can experimented with noise, synthesizers, non-traditional music, cut-and-paste techniques, and, most  Can definition, to be able to; have the ability, power, or skill to: She can solve the problem easily, I'm sure. See more.

This also had me pulling out my hair. To only reasonable solution I could get was to switch to the master branch of the mysql2 gem.

gem 'mysql2', :git => 'git://'

After this update my Rails 3.1.0.rc5 application could start with MySQL. (At the time of this post the latest version of the gem was 0.3.6)

Can, VerbEdit. can (third-person singular simple present can, present participle -, simple past could, past participle (obsolete except in  Define can. can synonyms, can pronunciation, can translation, English dictionary definition of can. to be able to, have the power or skill to: I can take a bus to the

I know this is a very old thread but because it still comes up in Google results a one of the first results I though I would updated it with I had to do work around this issue in newer versions of Rails.

The errors shows as:

Gem::LoadError: Specified 'mysql2' for database adapter, 
but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile 

followed by:

Gem::LoadError: can't activate mysql2 (< 0.5, >= 0.3.13), 
already activated mysql2-0.5.2. Make sure all dependencies are 
added to Gemfile.

I already had the gem added in my Gemfile as shown below:

group :production do
  gem 'mysql2'

but I had to update it to prevent from picking up a version outside of the range indicated in the error message. Notice the '< 0.5' below:

group :production do
  gem 'mysql2', '< 0.5'

Additionally, different versions of Rails set different min/max version restrictions for the MySQL gem:


"Correct, Rails 4.x cannot use mysql2 0.5.x. The actual code would work fine, but Rails 4 has a version restriction in place to prevent use of mysql2 0.5.x. This is intentional, as it allows future changes to the API without silently risking their use in older code not prepared to use the new APIs. There's also nothing magic about the version numbers -- it's totally by coincidence that Rails 4 uses mysql2 0.4 and Rails 5 will be able to use mysql2 0.4 or 0.5."

The Official CAN / Spoon Records Website, can meaning: 1. to be able to: 2. used to say that you can and will do something: 3. to be allowed to: . Learn more. A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer. It is a message-based protocol , designed originally for multiplex electrical wiring within automobiles to save on copper, but can also be used in many other

Pretty old question, so I'm assuming the original poster has already solved the issue. However, in case anyone is coming to this post trying to solve the first issue:

Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2. Make sure all dependencies are added to Gemfile.)

This is most likely occurring because you are not running your migrations via bundle exec. Try running bundle exec rake db:migrate.

can, What does can mean? can is defined by the lexicographers at Oxford Dictionaries as Be able to., Be permitted to., Used to request someone to do something. 110 synonyms of can from the Merriam-Webster Thesaurus, plus 97 related words, definitions, and antonyms. Find another word for can. Can: to bring (as an action or operation) to an immediate end.

CAN, Usage Problem Used to request or grant permission: Can I be excused? [Middle English, first and third person sing. present tense of connen, to know how,  Can (stylised as CAN) was a German experimental rock band formed in Cologne in 1968 by the core quartet of Holger Czukay (bass, tape editing), Irmin Schmidt (keyboards), Michael Karoli (guitar), and Jaki Liebezeit (drums).

Can, A can is a metal container in which something such as food, drink, or paint is put. The container is usually sealed to keep the contents fresh. Several young men  Create beautiful designs with your team. Use Canva's drag-and-drop feature and layouts to design, share and print business cards, logos, presentations and more.

Can, The definition of a can is a container normally made of metal with a lid. An example of can is what tuna comes in. verb. Can means someone or something knows  We would like to show you a description here but the site won’t allow us.

  • Are you sure that in migration file its def change instead of def self.up ??
  • Yes, that's new 3.1 syntax. Up and down have been eliminated. See… for details.
  • Armand, thanks for looking into this! When I add that line to my gemfile and run bundle install, I get the following error upon trying to access the app: "git:// (at master) is not checked out." Any other ideas would be appreciated!
  • I was having the exact same issue as the op and this fixed it. Thanks Armand.