不了解捆扎机与宝石的相互作用 [英] Don't Understand Bundler Interaction with Gems

查看:91
本文介绍了不了解捆扎机与宝石的相互作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为我了解Bundler如何处理宝石,但是在最近发生一些事情之后,我不确定我是否正确。

I thought I understood how Bundler works with gems, but after something that recently happened, I am not sure I have it right.

我正在开发Rails应用程序。首先(为了让我熟悉以前未使用过的Rails环境),我没有使用IDE。但是,由于我错过了IDE的某些优势,因此我才开始使用RubyMine。作为RubyMine设置的一部分,它要求更新我现有项目的所有gem。

I am developing an Rails application. To start off (and just so I would get familiar with the Rails environment which I haven't worked in before), I did not use an IDE. But, because I'm missing out on some of the advantages of an IDE, I just started using RubyMine. As part of the RubyMine setup, it asked to update all my gems for my existing project.

在那之后,我无法运行 rake [anything]。每次这样做,我都会收到以下错误:

After that, I could not run "rake [anything]". Every time I did, I received an error of:


您已经激活了rake 0.9.3.beta.1,但是您的Gemfile
的要求为0.9.2.2。使用bundle exec可以解决这个问题。

You have already activated rake 0.9.3.beta.1, but your Gemfile requires rake 0.9.2.2. Using bundle exec may solve this.

我可以更新到下一个版本的rake-没问题-但是我首先不明白发生了什么。发生了什么事,我激活了较新版本的rake。最终,我最终通过将

I was okay updating to the next version of rake - that wasn't a problem - but I don't understand what happened in the first place. What happened that I "activated" a newer version of rake. Ultimately, I ended up solving the problem by putting

gem 'rake', '0.9.3.beta.1'

在我的Gemfile中并运行

in my Gemfile and running

bundle update rake

但是,我仍然不确定这里发生了什么。如果我以前使用过9.2.2,为什么会突然被炸毁,又如何在将来防止这种情况发生?

But, I'm still not sure what happened here. If I was using 9.2.2 before, why did it all of a sudden blow up like that and how can I prevent that in the future?

推荐答案

您应该真正考虑安装和使用 RVM Rbenv 来管理您的红宝石版本和宝石集。如果您采用Rbenv方式,则可以使用 rbenv-gemset 插件

You should really consider installing and using RVM or Rbenv to manage your ruby versions and gemsets. If you go the Rbenv way, the rbenv-gemset plugin can be used to manage gemsets similar to how RVM natively does.


您已经激活了rake 0.9.3.beta.1,但是您的Gemfile需要耙0.9.2.2。使用bundle exec可以解决这个问题。

You have already activated rake 0.9.3.beta.1, but your Gemfile requires rake 0.9.2.2. Using bundle exec may solve this.

在最后一个软件包之间执行和安装/配置/运行RubyMine,您必须已安装 rake 0.9.3.beta.1 。因为您不是通过RVM或Rbenv这样的宝石集来管理宝石,所以Rake的默认版本为 0.9.3.beta.1 ,而不是已安装的版本。通过捆绑程序, 0.9.2.2

At some point between your last bundle execution and installing/configuring/running RubyMine you must have installed rake 0.9.3.beta.1. Because you're not managing your gems through gemsets like RVM or Rbenv will do for you, the default version of Rake became 0.9.3.beta.1 instead of the version installed by bundler, 0.9.2.2.

上述错误表明您的 Gemfile 有类似

The above error suggests your Gemfile had something like

gem 'rake', '0.9.2.2'

不允许使用rake的版本,但 0.9.2.2

which does not allow the version of rake being used to be anything but 0.9.2.2.

如果您确实在系统上除之外还具有 0.9.2.2 0.9.3.beta.1 Gemfile 配置为 0.9.2.2 ,而不是运行

If you do in fact have 0.9.2.2 on your system in addition to the 0.9.3.beta.1 and your Gemfile is configured for 0.9.2.2, instead of running

rake some:task

您可以运行

bundle exec rake some:task

,捆绑程序将通过运行 some:task 0.9.2.2 版本的rake。与 bundle exec ... 一起通过捆绑程序运行 Gemfile 中发现的与宝石有关的任务被认为是一种好习惯RVM或Rbenv。

and bundler will run some:task through the 0.9.2.2 version of rake. Running tasks related to gems found in a Gemfile through bundleer with bundle exec ... is considered good practice regardless of using RVM or Rbenv.

您可以阅读有关捆绑执行程序 此处

You can read about bundle exec here.

这篇关于不了解捆扎机与宝石的相互作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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