尝试使用db:create时出现“错误:Rake已中止”

时间:2019-03-01 10:05:43

标签: ruby-on-rails ruby-on-rails-5 rake

我是Ruby on Rails的新手,所以我按照说明从gorails.com安装ROR,并以mysql作为数据库。 (也曾尝试使用SQLite3,但在那儿我也遇到了错误...?)https://gorails.com/setup/osx/10.14-mojave

一切顺利,直到我不得不使用以下内容,

rake db:create

在ROR项目中运行此命令时,出现此rake中止错误。从我的终端输出以下信息。

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。

2 个答案:

答案 0 :(得分:1)

尝试一下:

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/

答案 1 :(得分:1)

我使用了@Denny Mueller和@Umar Khan的答案来解决问题。我没有意识到这是openssl的问题,但是解决问题的方法与该问题的答案provided by Michael Erb相同。

解决方案

事实证明,openssl仅用于桶装,这意味着它没有符号链接到/ 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`
相关问题