捆绑安装失败。无法安装mysql2 gem

时间:2015-09-03 16:19:19

标签: ruby-on-rails ruby gem zsh zshrc

我在OS X Yosemite 10.10.2上。我不知道我为此做了什么,我正在努力弄清问题是什么。

基本上我的大多数rails命令都失败了。我使用的是zsh。

当我尝试运行bundle install时,我得到了

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

    /Users/name/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150903-44386-11qoex1.rb extconf.rb --with-mysql-config=usr/local/bin/mysql_config/
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Cannot find mysql_config at usr/local/bin/mysql_config/
-----
*** 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/name/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysql-config

extconf failed, exit code 1

Gem files will remain installed in /Users/name/workspace/application/vendor/bundle/ruby/2.2.0/gems/mysql2-0.3.20 for inspection.
Results logged to /Users/name/workspace/application/vendor/bundle/ruby/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/gem_make.out
An error occurred while installing mysql2 (0.3.20), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.20'` succeeds before bundling.

我做了,

gem install mysql2 -v '0.3.20'

它成功了。

Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.20
Parsing documentation for mysql2-0.3.20
Done installing documentation for mysql2 after 0 seconds
1 gem installed

现在,当我执行bundle install时,它再次给出了同样的错误。

所以我尝试了which mysql2,它说mysql2 not found

根据这条评论https://stackoverflow.com/a/16132663/5245746,我检查了我的cflags,它对我来说很好看。这是我的,

cflags="-I$pkgincludedir -O3 -g -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF " #note: end space!

我检查了mkmf.log文件。这是日志http://pastebin.com/aZ8ySXd8

我已经花了半天时间在这上面而且非常令人沮丧。我认为这不是mysql2的问题,这背后有一个更大的问题。谁能告诉我一些方向?你们知道为什么会这样吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

出于某种原因,mysql2的extconf提供了选项:

--with-mysql-config=usr/local/bin/mysql_config/

应该是(注意正斜杠的位置):

--with-mysql-config=/usr/local/bin/mysql_config

或者根本没有设置,因为/usr/local/bin/mysql_config是mysql2搜索的默认值之一。