Error: uninitialized constant MysqlCompat::MysqlRes

Hi,

I’ve found the way to install gem with mysql 5.5x on Snow Leopard.
Solution is described at:

So just modify DYLD_LIBRARY_PATH and it will work - at least it fixed
issue on my side

Hope that helps.

Mariusz Nowak

guilherme p. wrote in post #985453:

Hi,

After all attempts. I simply uninstall mysql 5.5.9 (64 bits) and all
mysql gems.

Then install Mysql 5.1.55 (64 bits) and

“sudo env ARCHFLAGS=”-arch x86_64" gem install mysql – --with-mysql-
config=/usr/local/mysql/bin/mysql_config"

and it works on MAC…

Hope it helps.

Matthew Werner wrote in post #982105:

Hi All,

This has been the most thorough discussion of the topic I’ve found. I’ve
spent far too much time trying to get this stupid gem to work. I’m going
to post the information i’ve got and I’m praying someone out there will
be able to help me.

ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
mysql --version
mysql Ver 14.14 Distrib 5.5.9, for osx10.6 (i386) using readline 5.1
rails -v
Rails 2.3.5
sudo gem uninstall mysql
Successfully uninstalled mysql-2.8.1

Here is where I’ve seen so so (SO) many different recommendations on
what to do. I’ve tried damn near everything, both sudo and not,
specifying my arch flags and not. I’ll just go with the most thorough:

export ARCHFLAGS=“-arch i386” ; sudo gem install --no-rdoc --no-ri mysql –
–with-mysql-dir=/usr/local
–with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.8.1
1 gem installed

rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
=> Environment: Development
** Execute db:migrate
rake aborted!
uninitialized constant MysqlCompat::MysqlRes

/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in

`load_missing_constant’

/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in

`const_missing’

/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/mysql_adapter.rb:9:in

`define_all_hashes_method!’

I’m lost on what else it could be. I feel like I’ve tried every
combination. I’ve tried reinstalling ruby, 64bit of mysql, please help.
I’m out of ideas.

After wrestling with this problem for several days I finally got it
nailed. 2 things that I have done that made it work:

  1. sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri
    mysql – --with-mysql-config=/usr/local/mysql/bin/mysql_config
  2. export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

I’m on Snow Leopard, and have only 1 MySQL (x86_64) 5.5, and 1 ruby
(prepackaged with Snow Leopard) installed.

If you have tried all the above and it still didn’t work, try the
instructions on THIS page:

It worked for me! (Don’t forget to use the “source” command or restart
your terminal session after modifying your bash profile.)

Hi All,

This has been the most thorough discussion of the topic I’ve found. I’ve
spent far too much time trying to get this stupid gem to work. I’m going
to post the information i’ve got and I’m praying someone out there will
be able to help me.

ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
mysql --version
mysql Ver 14.14 Distrib 5.5.9, for osx10.6 (i386) using readline 5.1
rails -v
Rails 2.3.5
sudo gem uninstall mysql
Successfully uninstalled mysql-2.8.1

Here is where I’ve seen so so (SO) many different recommendations on
what to do. I’ve tried damn near everything, both sudo and not,
specifying my arch flags and not. I’ll just go with the most thorough:

export ARCHFLAGS="-arch i386" ; sudo gem install --no-rdoc --no-ri mysql –
–with-mysql-dir=/usr/local
–with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.8.1
1 gem installed

rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
=> Environment: Development
** Execute db:migrate
rake aborted!
uninitialized constant MysqlCompat::MysqlRes
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in
load_missing_constant' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:inconst_missing’
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/mysql_adapter.rb:9:in
`define_all_hashes_method!’

I’m lost on what else it could be. I feel like I’ve tried every
combination. I’ve tried reinstalling ruby, 64bit of mysql, please help.
I’m out of ideas.