drhanlau
drhanlau

Reputation: 2527

MySql2 on Rails 3.0.3 on Mac OS X

I know this has been asked many times by different other users with similar problem, but I can't seems to find one that are similar to my case:

My specs:

OS - Mac OSX 10.6 Snowleopard
SQL Server - MySQL 5.5
Rails - 3.0.3
Ruby 1.8.7

While try to run a rake db:create, I run into the following error message:

"uninitialized constant Mysql2" 

Full trace is posted if you are interested:-

** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
uninitialized constant Mysql2
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:64:in `create_database'
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:33
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Upvotes: 1

Views: 2090

Answers (2)

Mauro De Giorgi
Mauro De Giorgi

Reputation: 394

Same configuration, same problem here...

Edit: Solved! Had to add gem 'mysql2' to the Gemfile and run bundle install. Now it works fine.

Upvotes: 4

Kevin Sylvestre
Kevin Sylvestre

Reputation: 38012

Try:

sudo gem install mysql2
bundle install

Upvotes: 0

Related Questions