Error: uninitialized constant MysqlCompat::MysqlRes

To fix this, specify ARCHFLAGS when you install the 'mysql' gem:

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

This didn't seem to fix the error for me. I still get 'uninitialized constant MysqlCompat::MysqlRes'

Kyle Fox wrote:

To fix this, specify ARCHFLAGS when you install the 'mysql' gem:

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

On Aug 27, 12:07�pm, Caleb Cullen <rails-mailing-l...@andreas-s.net>

cheers,

I also built the gem with the archflags, but am still getting this error. Did anyone find a different reason that might be causing this?

Anybody still has the issue?

I have been using jruby for a while but today I was trying to setup using the last version of ruby 1.9 and rails 2.3.4 and I got hit with that.

Also running centos and tried the ARCHFLAGS trick with no success.

Pishty Ags wrote:

Actually, doing more research and an strace on the process I found the problem.

Looking in the wrong place for the location of the library, I added my mysql lib directory to ld.so.conf/mysql.conf config file and it fixed it.

Jean Bombeur wrote:

I was having the same problem on Snow Leopard and, after some time I did the following:

Removed all mysql gems I had:

gem uninstall mysql

In my case I had to specify both mysql-dir and mysql-config (and -arch x86_64 to 64 bits)

export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc -- no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/ local/mysql/bin/mysql_config

Hope it works

Hi

************* URGENT PLEASEEEEEEEEEEEEEEEEEEEEEEEEEE *********** I still see the problem after following the above steps. Please please help me.

~Sam.

=========================================================================== === ruby script/server => Booting Mongrel => Rails 2.3.4 application starting onhttp://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server /!\ FAILSAFE /!\ Mon Oct 12 17:15:15 -0700 2009 Status: 500 Internal Server Error uninitialized constant MysqlCompat::MysqlRes /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/de p endencies.rb:440:in `load_missing_constant' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/de p endencies.rb:80:in `const_missing' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/mysql_adapter.rb:9:in `define_all_hashes_method!' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/mysql_adapter.rb:66:in `mysql_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:223:in `send' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:223:in `new_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:188:in `checkout' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:184:in `loop' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:184:in `checkout' /usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:183:in `checkout' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:98:in `connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:326:in `retrieve_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_specification.rb:123:in `retrieve_connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_specification.rb:115:in `connection' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/quer y _cache.rb:9:in `cache' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/quer y _cache.rb:28:in `call' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn e ction_adapters/abstract/connection_pool.rb:361:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/fa i lsafe.rb:26:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchro nize' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/di s patcher.rb:114:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/re l oader.rb:34:in `run' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/di s patcher.rb:108:in `call' /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:i n `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call' /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb: 1 7:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13: i n `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/chunked.rb:15:in `call ' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:61 : in `process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `proce ss_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `proce ss_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285 =========================================================================== ===

Jean Bombeur wrote: > Actually, doing more research and an strace on the process I found the > problem.

> Looking in the wrong place for the location of the library, I added my > mysql lib directory to ld.so.conf/mysql.conf config file and it fixed > it.

> Jean Bombeur wrote: >> Anybody still has the issue?

>> I have been using jruby for a while but today I was trying to setup >> using the last version of ruby 1.9 and rails 2.3.4 and I got hit with >> that.

>> Also running centos and tried the ARCHFLAGS trick with no success.

>> Pishty Ags wrote: >>> Evan Green wrote: >>>> This didn't seem to fix the error for me. I still get 'uninitialized >>>> constant MysqlCompat::MysqlRes'

>>>> Kyle Fox wrote: >>>>> To fix this, specify ARCHFLAGS when you install the 'mysql' gem:

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

>>>>> On Aug 27, 12:07 pm, Caleb Cullen <rails-mailing-l...@andreas-s.net>

>>>> cheers,

>>> on my Centos Machine, i had to install mysql-devel.x86_64 first, then i >>> ran the command:

>>> env ARCHFLAGS="-arch x86_64" gem install mysql -- >>> --with-mysql-config=/usr/lib64/mysql/mysql_config

>>> which did the trick.

>>> thanks Kyle

-- Posted viahttp://www.ruby-forum.com/.

Raphael Petegrosso wrote:

I was having the same problem on Snow Leopard and, after some time I did the following:

Removed all mysql gems I had:

gem uninstall mysql

In my case I had to specify both mysql-dir and mysql-config (and -arch x86_64 to 64 bits)

export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc -- no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/ local/mysql/bin/mysql_config

Hope it works

I was able to resolve this issue. Thanks for your valuable suggestions. Along with the above steps, I had to configure the LD_LIBRARY_PATH.

These instructions also worked for me after upgrading to Snow Leopard. In my case mysql was in /opt/local/lib/mysql5, so the following fixed it for me:

sudo gem uninstall mysql

export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config

had the same, switching to 2.7 helps sudo gem install mysql -v 2.7

grosser.michael wrote:

had the same, switching to 2.7 helps sudo gem install mysql -v 2.7

On 22 Okt., 17:33, Caleb Cullen <rails-mailing-l...@andreas-s.net>

I was able to install the mysql v. 2.7 gem on a macport mysql version with:

sudo gem install -v 2.7 --no-rdoc --no-ri mysql -- --with-mysql-dir=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config;

If you are still getting this issue, I have posted an EXPLANATION as well as how to derive the correct solution for your system here http://techliberty.blogspot.com/ the EXPLANATION was to long for a forum post :slight_smile:

This article got it done for me:

Pishty Ags wrote:

Evan Green wrote:

This didn't seem to fix the error for me. I still get 'uninitialized constant MysqlCompat::MysqlRes'

Kyle Fox wrote:

To fix this, specify ARCHFLAGS when you install the 'mysql' gem:

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

On Aug 27, 12:07�pm, Caleb Cullen <rails-mailing-l...@andreas-s.net>

cheers,

on my Centos Machine, i had to install mysql-devel.x86_64 first, then i ran the command:

env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config

which did the trick.

thanks Kyle

I use Centos , but it's i386 . So I installd mysql-devel,and use the command: env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/lib/msyql/mysql_config", and it did the work , Aha!

For all you folks who couldn't get this to work on Snow Leopard inspite of trying the ridiculously simple solution(s) mentioned above,

Try this: Re compile ruby. Then do

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

This will ensure that the *right* arch of ruby is used to compile the native extensions.

Nikhil Gupte wrote:

For all you folks who couldn't get this to work on Snow Leopard inspite of trying the ridiculously simple solution(s) mentioned above,

Try this: Re compile ruby. Then do

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

This will ensure that the *right* arch of ruby is used to compile the native extensions.

and how do you recompile Ruby...

New to the OSX platform...

Thanks.

I went through this within the last two days. Might be useful to see my write up here, too:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/37b593be608e2461/1ace7ea9d30ef28a#1ace7ea9d30ef28a

Jean,

Best is to install macports, if you aren't already using it.

To re-compile ruby, run:

sudo port install ruby

Nikhil Gupte wrote:

Jean,

Best is to install macports, if you aren't already using it.

To re-compile ruby, run:

sudo port install ruby

I was able to get mysql gem to install on OSX Leopard without warnings with the --no-rdoc and --no-ri switches; archflags likewise eliminated the uninitialized constant error:

sudo gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

That hasn't made my installation functional however. I just rebuilt my entire project with rails myApp -d mysql; I then scaffolded 5 sets of tables (i.e. script/generate scaffold tablename c_code:string c_name:string tran_id:integer priority:integer); I next drag the project directory onto XCode Organizer; create the start server script (script/server); and start the gem server in terminal: gem server.

Fine and dandy so far (seemingly). Then I run rake db:migrate to engender the following error:

iMacMike:pfmpe mikemontagne$ rake db:migrate --trace (in /Users/mikemontagne/rproj/pfmpe) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! Unknown database 'pfmpe_development'

iMacMike:pfmpe mikemontagne$ rake db:migrate --trace

Unknown database 'pfmpe_development'

database.yml indicates that this is supposed to be the development database. But no such file exists in my project directory.

What file would you expect? This refers to a database, physical location dependent on your MySQL configuration.

Is this a MySQL server configuration issue? Does anybody understand why this table is not being created?

Perhaps you left out the step where you create it? At least I didn't see it in your post. You can create databases manually through the MySQL CLI console or a number of other tools, or you can run the appropriate rake task. `rake -T` will give you a list of the available tasks.

But you *do* have to create it before running your migrations :slight_smile:

HTH,