5

I'm running OSX 10.7 (Lion), and recently uninstalled MacPorts because MySQL failed to start. MySQL (64-bit) is now starting, but now I can't install the MySQL gem (Rails). I've tried using the with-mysql-config and the ARCHFLAGS option, neither of which worked. I tried reinstalling Ruby 1.9.3, which also didn't change anything. I'm currently running MySQL 5.1.61 after I thought MySQL 5.0.95 might be causing an issue. Here is the traceback:

Christy$ gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /Users/Christy/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb checking for rb_thread_blocking_region()... yes checking for rb_wait_for_single_fd()... yes checking for mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.h... yes creating Makefile make compiling client.c client.c: In function ‘rb_raise_mysql2_error’: client.c:98: warning: ISO C90 forbids mixed declarations and code client.c: In function ‘rb_mysql_client_socket’: client.c:590: warning: ISO C90 forbids mixed declarations and code compiling mysql2_ext.c compiling result.c linking shared-object mysql2/mysql2.bundle ld: file not found: /opt/local/lib/libssl.1.0.0.dylib for architecture x86_64 collect2: ld returned 1 exit status make: *** [mysql2.bundle] Error 1 

I tried reinstalling openssl (thinking that file not found: /opt/local/lib/libssl.1.0.0.dylib might be because of that), but it still doesn't work. I'm kind of new to this, so any help would be much appreciated! Thank you!

EDIT: /opt/local/lib/ does not exist. I don't know why it's looking there for the file. Any ideas on how to point it to the right place (locate libssl points to /usr/lib/libssl.0.9.8.dylib and /usr/local/Cellar/openssl/0.9.8s/lib/libssl.0.9.8.dylib, among other places)?

4 Answers 4

3

My problem was similar and it turned out that I had installed mysql with brew while macports was still installed. After fully uninstalling macports I then uninstalled and reinstalled mysql with brew:

brew uninstall mysql brew install mysql 
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! I just migrated from macports to homebrew and i didn't know that this could cause error.
2

LD_LIBRARY_PATH has a bad path in it. Can temporarily set it for that shell by running export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib ; gem install mysql2.

However, might suggest adding the definition to your .bashrc (or other appropriate .shellrc file) export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib so all shells get it.

4 Comments

Hmm. Seems like ld has that path you removed cached(?). Strange. Only thing I can think of, without knowing the rest about your setup, is doing a 'LD_LIBRARY_PATH=/usr/local/lib:/usr/lib gem install mysql2', but that should be the default anyway. Can you 'echo $LD_LIBRARY_PATH', perhaps its set incorrectly in your shell?
Nothing is returned from echo $LD_LIBRARY_PATH. Thoughts?
Can you try 'export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib ; gem install mysql2'?
Hmm. Might want to consider adding 'export LD_LIBRARY_PATH="/usr/local/lib:/usr/lib" to your .bashrc I'll update the answer text to reflect
2

I had to set the path to my mysql installation which was 5.1. Doing this, then it worked:

export ARCHFLAGS="-arch x86_64" export PATH=$PATH:/opt/local/lib/mysql51/bin 

Comments

0

Not sure, but maybe you need to install the libssl-dev package to get it compile

5 Comments

not sure. just one of the things i look for if builds fail on my machine. @trilobyte: another point could be that you may have to use 'sudo gem install mzsql2'. especially gems that need builds often require root permission. and the 'for architecture x86_64' part may give some hint. does the file exist at all? if so, maybe it's 32 bit for some reason.
You're right, the file doesn't exist. I don't know why it's looking there. There are dylib packages in /usr/local/lib, but not libssl.1.0.0.dylib. Do you know where it might be, or why it's looking in a directory that doesn't exist?
@thorstenmüller You should never use sudo with RVM (or rbenv).
@Andrew Marshall: Thanks for pointing that out. Didn't see it. 'rvmsudo' then instead.
@trilobyte: the build system uses a set of include paths where it looks for libraries and header files. /usr/local/lib is one of those standard paths. You can sometimes decide where to install a certain library. The other option is to tell the build with flags where to look for libraries.Maybe this link would give some details.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.