首页 > 解决方案 > mysql2 gem 坚持使用 openssl 1.0 而不是 1.1

问题描述

我最近将 openssl 更新到 1.1,并为我们的一个 rails 应用程序重新安装了 ruby​​ 2.5.3。

但是我收到了错误:

/Users/cameron/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/cameron/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
  Reason: image not found - /Users/cameron/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle

在我.zshrc的路径中有以下内容:

export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

我已经尝试卸载 mysql2 并像这样重新安装:

gem install mysql2 -v 0.4.10 -- --with-cflags=\"-I/usr/local/opt/openssl@1.1/include\" --with-ldflags=\"-L/usr/local/opt/openssl@1.1/lib\"

但是错误不断出现......

为什么 mysql2 gem 仍在尝试1.0.0使用1.1

标签: rubyopenssl

解决方案


对于遇到此问题的任何人...修复相当烦人但很简单。

从字面上看:

source ~/.zshrc或者source ~/.bash_profile

你甚至不需要使用--with-cflags --with-ldflags... 并重新安装你的 mysql2 gem。将您的个人资料与路径中的 openssl 重新链接后,一个简单bundle install的就足够了,一切都会再次运行!


推荐阅读