bundle exec rake db:migrate导致“找不到可执行的rake”错误。

8

我最近安装了Rails 3.1,现在我的旧的Rails 3.0应用无法运行rake db:migrate命令。当我尝试运行bundle exec rake db:migrate时,会出现以下情况。我使用Ubuntu操作系统,并没有安装RVM。

/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:142:in `block in cripple_rubygems': can't find executable rake (Gem::Exception)
    from /usr/local/lib/ruby/gems/1.9.1/bin/rake:19:in `<main>'

当我运行rake db:migrate命令时,它会输出以下内容:

rake aborted!
You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.8.7. Consider using bundle exec.

(See full trace by running task with --trace)

哪个版本的rake
/usr/local/bin/rake
1个回答

11

将以下内容添加到您的Gemfile中:

gem 'rake' , '>= 0.9.2'

并运行 bundle update


你需要提供更多细节,说明你正在使用什么环境:

  • 使用哪个操作系统?
  • 你是否使用 RVM?
  • 这是全新的 RVM 设置吗?

1)请尝试运行以下命令:

gem list | rake

你得到了什么输出?

2) 如果你在输出中没有看到rake,那么请执行以下操作:

gem install rake 

然后再尝试运行rake db:migrate

3) 如果你看到rake,但它还是无法工作,则执行以下操作:

which rake

你得到了什么输出?它应该看起来像这样:

~/.rvm/gems/ruby-1.9.2-p0/bin/rake

gem list | rake 输出: 你已经激活了 rake 0.9.2.2,但是你的 Gemfile 需要 rake 0.8.7。考虑使用 bundle exec。 - go minimal
那很容易!旧版的Rake与Rails 3.1.1不兼容-您需要在Gemfile中增加rake的版本号!将以下内容添加到您的Gemfile中:gem' rake','>=0.9.2',然后运行 bundle update - Tilo
2
添加 :require => false,通常情况下你不需要一直 require rake。 - Marian Theisen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接