为什么我的环境要求我运行bundle exec?
每当我运行 rake 命令(即 rake paths )时,我都会收到此错误:
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 paths ,它就会起作用。
我希望能够简单地rake paths
而不必运行bundle exec rake paths
。
我查看了具有类似错误的其他问题,并尝试了各种解决方案(例如运行bundle update
),但无济于事。
另外,在我的 gemfile
中,我指定了 gem 'rake', '0.9.2'
有什么建议吗?
Whenever I run a rake command (i.e. rake routes
) I get this error:
You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this.
If I run bundle exec rake routes
it works.
I want to be able to simply rake routes
without having to run bundle exec rake routes
.
I've looked at other questions with similar errors and tried the various solutions (like running bundle update
) to no avail.
Also, in my gemfile
I specified gem 'rake', '0.9.2'
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试执行:
您可能会看到为 rake 安装了几个版本。顺便说一句,
bundle exec
是在 Rails 应用程序上下文中执行代码的正确方法。因此,您可以使用别名来减少输入。Try to execute:
You'll probably see a couple of version installed for rake. By the way,
bundle exec
is the right way of executing your code in the context of a Rails application. So, you can use an alias for typing less.如果你使用rvm。你可以尝试以下
In case if you use rvm. you can try following
正如@lucapette所说,你可能有多个版本的rake。假设您确实想使用 0.9.2,您可以删除 0.9.2.2 版本以消除警告,然后运行捆绑安装以确保您拥有所需版本的所有正确的 gem 版本(在您的情况下为 0.9.2,在我下面的示例中为 0.8.7)。
步骤如下:
As @lucapette said, you probably have multiple versions of rake. Assuming you do want to use 0.9.2 you can remove the 0.9.2.2 version to get rid of the warning then run bundle install to ensure you have all the right gem versions for the version you do want (0.9.2 in your case, 0.8.7 in the my example below).
Here are the steps:
如果 gemfile 中的某些 gem 需要旧版本的 Rake,则您可能会看到此消息。也许您已经更新了 rake。您通常可以通过更新 gem 来修复它。运行:
这将使用 gemfile 中最新的 gem 更新您的包。这可能会解决耙子不兼容性的问题。
You may see this message if some of the gems in your gemfile require an older version of Rake to the one you have installed. Perhaps you have updated rake. You can often fix it by updating your gems. Run:
This will update your bundle using the most recent gems in your gemfile. This will likely fix the rake incompatibility.