rake db:migrate 错误 mysql2 gem - 库未加载:libssl.1.0.0.dylib
rake db:migrate error with mysql2 gem - Library not loaded: libssl.1.0.0.dylib
运行 rake db:migrate
后出现以下错误
rake aborted!
LoadError: dlopen(/Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle, 9): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle
/Users/scott/Google Drive/playground/myApp/myApp/config/application.rb:21:in `<top (required)>'
/Users/scott/Google Drive/playground/myApp/myApp/Rakefile:4:in `<top (required)>'
libssl 指的是什么?
所以我自己的问题的答案如下 - 在 Whosebug 上的 5 个左右的其他解决方案中,这是唯一有效的解决方案:
brew install openssl
cd /usr/local/Cellar/openssl/1.0.1f/lib
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/lib/
这里有完整的解决方案 - https://mithun.co/hacks/library-not-loaded-libcrypto-1-0-0-dylib-issue-in-mac/
先卸载mysql2 gem:
gem uninstall mysql2
确保你安装了 openssl:
brew install openssl
它会打印出一些注释。我们对这部分感兴趣:
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
然后你可以像这样重新安装 mysql2 gem:
gem install mysql2 -v 0.4.10 -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib
你应该可以开始了。
以下修复解决了问题
==> cd /usr/local/Cellar/openssl/1.0.2s/lib/
==> sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib
就我而言,只需卸载并安装 mysql2 gem 就可以了
$ gem uninstall mysql2
$ bundle install
> Fetching mysql2 0.4.10
> Installing mysql2 0.4.10 with native extensions
只有一个命令:
gem pristine mysql2
那我解决这个问题
对于 rbenv
的用户:
brew uninstall openssl
brew install rbenv/tap/openssl@1.0
gem uninstall mysql2
gem install mysql2 -v '0.4.10' -- --with-opt-dir="$(brew --prefix rbenv/tap/openssl@1.0)"
对我来说,mysql2 的更高版本(在我的例子中是 0.5.3)需要 openssl1.1。这样做之后,它对我有用:
$ cp /usr/local/Cellar/openssl@1.1/1.1.1j/lib/libssl.1.1.dylib /usr/local/lib
$ cp /usr/local/Cellar/openssl@1.1/1.1.1j/lib/libcrypto.1.1.dylib /usr/local/lib
运行 rake db:migrate
后出现以下错误rake aborted!
LoadError: dlopen(/Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle, 9): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle
/Users/scott/Google Drive/playground/myApp/myApp/config/application.rb:21:in `<top (required)>'
/Users/scott/Google Drive/playground/myApp/myApp/Rakefile:4:in `<top (required)>'
libssl 指的是什么?
所以我自己的问题的答案如下 - 在 Whosebug 上的 5 个左右的其他解决方案中,这是唯一有效的解决方案:
brew install openssl
cd /usr/local/Cellar/openssl/1.0.1f/lib
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/lib/
这里有完整的解决方案 - https://mithun.co/hacks/library-not-loaded-libcrypto-1-0-0-dylib-issue-in-mac/
先卸载mysql2 gem:
gem uninstall mysql2
确保你安装了 openssl:
brew install openssl
它会打印出一些注释。我们对这部分感兴趣:
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
然后你可以像这样重新安装 mysql2 gem:
gem install mysql2 -v 0.4.10 -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib
你应该可以开始了。
以下修复解决了问题
==> cd /usr/local/Cellar/openssl/1.0.2s/lib/
==> sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib
就我而言,只需卸载并安装 mysql2 gem 就可以了
$ gem uninstall mysql2
$ bundle install
> Fetching mysql2 0.4.10
> Installing mysql2 0.4.10 with native extensions
只有一个命令:
gem pristine mysql2
那我解决这个问题
对于 rbenv
的用户:
brew uninstall openssl
brew install rbenv/tap/openssl@1.0
gem uninstall mysql2
gem install mysql2 -v '0.4.10' -- --with-opt-dir="$(brew --prefix rbenv/tap/openssl@1.0)"
对我来说,mysql2 的更高版本(在我的例子中是 0.5.3)需要 openssl1.1。这样做之后,它对我有用:
$ cp /usr/local/Cellar/openssl@1.1/1.1.1j/lib/libssl.1.1.dylib /usr/local/lib
$ cp /usr/local/Cellar/openssl@1.1/1.1.1j/lib/libcrypto.1.1.dylib /usr/local/lib