mysql gem install not happening on Mac OS Leopard - any inputs at all??

Hello all,

Ive got Mac OS X Leopard (10.5.8), ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0] and mysql 5.0.67 installed and working fine with Rails 2.1.0.

"which ruby" outputs /usr/bin/ruby. I can see the mysql symlink in / usr/local/mysql. I can also see the mysql-5.0.67-osx10.5-x86 folder in /usr/local .

Im trying to upgrade my Rails apps to 2.3.5 but when i try to install the mysql gem, I get "ERROR: Failed to build gem native extension." I tried all the following commands with and without sudo and get the same error everytime

env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config env ARCHFLAGS="-arch i386" gem install mysql --with-mysql-dir=/usr/local/mysql gem install mysql -- --with-mysql-dir=/usr/local/mysql gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Im not sure what Im doing wrong. Am I supposed to uninstall the existing mysql and reinstall the latest (5.1.x) before I install the mysql gem? Or are my ruby and mysql paths screwed up? Ive googled a lot and tried all the suggestions (as you can see above) but none work.

I raised this issue already in the group but no replies yet. So I've reframed it in a simpler fashion. Even if noone knows the solution right away, I'd really appreciate any inputs at all.

Thanks!

I also get this warning in the very beginning of the gem install. Does it have any relevance?

WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and     /usr/bin aren't both writable. WARNING: You don't have /Users/Ram/.gem/ruby/1.8/bin in your PATH,     gem executables will not run.

<on my knees now> :S

Im not comfortable uninstalling everything and installing it from scratch again. Dont want to lose my existing setup. Pointers from anyone at all?

If it was "working fine with Rails 2.1.0" and you're just upgrading Rails itself, why are you trying to (re-)install the mysql gem?

Im not re-installing the mysql gem. I have been using the Ruby based mysql library that used to ship with Rails by default (pre 2.2). If I am to migrate to Rails 2.3 then I HAVE to install the gem now.

<on my knees now> :S

Im not comfortable uninstalling everything and installing it from scratch again. Dont want to lose my existing setup. Pointers from anyone at all?

There should be a log file detailing what went wrong when it tried to build the gem. What's in it?

Fred

Hello Fred,

I can see the following errors in the mkmf.log residing in ../ mysql-2.8.1/ext/mysql_api/ .

1. (Under "find_library: checking for mysql_query() in - lmysqlclient... -------------------- no") conftest.c: In function 't': conftest.c:3: error: 'mysql_query' undeclared (first use in this function) conftest.c:3: error: (Each undeclared identifier is reported only once conftest.c:3: error: for each function it appears in.)

2. (Under "find_library: checking for mysql_query() in - lmysqlclient... -------------------- no") ld: library not found for -lmysqlclient collect2: ld returned 1 exit status

3. ld: library not found for -lmygcc (Under "have_library: checking for main() in -lmygcc... -------------------- no")

4. ld: library not found for -lnsl (Under "have_library: checking for main() in -lnsl... -------------------- no")

5. ld: library not found for -lsocket (Under "have_library: checking for main() in -lsocket... -------------------- no")

Hope that helps. Thanks!

Hello Fred,

I can see the following errors in the mkmf.log residing in ../ mysql-2.8.1/ext/mysql_api/ .

dumb question: do you have the apple developer tools installed?

Fred

:slight_smile: I do. And no, not a dumb question. Im happy answering *any* question if it means you can help me fix this hair-loss-causing issue!!!

Okay ... RESOLVED! :smiley:

I left the mysql installation as such in /usr/local . I had been running the ruby and rails shipped with leopard in /usr/ bin. Followed the hivelogic article (Dan Benjamin rails-leopard) to roll my own installations in /usr/local/ and then ran "sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql" . Worked like a charm!

Thank you all for the help! :slight_smile:

Ram wrote:

Okay ... RESOLVED! :smiley:

I left the mysql installation as such in /usr/local . I had been running the ruby and rails shipped with leopard in /usr/ bin. Followed the hivelogic article (http://hivelogic.com/articles/ruby- rails-leopard) to roll my own installations in /usr/local/ and then ran "sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql" . Worked like a charm!

Hivelogic's advice to roll your own Ruby installation is generally pointless and silly on Leopard (unless you're using 1.9). Now that you have it all running, I suggest that you get it working with the system Ruby (which it *will* do) and delete the unnecessary Hivelogic one.

Thank you all for the help! :slight_smile:

Best,

Hello Marnen,

On the contrary, I find hivelogic's logic (:P) quite sound.

I understand that the possibility of software updates breaking the environment is kinda remote, but learning to build from source and knowing exactly where your software is helps a lot. Whats the point in developing in RoR but having little knowledge of where your components are installed on your machine or how to update them? I help maintain a couple other Macs where we followed hivelogic's article the very day the Macs were opened from their boxes, and they have no issues whatsoever in maintenance. In contrast, my setup has been giving trouble regularly. Still remains to be seen though, whether having hivelogic's setup on top now on my machine will work consistently :).

Besides, gem install mysql simply dint work in my older setup. Spent couple of weeks on it.