为什么我的环境要求我运行bundle exec?

发布于 2024-12-14 20:53:22 字数 477 浏览 6 评论 0原文

每当我运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

紫竹語嫣☆ 2024-12-21 20:53:22

尝试执行:

gem list

您可能会看到为 rake 安装了几个版本。顺便说一句,bundle exec 是在 Rails 应用程序上下文中执行代码的正确方法。因此,您可以使用别名来减少输入。

Try to execute:

gem list

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.

情独悲 2024-12-21 20:53:22

如果你使用rvm。你可以尝试以下

rvm gem list

In case if you use rvm. you can try following

rvm gem list
醉梦枕江山 2024-12-21 20:53:22

正如@lucapette所说,你可能有多个版本的rake。假设您确实想使用 0.9.2,您可以删除 0.9.2.2 版本以消除警告,然后运行捆绑安装以确保您拥有所需版本的所有正确的 gem 版本(在您的情况下为 0.9.2,在我下面的示例中为 0.8.7)。

步骤如下:

$ gem list

*** LOCAL GEMS ***

...
rake (0.9.2.2, 0.8.7)
...

$ gem uninstall rake

Select gem to uninstall:
 1. rake-0.8.7
 2. rake-0.9.2.2
 3. All versions
> 2

You have requested to uninstall the gem:
        rake-0.9.2.2
addressable-2.2.6 depends on [rake (>= 0.7.3)]
...
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled rake-0.9.2.2
INFO:  gem "0.9.2.2" is not installed

$ bundle install

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:

$ gem list

*** LOCAL GEMS ***

...
rake (0.9.2.2, 0.8.7)
...

$ gem uninstall rake

Select gem to uninstall:
 1. rake-0.8.7
 2. rake-0.9.2.2
 3. All versions
> 2

You have requested to uninstall the gem:
        rake-0.9.2.2
addressable-2.2.6 depends on [rake (>= 0.7.3)]
...
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled rake-0.9.2.2
INFO:  gem "0.9.2.2" is not installed

$ bundle install
昵称有卵用 2024-12-21 20:53:22

如果 gemfile 中的某些 gem 需要旧版本的 Rake,则您可能会看到此消息。也许您已经更新了 rake。您通常可以通过更新 gem 来修复它。运行:

bundle update

这将使用 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:

bundle update

This will update your bundle using the most recent gems in your gemfile. This will likely fix the rake incompatibility.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文