ruby 使用捆绑器仅更新一颗 gem

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11263150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:14:33  来源:igfitidea点击:

Update just one gem with bundler

rubyrubygemsbundler

提问by sailor

I use bundler to manage dependencies in my rails app, and I have a gem hosted in a git repository included as followed:

我使用 bundler 来管理 Rails 应用程序中的依赖项,并且我在 git 存储库中托管了一个 gem,如下所示:

gem 'gem-name', :git => 'path/to/my/gem.git'

To update this gem, I execute bundle updatebut it also updates all the gem mentioned in Gemfile. So what is the command to update just one specific gem?

为了更新这个 gem,我执行bundle update但它也更新了 Gemfile 中提到的所有 gem。那么只更新一个特定 gem 的命令是什么?

回答by mseebacher

Hereyou can find a good explanation on the difference between

在这里你可以找到一个很好的解释

Update both gem and dependencies:

更新 gem 和依赖项:

bundle update gem-name 

or

或者

Update exclusively the gem:

仅更新 gem:

bundle update --source gem-name

along with some nice examples of possible side-effects.

以及一些可能的副作用的好例子。

Update

更新

As @Tim's answer says, as of Bundler 1.14 the officially-supported way to this is with bundle update --conservative gem-name.

正如@Tim 的回答所说,从 Bundler 1.14 开始,官方支持的方法是使用bundle update --conservative gem-name.

回答by dukz

The way to do this is to run the following command:

执行此操作的方法是运行以下命令:

bundle update --source gem-name

回答by Tim

It appears that with newer versions of bundler (>= 1.14) it's:

看来,使用较新版本的捆绑程序(> = 1.14),它是:

bundle update --conservative gem-name

回答by Brandan

You simply need to specify the gem name on the command line:

您只需要在命令行上指定 gem 名称:

bundle update gem-name

回答by Linus

bundle update gem-name [--major|--patch|--minor]

bundle update gem-name [--major|--patch|--minor]

This also works for dependencies.

这也适用于依赖项。

回答by Kitto

I've used bundle update --sourcemyself for a long time but there are scenarios where it doesn't work. Luckily, there's a gem called bundler-patchwhich has the goal of fixing this shortcoming.

我自己使用bundle update --source了很长时间,但有些情况下它不起作用。幸运的是,有一个名为 gembundler-patch的目标是修复这个缺点。

I also wrote a short blog postabout how to use bundler-patchand why bundle update --sourcedoesn't work consistently. Also, be sure to check out a postby chrismo that explains in great detail what the --sourceoption does.

我还写了一篇关于如何使用bundler-patch以及为什么bundle update --source不能始终如一地工作的简短博客文章。另外,请务必查看chrismo的帖子,其中详细解释了该--source选项的作用。

回答by shushugah

bundler update --source gem-namewill update the revision hash in Gemfile.lock which you can compare with the last commit hash of that git branch (master by default).

bundler update --source gem-name将更新 Gemfile.lock 中的修订哈希,您可以将其与该 git 分支(默认为 master)的最后一次提交哈希进行比较。

GIT remote: [email protected]:organization/repo-name.git revision: c810f4a29547b60ca8106b7a6b9a9532c392c954

GIT remote: [email protected]:organization/repo-name.git revision: c810f4a29547b60ca8106b7a6b9a9532c392c954

can be found at github.com/organization/repo-name/commits/c810f4a2(I used shorthand 8 character commit hash for the url)

可以在github.com/organization/repo-name/commits/c810f4a2(我使用速记 8 字符提交哈希作为 url)