【问题标题】:Migrations are pending; run 'rake db:migrate RAILS_ENV=development' to resolve this issue.?迁移待定;运行 'rake db:migrate RAILS_ENV=development' 来解决这个问题。?
【发布时间】:2014-02-08 14:21:22
【问题描述】:
当我运行> rake db:migrate 时,在我的网页中出现此错误之后。它显示错误,例如:
rake aborted!
you have already activated rake 10.1.1 but you gemfile requires rake 10.1.0 using bundle exec may solve this.
- 当我尝试使用
bundle exec rake db:migrate 它有效。
- 当我尝试使用
rake db:migrate 时。 我显示错误
我的问题是:
-
bundle exec rake db:migrate 和 rake db:migrate 有什么区别。
- 每次我都必须这样做 如果是,那为什么?
- 我的项目有什么问题。
谢谢。
【问题讨论】:
标签:
ruby-on-rails
ruby
ruby-on-rails-4
rake
【解决方案1】:
bundle exec rake db:migrate 将在您的 Gemfile 环境中运行 rake db:migrate。
您遇到了一个错误,因为您的 Gemfile 需要一个 rake 版本,但您的系统上安装了一个较新的版本。
默认情况下,rake 将运行最新的可用版本,因此不匹配。
在 bundler 管理的项目中,您应该始终在命令前加上 bundle exec,我个人将 bx 别名为 bundle exec。
你也可以使用binstubs
【解决方案2】:
尝试运行bundle update。
您的 Gemfile.lock 似乎与您的 Gemfile 不同步。