1

I just meet one uninitialized constanterror,I have no idea on it now.Please save my day.

I'm trying to use mongodb & mysql2 simultaneously.Mongodb was OK.Now I want to add mysql2 gem into my project.

After gem install mysql2 -- --srcdir=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config and add mysql2 into Gemfile.

When I restart server,it gives me this error:

/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:12:in `<class:Client>': uninitialized constant Mysql2::Client::REMEMBER_OPTIONS (NameError)
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:2:in `<module:Mysql2>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:1:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2.rb:10:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2.rb:10:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `block in require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
    from /Users/Liber/ktv/trunk/config/application.rb:11:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

how Can i fix this guy? thank you.

 <class:Client>': uninitialized constant Mysql2::Client::REMEMBER_OPTIONS (NameError)

---------------------------Solution----------------------------

Just

brew install mysql

DO NOT use DMG file to install mysql

and then :

sudo gem install mysql2 --with-mysql-config=/usr/local/mysql/bin/mysql_config

Everything is OK now.

Thanks @BenjaminTan

GSLiPt
  • 201
  • 3
  • 6

1 Answers1

0

You should check out this link, which outlines nicely how to setup MySQL on Mountain Lion. The main takeway is to rely on brew install rather than the dmg file, as the OP has mentioned.

Community
  • 1
  • 1
Benjamin Tan Wei Hao
  • 9,621
  • 3
  • 30
  • 56
  • of course....../usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.5.27, for osx10.6 (i386) using readline 5.1 – GSLiPt Aug 26 '12 at 05:18
  • Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.---------------but it also is uninitialized constant – GSLiPt Aug 26 '12 at 05:38
  • is it possible that I use OSX10.8.1,but mysql is only for OSX10.6? – GSLiPt Aug 26 '12 at 05:46
  • 1
    Just brew install mysql > DO NOT use DMG file to install mysql and then : sudo gem install mysql2 --with-mysql-config=/usr/local/mysql/bin/mysql_config Everything is OK now. Thanks @BenjaminTan – GSLiPt Aug 26 '12 at 07:38