rakedb:mysql2-gem迁移错误-未加载库:libssl1.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指的是什么?

首先卸载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

所以我自己的问题的答案是以下-在stackoverflow上的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
$ 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

相关内容

  • 没有找到相关文章

最新更新