2

Problem Solved: The MySQL 2.8.1 Gem does not play well with MySQL 5.5.x

The solution was to uninstall MySQL (using instructions available here). And then install MySQL 5.1.56 using the x86_64 installer from MySQL.com

I reset my .rvm folder permissions as suggested below and then installed the MySQL gem according to the instructions at RVM's site.

Success!

Original Question:

I am running:

  • OSX 10.6.7 on a Core2Duo 64Bit Macbook Air
  • RVM 1.6.5
  • ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.0], MBARI 0x6770, Ruby Enterprise Edition 2011.03 / Mach-O 64-bit executable x86_64 (This Ruby version is set as --default)
  • MySQL 5.5.11 / Mach-O 64-bit executable x86_64 (Installed using MySQL.com DMG installer)

I've attempted to install the MySQL gem using every command on the net. Running rake db:migrate yields the error uninitialized constant MysqlCompat::MysqlRes

The following install commands all result with uninitialized constant MysqlCompat::MysqlRes

  1. rvmsudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
  2. sudo env ARCHFLAGS="-arch x86_64" rvmsudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
  3. sudo env ARCHFLAGS="-arch x86_64" rvmsudo gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include

And these commands don't even install. I just receive this error: Permission denied - /Users/Jake/.rvm/gems/ree-1.8.7-2011.03/gems/mysql-2.8.1/COPYING

  1. gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
  2. env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
  3. sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
  4. sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include

I have also placed rvm_archflags="-arch x86_64" in ~/.rvmrc. It had no effect.

I have imploded RVM and started from scratch twice. I've uninstalled and re-installed MySQL as well.

What am I doing wrong? What else can I try? Thank you for your help!

Community
  • 1
  • 1
Jake
  • 25
  • 3
  • "uninitialized constant MysqlCompat::MysqlRes" kind of smells like your database.yml file isn't right. I suspect that because that is what defines your database type (MySQL, Postgresql, etc.) Rails should read that information and automatically use the right gem, which should automatically include the `MysqlCompat::MysqlRes` constant. – the Tin Man May 02 '11 at 20:34

3 Answers3

1

Rule #1, when working with RVM. Do NOT use sudo.

DO NOT use sudo...

to work with RVM gems. When you do sudo you are running commands as root, another user in another shell and hence all of the setup that RVM has done for you is ignored while the command runs under sudo (such things as GEM_HOME, etc...). So to reiterate, as soon as you 'sudo' you are running as the root system user which will clear out your environment as well as any files it creates are not able to be modified by your user and will result in strange things happening. (You will start to think that someone has a voodoo doll of your application...)

Your permissions are all screwed up because you used sudo, so, you have to fix that:

sudo chown -R Jake ~/.rvm

should restore ownership of all the files to you.

Following that, follow the directions on the RVM site for dealing with MySQL. Do NOT follow directions all over the internet, because nobody knows better than the author of RVM when it comes to making things work with it.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
1

try this

cd `rvm gemdir`
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Alex Chien
  • 41
  • 3
0

In the future, you may want to try using Homebrew to install mysql. Here are some full-proof installation steps that I've run many times on OS X:

http://michaelfarmer.info/preferred-rails-3-and-mysql-installation-on-o

Mike Farmer
  • 2,992
  • 4
  • 28
  • 32