解决错误:安装mysql2(0.4.5)时发生错误,Bundler无法继续。确保`gem install mysql2 -v' 0.4.5'`

时间:2017-01-10 07:36:51

标签: mysql ruby-on-rails ruby docker

我正在尝试通过运行命令来构建docker镜像:

docker build -t user:repository .

并不断收到此错误:

An error occurred while installing mysql2 (0.4.5), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.5'` succeeds before bundling.
The command '/bin/sh -c /bin/bash -l -c "gem install bundler && bundle install"' returned a non-zero code: 5

我尝试过的事情

  1. gem install mysql2 -v' 0.4.5'`

    收到错误

    错误:找不到有效的宝石' mysql2' (= 0.4.5),原因如下:           无法从https://rubygems.org/下载数据 - SSL_connect返回= 1 errno = 0状态= SSLv3读取服务器证书B:证书验证失败(https://api.rubygems.org/specs.4.8.gz

  2. 在运行this repo和this网站的建议后,我收到了错误消息:

    无法找到有效的宝石' C:rubygems-update-2.6.7.gem'任何存储库中的(> = 0)

    我被困在这一点上,因为我不知道这个问题源于何处。非常感谢任何帮助。

    当我运行bundle update时,我得到了一个

    Could not verify the SSL certificate for https://rubygems.org/.
    There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about
    OpenSSL certificates, see. To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
    

2 个答案:

答案 0 :(得分:0)

尝试运行bundle update。我有类似的问题,对我有用......祝你好运!

答案 1 :(得分:0)

Dockerfile在这里很有用,但让我们随机试一下。

如果您使用ubuntu,则基本安装不包含任何ca证书,因此SSL无法正常运行。尝试安装软件包' ssl'和' ca-certificates'。