Bundler:始终在 Gemfile 中使用最新版本的 git branch

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8324334/
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-19 06:12:38  来源:igfitidea点击:

Bundler: always use latest revision of git branch in Gemfile

rubygitbundlergemfile

提问by pithyless

I have a Gemfile with a private git repo in the following format:

我有一个带有以下格式的私有 git 存储库的 Gemfile:

gem 'magic_beans', :git => "[email protected]:magic_beans.git', :branch => 'super_beans'

gem 'magic_beans', :git => "[email protected]:magic_beans.git', :branch => 'super_beans'

When I bundle install, the Gemfile.lock locks it to a specific SHA revision.

当 I 时bundle install,Gemfile.lock 将其锁定到特定的 SHA 修订版。

Can I get bundler to always check and use the latest SHA commit and/or update the Gemfile.lock? Notice that when I push updates to the super_beansbranch I am not modifying the gem version.

我可以让捆绑程序始终检查和使用最新的 SHA 提交和/或更新 Gemfile.lock 吗?请注意,当我将更新推送到super_beans分支时,我并没有修改 gem 版本。

Ideally, every time I run bundleit would check upstream git repo for a newer SHA revision of the branch.

理想情况下,每次我运行bundle它都会检查上游 git repo 以获取分支的更新 SHA 修订版。

回答by Matthew Rudy

This isn't how bundler works. The point is to allow seamless versioning of dependencies. (particularly so you know exactly what version of the code is deployed at any given time).

这不是捆绑程序的工作方式。关键是允许对依赖项进行无缝版本控制。(特别是让您确切地知道在任何给定时间部署的代码版本)。

If want the latest version, you should just run.

如果想要最新版本,你应该运行。

bundle update magic_beans

This is exactly the same functionality as if you just say

这和你刚才说的功能完全一样

gem "rails"

I'd suggest though, if you have a range of specific things you want to update then add a custom binary (say an executable file named bundle_update)

不过,我建议,如果您有一系列要更新的特定内容,请添加自定义二进制文件(例如名为 的可执行文件bundle_update

#!/usr/bin/env bash
bundle install
bundle update magic_beans

Then just do a ./bundle_updatewhen you want to update these things.

然后./bundle_update在你想更新这些东西的时候做一个。

回答by leonardoborges

You can run bundle updateto update all or specific gems to their latest available version, as stated in the docs.

您可以运行bundle update以将所有或特定 gem 更新为其最新可用版本,如文档中所述。

Would that help?

那会有帮助吗?

回答by Michael Yin

After searching through the documents I finally found the magic way to do this:

在搜索文档后,我终于找到了执行此操作的神奇方法:

bundle update magic_beans --source magic_beans

bundle update magic_beans --source magic_beans

That is to update the magic_beansgem only, but not to touch other locked gems. The doc about this is: http://bundler.io/man/bundle-update.1.html

也就是magic_beans只更新宝石,不接触其他锁定的宝石。关于这个的文档是:http: //bundler.io/man/bundle-update.1.html

回答by Fabián Contreras

delete .gemlock is what worked for me :/

删除 .gemlock 对我有用:/