尽管使用`gem install ...'命令进行安装,但mysql2 gem在捆绑安装中失败. [英] mysql2 gem fails on bundle install, despite installing using `gem install...` command

查看:57
本文介绍了尽管使用`gem install ...'命令进行安装,但mysql2 gem在捆绑安装中失败.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的捆绑安装

Fetching mysql2 0.5.2
Installing mysql2 0.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
...
...
...
Cannot find mysql_config at /usr/local/opt/mysql@5.6/bin/mysql_config
--with-ldflags=-L/usr/local/opt/openssl/lib
--with-cppflags=-I/usr/local/opt/openssl/include
-----
*** 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/admin/.asdf/installs/ruby/2.6.3/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

To see why this extension failed to compile, please check the mkmf.log which can be found
here:

/Users/admin/development/locari/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/Users/admin/development/locari/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.2 for
inspection.
Results logged to
/Users/admin/development/locari/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.2/gem_make.out

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds
before bundling.

所以我按照它说的做,然后运行 sudo gem install mysql2 -v'0.5.2'--source

So I do what it says, and run sudo gem install mysql2 -v '0.5.2' --source

$ sudo gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
Successfully installed mysql2-0.5.2
Parsing documentation for mysql2-0.5.2
Done installing documentation for mysql2 after 0 seconds
1 gem installed

它安装得很好!但是当我再次运行 bundle install 时,我得到了同样的错误.我尝试在brew中卸载,取消链接并重新安装 mysql .

And it installs fine! But when I run bundle install again, I get the same error. I've tried uninstalling, unlinking, and reinstalling mysql in brew.

接下来我可以尝试什么?

What can I try next??

推荐答案

我找到了答案.我需要先运行这些命令,然后才能运行:

I found the answer. I needed to run these commands first, then it worked:

捆绑配置--local build.mysql2"--with-cppflags = -I/usr/local/opt/openssl/include"

捆绑配置--local build.mysql2"--with-ldflags = -L/usr/local/opt/openssl/lib"

,然后当我运行 bundle install 终于成功了

and then when I ran bundle install it finally worked

这篇关于尽管使用`gem install ...'命令进行安装,但mysql2 gem在捆绑安装中失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆