您已经激活了 X,但是您的 Gemfile 需要 Y [英] You have already activated X, but your Gemfile requires Y

查看:31
本文介绍了您已经激活了 X,但是您的 Gemfile 需要 Y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 rake 时出现此错误:

When running rake I get this error:

您已经激活了 rake 0.9.2,但是您的 Gemfile 需要 rake 0.8.7.考虑使用 bundle exec.

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

使用 bundle exec rake 而不是 rake 似乎可行,但这是解决此问题的最佳方法吗?

Using bundle exec rake instead of just rake seems to work, but is it the best way to fix this?

推荐答案

使用 bundle exec 是正确的方法.

Using bundle exec is the right way to do this.

基本上发生的事情是您已将 rake 更新到 0.9.2,这与您的 Gemfile 中指定的版本冲突.以前最新版本的 rake 与您 Gemfile 中的版本匹配,因此在简单地使用 rake 时您不会收到任何警告.

Basically what's happening is that you've updated rake to 0.9.2 which now conflicts with the version specified in your Gemfile. Previously the latest version of rake you had matched the version in your Gemfile, so you didn't get any warning when simply using rake.

Yehuda Katz(最初的 Bundler 开发人员之一)在 这篇博文.

Yehuda Katz (one of the original Bundler developers) explains it all in this blog post.

为了避免一直键入 bundle exec ...,您可以在 shell 中为您通常与 Bundler 一起使用的命令设置别名或函数.例如,这就是我用于 Rake 的内容:

To avoid typing bundle exec ... all the time, you could set up an alias or function in your shell for commands you commonly use with Bundler. For example this is what I use for Rake:

$ type bake
bake is a function
bake () 
{ 
    bundle exec rake "$@"
}

这篇关于您已经激活了 X,但是您的 Gemfile 需要 Y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆