mysql - 无法 rake :db migrate - Keep getting a 'rake aborted! load error'

标签 mysql ruby-on-rails macos command-line

我使用 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 应用程序作为上下文)。所以,两者之间不存在线性联系。

  1. rails 新 myapp
  2. 在 Gemfile 中添加“gem mysql2”
  3. 捆绑
  4. rake 数据库:创建

或者,另一种选择:

rails new myapp -d mysql

关于mysql - 无法 rake :db migrate - Keep getting a 'rake aborted! load error' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25554713/

相关文章:

PHP/SQL Where, And, Order By——适用于一个语句,但在另一个类似查询中出错

ruby-on-rails - 如何阻止 Rails 3.1 迁移在事务中运行?

javascript - Rails 每个循环中的 JQuery 错误(未捕获的 ReferenceError : $ is not defined)

mysql - 如何将 ID 列表通过管道传输到 MySQL select 语句

java - 如何将 Eclipse 项目从 Windows 导入到 Mac OS

php - laravel中如何根据表列值重定向不同的编辑页面?

mysql - 使用共享和专用托管服务器时的数据库查询性能

php - 选择数据库中尚未存在的不同值

ruby-on-rails - 将参数传递给 Rails 单元测试

macos - 将大量文件合并为一个