Ruby/Rails and MySQL on Snow Leopard (10A380)
First get and install the 64bit MySQL version:
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.35-osx10.5-x86_64.dmg/from/pick#mirrors
Then install the MySQL gem the following way:
sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
This worked great for me however I would like to point out that copy-paste did not work on the gem install, I am guessing because of some special characters were inserted in the html.
If you type it out it will works great.
I am getting very close to getting *everything* working under 10.6.
Hmm, I have the devtools installed but I get:
$ sudo gem install mysql — –-with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql — –-with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
Ok, found a solution that seems to work:
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Thank you very much!
You could post more about making rails gems work on snow leopard
Hi Philipp, Thanks for your great post! Have you had any luck installing gems on Snow Leopard?
I get the following error when installing many of the tools, even after installing the new version of XCode
Building native extensions. This could take a while…
ERROR: Error installing jscruggs-metric_fu:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can’t find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/relevance-rcov-0.8.3.8 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/relevance-rcov-0.8.3.8/ext/rcovrt/gem_make.out
Cheers and thanks for the great post.
[...] down, however, it really is not all that difficult. I went through numerous blogs which had lots of information, but the end result of going through that was actually a hosing of my rails setup. [...]
Indeed a 64 bits version of MySQL is required, and this gem install line worked for me :
sudo env ARCHFLAGS=”-Os -arch x86_64 -fno-common” gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
You can use these flags for jscruggs-metric_fu too :
sudo env ARCHFLAGS=”-Os -arch x86_64 -fno-common” gem install jscruggs-metric_fu
Still trying to get Ruby Enterprise Edition working on Snow Leopard (bus error during compilation)
I’ve a problem using the procedure you’ve described.
Actually i’m using a MacBook Pro 3,1 that uses a 32bit kernel (due to EFI differences).
After downloading and installing the
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.37-osx10.5-x86_64.dmg/from/pick#mirrors
package i can’t build the gem with x86_64 arch.
The build succeded with this command:
sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
but wen i try to migrate i get uninitialized constant MysqlCompat::MysqlRes error.
I tryed with the x86 package but the same result, any help?
Thanks,
Matteo
I’m having the same problem as macteo above. The mysql 5.1 install worked fine, but I get “uninitialized constant MysqlCompat::MysqlRes” when I start server, migrate, or do anything that hits mysql.
I’m using the built in Apache and ruby (1.8.7 u-darwin)
Steve,
make sure you do the following:
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
if you do not tell gem to install with x86_64 it will throw the error you are getting.
I just installed Snow Leopard and am running into the same “uninitialized constant MysqlCompat::MysqlRes” error.
I installed 2.8.1 successfully:
lappy:~ loren$ sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –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
lappy:~ loren$ gem list –local mysql
*** LOCAL GEMS ***
mysql (2.8.1)
But I still get the error. I’m on 5.0.60sp1-enterprise-gpl.
I’m not sure how else to troubleshoot this.
Loren,
I had these same problems with MySQL on Snow Leopard this weekend. This site helped a lot:
http://codetocustomer.com/blog/2009/08/snow-leopard-for-open-source-devs
Here are some debugging tips:
$ file `which mysql`
/usr/local/bin/mysql: Mach-O 64-bit executable x86_64
If you see 32-bit then you need a fresh install of the x86_64 build. You may need to move the old 32-bit one out of the way.
$ file /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle: Mach-O 64-bit bundle x86_64
If you see the 32-bit version, you’ll have the symptoms about MysqlRes error. You need to reinstall the mysql gem:
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql –verbose — –with-mysql-config=/usr/local/mysql/bin/mysql_config
This helped me to confirm that the mysql gem was actually working:
$ irb
>> require ‘rubygems’
>> require ‘mysql_api’
>> Mysql.get_client_info
=> “5.0.85″
When I was mixing architectures, the above failed with an error about incompatible architectures.
Hope this helps!
Like others, I’m afraid nothing on this page was working. Found this page, though, which got everything working again:
http://void-design.net/2009/08/05/ruby-191-mysql-and-a-snow-leopard/
I’m almost there. Mysql x86 is up and running. Mysql gem 2.8.1 is installed, but I got the same error as this guy installing the mysql gem api documentation: http://pastie.org/pastes/592691
This results in the following error when I try to start mongrel:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:442:in `load_missing_constant’: uninitialized constant MysqlCompat::MysqlRes (NameError)
Anyone else having this issue?
Here’s the steps (4hrs later) that i did to get it work after suffering the dreaded “uninitialized constant MysqlCompat::MysqlRes” error
1. Installed the 64 bit version of MySQL
2. Installed the gems version of mysql adapter via
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql config=/usr/local/mysql/bin/mysql_config
This happily enabled a connection to the database.
I had looked over a number of other posts, which indicated needing to adjust the default character set and a host of other fixes. All which failed.
This is great info, but when I install the gem I get a list of methods that have no definition, and the gem doesn’t work… here’s a subset of what I’m seeing…
russell-fines-macbook-pro:~ mrfine$ sudo gem install mysql
Building native extensions. This could take a while…
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1…
No definition for next_result
No definition for field_name
No definition for field_table
No definition for field_def
No definition for field_type
No definition for field_length
No definition for field_max_length
No definition for field_flags
No definition for field_decimals
Any Help? PLEASE ?
I am getting same error as Russell. Anyone else have ideas on what might be happening?
My email address is ardorlan@gmail.com
I am looking for the fix to Russel and mike problem, for I have this same problem. My system is a clean install, I am trying to get my ruby mysql programs to work but the mysql gem will not install.
When fix is found, Please send me the email, Thanks
I fix the problem.
gem install mysql
it says, “Successfully installed mysql-2.8.1″
so I do, updatedb
then i do, locate mysql-2.8.1
which gives me
/var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/mysql_api.so
so I copy to my ruby program dir, cp /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/mysql_api.so ./
Then i must edit the require line of my program
require “./mysql”
becomes
require “./mysql_api”
Thank you all.
I fixed the MySQL gem compilation problem by installing SL clean and then installing MySQL from MacPorts.
I documented the process here: http://blog.twg.ca/2009/09/livin-on-the-edge-ruby-rails-and-snow-leopard
Check it out, hopefully it helps someone.
Hi all,
I just spent half a day banging my head against the wall trying to get my brand spanking Snow Leopard back on rails. I had to install Ruby manually to get things right, and in retrospect this was probably due to a previously installed local version under /usr/local
This recipe worked for me:
1. mysql-5.1.38-osx10.5-x86_64.dmg (installer)
2. readline-6.0.tar.gz
3. ruby-1.8.7-p174.tar.gz
4. rubygems-1.3.5.tgz
5. sudo gem install mysql
6. irb to test
For information on how to upgrade your MySQL databases (1) see:
http://dev.mysql.com/doc/refman/5.1/en/mysql-upgrade.html
For information on ruby prerequisite Readline (2) see section titled “Ruby” at:
http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx
For information on building Ruby and Rubygems (3, 4) see:
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/
Finally, here’s the “gem install” (5) that worked on my system:
sudo env ARCHFLAGS=”-arch x86_64″ gem install –verbose mysql — –with-mysql-include=/usr/local/mysql/include –with-mysql-lib=/usr/local/mysql/lib
Colin Kelley provided an excellent way to test your installation:
$ irb
>> require ‘rubygems’
>> require ‘mysql’
>> Mysql.get_client_info
=> “5.1.38″
Hope this helps some of you guys.
Cheers, Jussi
Yep – worked a treat. A nice simple test to check that it’s all working.
Thanks
seems to be a big mess, not all computers are able to run 64-bit kernel (EFI-32.. thanks Apple)
so most of these posts are not relevant…
Q: running mysql Ver 14.12 Distrib 5.0.67, for apple-darwin9.0.0b5 (i686) using readline 5.1
how do I upgrade to 5.1.38 ? should I rebuild it ? which client should I use ?
bt
got it right… forgot to read an important line in Jussi’s post , I reinstalled all
install READLINE 6.0 !!!…
only pending issue after install :
irb(main):001:0> require ‘rubygems’ => true
irb(main):002:0> require ‘mysql’ => true
irb(main):003:0> Mysql.get_client_info
NoMethodError: undefined method `get_client_info’ for Mysql:Class
from (irb):3
what could be wrong ?
running : OS X 10.6 Snow Leopard
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]
Rails 2.3.4
MySQL 5.1.38
Another thing that worked for me:
Install macports (if you dont already have it)
$ sudo port install mysql5_devel
$ sudo gem install -V mysql — –with-mysql-config=/opt/local/bin/mysql_config5
I sent a question last night,does it have to be “approved” before it shows on the list above?
Sorry wrong place, I am having a similar issue but the post is here: http://void-design.net/2009/08/05/ruby-191-mysql-and-a-snow-leopard/
Ok, if you’re one of those poor souls running with a 32-bit EFI (I have a MacBook2,1) do NOT follow any instructions for 64-bit installs!
Check your EFI using “ioreg -l -p IODeviceTree | grep firmware-abi ” in the terminal, if it comes up with ‘| | “firmware-abi” = ‘ then do the following.
1) Download and install the x86 version of myql from http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg (NOT the x86_64 version, I cannot stress this enough!)
2) sudo killall mysqld (kill any running mysqld processes)
3) sudo mysqld_safe (start the 32-bit mysql server)
4) sudo gem uninstall mysql (remove improperly installed mysqld gem)
5) sudo env ARCHFLAGS=”-arch x86″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config (Again, NOT “-arch x86_64″)
You should now be up and running. If Apple ever comes out with a firmware update for those of us with early Core 2 systems, maybe we’ll actually be able to run in 64-bit mode. But for now, even though you we have 64-bit processors, we’re stuck running in 32-bit mode.
Take a look at this post: http://jameseggers.com/post/185690322/fix-mysql-and-rails-on-snow-leopard . It shows how to get MySQL + Ruby on Rails + Snow Leopard all working perfectly.
Thank you Jussi!! worked like a charm. although in bash I put the ARCHFLAGS in the env using a separate export command.
Was having this issue:
$ sudo env ARCHFLAGS=”-arch x86_64″ gem install –verbose mysql — –with-mysql-include=/usr/local/mysql/include –with-mysql-lib=/usr/local/mysql/lib
Password:
env: x86_64″: No such file or directory
Finally I deleted the ”″ around “-arch x86_64″ and manually typed them in. Still got some errors but did finally see
Successfully installed mysql-2.8.1
[...] Installing MySQL on Snow Leopard Epic Snow Leopard Upgrayyyyd Guide Ruby/Rails and MySQL on Snow Leopard (10A380) [...]
Hallelujah! After about 5 hours and countless other “instructions” this one finally did the trick. Much thanks to Colin Kelley for the helper tips to make sure the right files are being used.
On Snow Leopard, rnsure that your version/arch of *ruby* is correct (x86_64) before installing the mysql gem
http://www.ruby-forum.com/topic/192550#884346
I worked for me. Thanks a lot.
Keep posting stuff like this i really like it! Good job friend!
Installing XCode is the key! I tried to install Rails with MySQL and after 3 hours of trying i read your post and installed XCode again and now i can install MySQL correctly …
[...] http://www.schmidp.com/2009/06/14/rubyrails-and-mysql-on-snow-leopard-10a380/ [...]
When I run irb and then “require ‘rubygems’ I get this error:
LoadError: no such file to load — rubygems
from (irb):1:in `require’
from (irb):1
from :0
I have already done most if not all of the things suggested in this post, including testing that my ruby and mysql are 64 bit (via file `which ruby` and file `which mysql`).
Do I need to reinstall gem? That wasnt mentioned anywhere in the snow leopard conversion docs.
My issue was having 2 versions of ruby (the ports version and the one that apparently came with snow leopard). and so gem was using a different version of ruby than when I ran ruby or irb from the command line.
We’re a group of volunteers and opening a new scheme in our community. Your web site provided us with valuable information to work on. You have done an impressive job and our entire community will be thankful to you.
Don’t forget you will not often win. Some days, essentially the most resourceful specific will style defeat”
I was recommended this web site by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my problem. You are incredible! Thanks!
Hi there, just became alert to your blog through Google, and found that it is truly informative. I’m going to watch out for brussels. I will appreciate if you continue this in future. Many people will be benefited from your writing. Cheers!
Hi, yes this post is genuinely fastidious and I have learned lot of things from it regarding blogging. thanks.
Definitely believe that which you said. Your favorite reason seemed to be on the net the simplest thing to be aware of. I say to you, I definitely get irked while people think about worries that they just don’t know about. You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people can take a signal. Will likely be back to get more. Thanks
Some truly quality posts on this internet site , bookmarked .
[...] http://www.schmidp.com/2009/06/14/rubyrails-and-mysql-on-snow-leopard-10a380/ [...]
Definitely consider that that you said. Your favorite reason appeared to be on the net the simplest factor to take note of. I say to you, I definitely get irked whilst people consider concerns that they plainly don’t understand about. You controlled to hit the nail upon the highest and outlined out the whole thing with no need side-effects , people can take a signal. Will likely be back to get more. Thanks
I simply could not go away your site prior to suggesting that I extremely loved the standard information an individual supply to your guests? Is going to be back continuously to inspect new posts