Accidental Technologist

Musings about Entrepreneurship, Technology and Software Development

  • Home
  • About
  • Still River Software
  • Privacy Policy

Powered by Genesis

You are here: Home / Apple / Fixing Uninitialized Constant MysqlCompat::MysqlRes Error on Snow Leopard

Fixing Uninitialized Constant MysqlCompat::MysqlRes Error on Snow Leopard

November 25, 2009 by Rob Bazinet 40 Comments

Tweet

Recently I ran into a problem on my MacBook Pro running Snow Leopard when trying to connect to a MySQL database.  The current version of the gem (2.8.1) installed fine but when trying to use it, I received the following error:

uninitialized constant MysqlCompat::MysqlRes

When trying to spin up a Rails application on my Mac.  I am running Snow Leopard and already had the MySQL gem installed.  A bit of searching around the web led to some information that this is an issue to do with the MySQL driver, in particular mysql-2.8.1.  The explanation came from a thread on StackOverflow.com:

As it turns out, that class should not exist; the error message is caused by a problem with the latest Mysql driver. mysql-2.8.1 looked for my libraries in a directory named with an extra level of ‘mysql’ at the end. For instance, my libraries (under MacOS X 10.5.8), are in /usr/local/mysql/lib, but the mysql.bundle library looks for the MySQL libraries at /usr/local/mysql/lib/mysql … which is wrong.

I tried some of the suggestions in the thread which suggested a straight install of the MySQL 2.7 gem but the result was the same.  It seems things are treated a bit differently on OS X 10.5.x and 10.6.x because of the 64-bit goodness we now have, but I was able to resolve the issue.  The first step was to uninstall my current MySQL gem:

sudo gem uninstall mysql

The command is a bit long but we basically want to install the version 2.7 of the MySQL gem and tell it where the MySQL main directory is located as well as where the configuration is located.  This command should be entered in a single line from a Terminal prompt (broken up here for display purposes):

export ARCHFLAGS="-arch i386 -arch x86_64" ;sudo gem install --no-rdoc --no-ri 
-v=2.7 mysql -- --with-mysql-dir=/usr/local/mysql
--with-mysql-config=/usr/local/mysql/bin/mysql_config
Firing up the Rails application worked like a champ after the gem installed.  I would imagine there will be a fix for the MySQL gem 2.8.1 or maybe there is already a workaround I did not come across in my search.  MySQL is working Snow Leopard for my Rails applications, so I am happy.
 
Technorati Tags: MySQL,MySQL Gem,Ruby on Rails

Share this:

  • LinkedIn
  • Twitter
  • Facebook
  • Email
  • More
  • Pinterest
  • Tumblr
  • Pocket
  • Reddit

Related

Filed Under: Apple

Care about your privacy? I do and use Fathom Analytics on this site.

Fathom Analytics

Recent Posts

  • How to Fix Rails Flash Rendering When Using Hotwire
  • Hotwire Fix for CORS Error when using Omniauth
  • Fix Installation of Ruby using rbenv on macOS Big Sur
  • RailsConf 2021 and the Future of Conferences
  • Fixing Out of Diskspace Errors on Amazon EC2

Categories

Services I Love

HatchBox - Easy Rails Deploys Fathom Analytics
Follow @rbazinet

Rob Bazinet
@rbazinet

  • Exactly this…. https://t.co/yWj7fZ01HR
    about 18 hours ago
  • https://t.co/EmagdpLoNv "Introducing GitHub Copilot X · GitHub"
    about 1 day ago
  • RIP Gordon Moore: https://t.co/c5J9LaHrj8
    about 1 day ago
  • Our daughter works as a teaching assistant at a local K-8 public school. It’s become apparent that students today r… https://t.co/p2t912GVyc
    about 2 days ago
  • Working to wrap up my current consulting gig by mid-April. I will be looking for the next thing soon. If anyone has… https://t.co/sg3cSV9yqM
    about 3 days ago
  • RSS - Posts
  • RSS - Comments
Find me on Mastodon