我是Ruby on rails的新手,所以我按照说明从gorails.com安装ROR,mysql作为数据库。 (也尝试过使用SQLite3,但我也遇到错误......?)https://gorails.com/setup/osx/10.14-mojave
一切顺利,直到我不得不使用以下,
rake db:create
当我在我的ROR项目中运行此命令时,我得到了这个rake aborted错误。随后从我的终端输出。
rake aborted!
LoadError: dlopen(/Users/username/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/username/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/username/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle
/Users/username/Desktop/myapp3/config/application.rb:7:in `<top (required)>'
/Users/username/Desktop/myapp3/Rakefile:4:in `require_relative'
/Users/username/Desktop/myapp3/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
我试过检查gemfile。
我用@Denny Mueller和@Umar Khan的答案解决了这个问题。我没有意识到这是openssl的一个问题,但问题的解决方案与这个问题上的答案provided by Michael Erb相同。
解决方案
事实证明,openssl只是keg-only,这意味着它没有符号链接到/ usr / local,因为Apple不赞成使用OpenSSL来支持自己的库。首先,卸载mysql2。
gem uninstall mysql2
然后重新安装OpenSSL
brew reinstall openssl
注意输出包含:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
然后我们可以再次安装mysql2
gem install mysql2 -v 0.4.10 -- --with-cppflags=-`I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib`
试试这个:
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/