views:

2787

answers:

3

After upgrading a few gems via terminal on my mac, I have created a new rails project backed up by a mysql database. Upon starting the app, the regular welcome aboard page appears.

Here's the problem - I tried clicking the link entitled "About your application's environment", I receive the following output in my browser:

MissingSourceFile in Rails/infoController#properties
no such file to load -- mysql

I also receive this output in the terminal

The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
Processing Rails::InfoController#properties (for 127.0.0.1 at 2008-12-09 20:41:41) [GET]
Processing Rails::InfoController#properties (for 127.0.0.1 at 2008-12-09 20:41:41) [GET]
MissingSourceFile (no such file to load -- mysql):
...

As it says, I tried issuing "gem install mysql" after stopping the application, only to be greeted by this chunk of jargon which I am unable to comprehend:

WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
      /usr/bin aren't both writable.
WARNING:  You don't have /Users/mymac/.gem/ruby/1.8/bin in your PATH,
      gem executables will not run.
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
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
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /Users/mymac/.gem/ruby/1.8/gems/mysql-2.7 for inspection.
Results logged to /Users/mymac/.gem/ruby/1.8/gems/mysql-2.7/gem_make.out

Clearly there is something wrong with my mysql installation, as I have also tried running the rake command to create the database, which prompted me with the following.

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql

(See full trace by running task with --trace)

However, when I run "mysql --version" at the command line, mysql is installed!

mysql  Ver 14.12 Distrib 5.0.67, for apple-darwin9.4.0 (i686) using readline 5.1

I also tried issuing "sudo gem install mysql", however that was also to no avail:

sudo gem install mysql
Password:
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
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

I also tried issuing "sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config" as instructed by bradheintz, which seemed to have installed ok, but after trying to view the application environment again, no ajaxy dropdown occurs and the rails app stops completely! The following output is printed just before the application decides to die on me lol.

dyld: lazy symbol binding failed: Symbol not found: _mysql_init
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
  Expected in: dynamic lookup

dyld: Symbol not found: _mysql_init
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
  Expected in: dynamic lookup

Trace/BPT trap

If anyone can understand what's going on here, and how to go about resolving this problem, I'd be very grateful :)

+4  A: 

The issue is that the MySQL gem builds native extensions and needs system-specific information about where to find certain libraries. You have to provide this on the command line.

Check out this page - the important bit (that worked for me, anyway) was:

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

Of course, be sure to substitute the correct path for your own system.

Also, stick with running your gem install commands via sudo.

The bigger issue is that the gem software provides NO feedback regarding the fact that you can't just do gem install mysql like you do with every other gem (and indeed, used to be able to do with the MySQL gem).

bradheintz
There are no instructions there, the guy is still having trouble installing mysql.
Damian
Well, it was the page that got me unstuck. I'll edit to be clearer about the magic.
bradheintz
Just tried that mate, and mysql installed ok, but now the rails app stops completely(see the end of the detailed post above).
Damian
Hmm - That issue is new to me. But Google turns up people with similar problems on Leopard, and this guy claims to have fixed it:http://cho.hapgoods.com/wordpress/?p=158That's the second hit from googling `dyld: lazy symbol binding failed: Symbol not found: _mysql_init rails leopard`.
bradheintz
I realise I'm still a noob when it comes to these matters, so which directory shall I replace this command with?
Damian
A: 

Try forcing build of the 32-bit version only (assuming you're on Intel Mac, the -V with gem should give you more verbose output)

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

More information in this blog post: http://blog.pastie.org/2008/10/mysql-64-bit-ruby-32-bit-friends-again.html

sascha
A: 

Last time I saw this error was when I try to install mysql/ruby adapter. And I encounter same error after upgrade rails on Mac to rails 1.2.2 because 1.2.2 remove mysql gem by default.

The reason last time I found is missing mysql client or library. Take Redhat for example, you can go to this link, and install mysql client and library. http://dev.mysql.com/downloads/mysql/5.0.html#linux-rhel5-x86-32bit-rpms

Let me know the result.

Joe