Mac OSX:MySQL gem 安装失败 (RoR)

tri*_*yte 5 mysql ruby-on-rails

我正在运行 OSX 10.7 (Lion),最近卸载了 MacPorts,因为 MySQL 无法启动。MySQL(64 位)现在正在启动,但现在我无法安装 MySQL gem (Rails)。我试过使用with-mysql-configARCHFLAGS选项,都没有奏效。我尝试重新安装 Ruby 1.9.3,这也没有改变任何东西。在我认为 MySQL 5.0.95 可能会导致问题之后,我目前正在运行 MySQL 5.1.61。这是回溯:

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
Run Code Online (Sandbox Code Playgroud)

我尝试重新安装 openssl(认为file not found: /opt/local/lib/libssl.1.0.0.dylib可能是因为这个),但它仍然不起作用。我对此很陌生,所以任何帮助将不胜感激!谢谢!

编辑/opt/local/lib/不存在。我不知道它为什么在那里寻找文件。关于如何将它指向正确的位置(locate libssl指向/usr/lib/libssl.0.9.8.dylib/usr/local/Cellar/openssl/0.9.8s/lib/libssl.0.9.8.dylib,以及其他地方)的任何想法?

rni*_*son 2

LD_LIBRARY_PATH 中有一个错误的路径。可以通过运行临时为该 shell 设置它export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib ; gem install mysql2

但是,可能建议将定义添加到您的 .bashrc (或其他适当的.shellrc文件)中export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib,以便所有 shell 都能获取它。