我使用 Homebrew ( brew install mysql
) 安装了 MySQL,然后运行 $ gem install mysql2
。我的 Mac 运行 OSX 10.9.4。
我将目录更改为应用程序的根目录,然后尝试运行 rake db:migrate
命令,并收到此错误:
Levine_iMac$ rake db:migrate
rake aborted!
LoadError: dlopen(/Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
in /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in require'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in <top (required)>'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in <top (required)>'
(See full trace by running task with --trace)
Levine_iMac$
我尝试向我的 .bash_profile 添加一些内容,如所述 here ,但这没有用。
我尝试了 sudo 命令,如here所述,但这没有用。
然后我尝试将 Ruby 版本从 2.1.1.. 更新到 2.1.2..,现在运行 rake:db migrate 时收到此错误
Levine_iMac$ rake db:migrate
rake aborted! cannot load such file -- bundler/setup /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:1:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in '<top (required)>' (See full trace by running task with --trace) Levine_iMac$ bundle install rbenv: bundle: command not found The 'bundle' command exists in these Ruby versions:
2.1.1
Levine_iMac$
关于如何解决这个问题有什么想法吗?谢谢。
最佳答案
那么,当您运行 rake db:migrate 时,您到底期望发生什么?您的下一步计划会实现吗?如果您能够回答这个问题,您就会明白为什么您所做的事情没有意义。
我会详细说明:
rake db:migrate 仅适用于现有 Rails 应用程序的上下文。运行“gem install mysql2”将为您在计算机上获取该库(该命令自行执行,它实际上与 Rails 本身没有任何关系,或者需要 Rails 应用程序作为上下文)。所以,两者之间不存在线性联系。
- rails 新 myapp
- 在 Gemfile 中添加“gem mysql2”
- 捆绑
- rake 数据库:创建
或者,另一种选择:
rails new myapp -d mysql
关于mysql - 无法 rake :db migrate - Keep getting a 'rake aborted! load error' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25554713/