在Mac os x Lion上安装mysql2 gem
前几天我更新了MacOSX Lion。它破坏了我的rails安装,因为我不得不重新编译mysql。虽然我已经了解到,重新安装mysql2 gem已经成了问题。我在运行leopard,所以我将从32位运行到64位在Mac os x Lion上安装mysql2 gem,mysql,ruby,gem,rvm,mysql2,Mysql,Ruby,Gem,Rvm,Mysql2,前几天我更新了MacOSX Lion。它破坏了我的rails安装,因为我不得不重新编译mysql。虽然我已经了解到,重新安装mysql2 gem已经成了问题。我在运行leopard,所以我将从32位运行到64位 ~/code/rails/london (master)$ gem install mysql2 -- --with-mysql-dir=/usr/local/mysql Building native extensions. This could take a while..
~/code/rails/london (master)$ gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql
checking for rb_thread_blocking_region()... *** 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=/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:796:in `have_func'
from extconf.rb:9:in `<main>'
Gem files will remain installed in /Users/stewartmatheson/.rvm/gems/ruby-1.9.2-p0@london/gems/mysql2-0.3.7 for inspection.
Results logged to /Users/stewartmatheson/.rvm/gems/ruby-1.9.2-p0@london/gems/mysql2-0.3.7/ext/mysql2/gem_make.out
~/code/rails/london(master)$gem安装mysql2--with mysql dir=/usr/local/mysql
构建本机扩展。这可能需要一段时间。。。
错误:安装mysql2时出错:
错误:无法生成gem本机扩展。
/Users/stewartmatesson/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb——带mysql dir=/usr/local/mysql
正在检查rb_线程_阻塞_区域()…***extconf.rb失败***
由于某些原因无法创建Makefile,可能是缺少
必要的库和/或标题。查看mkmf.log文件了解更多信息
细节。您可能需要配置选项。
提供的配置选项:
--使用opt dir
--不带opt dir
--选择包含
--不带opt include=${opt dir}/include
--使用opt lib
--不带opt lib=${opt dir}/lib
--用make prog
--没有make prog
--srcdir=。
--库尔迪尔
--ruby=/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:368:在“try_do”中:编译器未能生成可执行文件。(运行时错误)
您必须首先安装开发工具。
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:435:in'try_link0'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:440:in'try_link'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:552:in'try_func'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:797:in`block in have_func'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:693:in'block in checking_'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:280:in“延迟中的块(2级)”中
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:254:in'open'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:280:in'block in delay'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:254:in'open'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:276:in“推迟”
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:692:in'checking_'
from/Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/mkmf.rb:796:in'have_func'
来自extconf.rb:9:in`'
Gem文件仍将安装在/Users/stewartmatheson/.rvm/gems/ruby-1.9.2中-p0@london/gems/mysql2-0.3.7进行检查。
结果记录到/Users/stewartmatheson/.rvm/gems/ruby-1.9.2-p0@london/gems/mysql2-0.3.7/ext/mysql2/gem_make.out
到目前为止,我已经重新编译并安装了MySQL,并将RVM更新到head。我也安装了Xcode,但是我没有运气
建议?不知道这是否有帮助,但让我试试 要让mysql2 gem在我的OSX Lion下运行,运行Ruby 1.8.7: 安装mysql-下载mysql-5.5.14-osx10.6-x86\u 64 在mysql e MySQLCOM的.bash_配置文件中创建别名
alias mysql=“/usr/local/mysql/bin/mysql”
- 别名mysqld=“sudo/Library/StartupItems/MySQLCOM/MySQLCOM”
gem'mysql2','0.3.6'
创建此符号链接:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
我通过重新安装ruby解决了这个问题,这似乎是必需的,因为编译器是在Lion中更新的。我在系统ruby(Lion上的1.8.7)中安装了这个,如下所示:
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
env ARCHFLAGS="-arch x86_64" sudo gem install mysql2 -- --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
$locate mysql\u config
可以找到它的路径$sudogem安装mysql2--–使用mysql-config=/path/to/mysql\u-config
通过从源代码编译mysql,我成功地使其工作。在那之后,它似乎起了作用。我写了一篇关于这一点的博文,但我无法验证你的答案,因为我试图用ruby 1.9.2构建。我已经在3台Mac上实现了,有人对它进行了升级,所以它可能对使用ruby 1.8.7的人有用。这似乎对我有效[到目前为止,还不错]。创建链接的命令是:sudoln-s/usr/local/mysql/lib/libmysqlclient.18.dylib/usr/lib/libmysqlclient.18.dylib