【发布时间】:2011-12-27 17:04:52
【问题描述】:
每当我运行 rake 命令(即rake routes)时,我都会收到此错误:
You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this.
如果我运行bundle exec rake routes,它会起作用。
我希望能够简单地 rake routes 而不必运行 bundle exec rake routes。
我查看了其他具有类似错误的问题,并尝试了各种解决方案(例如运行bundle update),但均无济于事。
另外,在我的gemfile 中,我指定了gem 'rake', '0.9.2'
有什么建议吗?
【问题讨论】:
-
快速更新。最近从 RailsTutorial 中发现了这个关于需要使用
bundle exec的解释:“正如第 3.2.1 节中简要提到的,通常有必要在 bundle exec 中添加诸如 rake 或 rspec 之类的命令前缀,以便程序在确切的 gem 中运行由 Gemfile 指定的环境。(出于技术原因,唯一的例外是 rails 命令本身。)”此外,“只要 RVM 的版本号为 1.11.x 或更高,安装的 gem 将自动在适当的 Bundler 中执行环境”,因此不需要bundle exec前缀。
标签: ruby-on-rails ruby-on-rails-3 rake gemfile