gem install mysql2 v '0.3.11' 不适用于优胜美地

Posted

技术标签:

【中文标题】gem install mysql2 v \'0.3.11\' 不适用于优胜美地【英文标题】:gem install mysql2 v '0.3.11' not working on Yosemitegem install mysql2 v '0.3.11' 不适用于优胜美地 【发布时间】:2014-12-14 22:18:51 【问题描述】:

在 ruby​​ 版本 1.9.3 (rvm) 上执行 mysql2 版本 0.3.11 的捆绑安装或直接 gem 安装时,我收到以下错误。但是当我安装最新版本 0.3.16 时它可以工作。我还包括了我的 gcc 版本以供参考。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/ginocarlocortez/.rvm/rubies/ruby-1.9.3-p547/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  clean

make
compiling client.c
couldn't understand kern.osversion `14.0.0'
compiling mysql2_ext.c
couldn't understand kern.osversion `14.0.0'
compiling result.c
couldn't understand kern.osversion `14.0.0'
linking shared-object mysql2/mysql2.bundle
couldn't understand kern.osversion `14.0.0'
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ginocarlocortez/.rvm/gems/ruby-1.9.3-p547@willh/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/ginocarlocortez/.rvm/gems/ruby-1.9.3-p547@willh/extensions/x86_64-darwin-14/1.9.1/mysql2-0.3.11/gem_make.out
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

gcc 版本

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

【问题讨论】:

与***.com/questions/26417431/…相同的错误 针对 gcc 打开错误:gcc.gnu.org/bugzilla/show_bug.cgi?id=61407 @Substantial 似乎不是相同的错误。 【参考方案1】:

因此发生错误:

ld: -rpath can only be used when targeting Mac OS X 10.5 or later

尝试像这样指定 OSX 部署目标:

export MACOSX_DEPLOYMENT_TARGET=10.5

【讨论】:

考虑为您的答案添加解释 只需在运行bundle install 之前添加导出即可解决我的情况。 @steamboy——你能把它标记为接受吗(如果它也解决了你的问题)?谢谢@maikonas! $ MACOSX_DEPLOYMENT_TARGET=10.5 bundle install 为我工作。非常感谢!

以上是关于gem install mysql2 v '0.3.11' 不适用于优胜美地的主要内容,如果未能解决你的问题,请参考以下文章

gem install mysql2 失败

`block in replace_gem': Please install the mysql2 adapter: `gem install activerecord-mysql2-adap

使用 rvm 在 Snow Leopard for Rails 3 上安装 mysql2 gem

通过 Bundler 安装 mysql2 gem 时出错

安装 mysql2 gem 错误

gem列表中的mysql2 gem但获取项目找不到gem