如何使用bundler强制更新gem?

时间:2022-06-30 00:21:41

I have a private git hosting a gem we developed. The gem got some commits, but the version did not actually changed.

我有一个私人git托管我们开发的宝石。宝石得到了一些提交,但版本实际上没有改变。

How can I force bundler to update my gem even if the version hasn't changed?

即使版本没有更改,我如何强制捆绑器更新我的gem?

I tried "bundler update mygemname" but it did not update anything.

我试过“bundler update mygemname”,但它没有更新任何内容。

Thanks

谢谢

5 个解决方案

#1


12  

that will not work - there is no "force" option - you will have to modify your .gemspec file and increase the version number, then do gem build ..., and bundle install

这将无法工作 - 没有“强制”选项 - 您将不得不修改.gemspec文件并增加版本号,然后执行gem build ...,并进行捆绑安装

It is critical for bundler to be able to read the version number from your gem, which was introduced in the .gemspec file. It's confusing not only to bundler or gem update , but also confusing to people if you forget to update the version number in the .gemspec file. They would end up having gem-files lying around, and not be able to tell which versions they are, e.g. which one is newer? (of course you could use md5-sum, but that's beside the point here).

对于bundler来说,能够从gem中读取版本号是至关重要的,这是在.gemspec文件中引入的。它不仅令人困惑的是捆绑器或gem更新,而且如果您忘记更新.gemspec文件中的版本号,也会让人感到困惑。他们最终会有宝石文件,并且无法分辨它们是哪个版本,例如:哪一个更新? (当然你可以使用md5-sum,但这不是重点)。

The best thing to do is to correct the mistake in the .gemspec file, and re-release the gem.

最好的办法是纠正.gemspec文件中的错误,然后重新发布gem。

Check the bundler source code for available options:

检查bundler源代码以获取可用选项:

e.g.: bundler-1.0.15/lib/bundler/cli.rb

例如:bundler-1.0.15 / lib / bundler / cli.rb

(search for desc "install")

(搜索desc“安装”)

#2


18  

you can also put the git hashref right in the Gemfile with the :ref option

你也可以使用:ref选项将git hashref放在Gemfile中

gem 'foo', :git => 'git://github.com/foobar/foo.git', :branch => '0.9-beta', :ref => '9af382ed'

especially useful if you don't have control over said gem, and keeps bundler from giving you a newer version in case there are breaking changes.

如果您无法控制所述gem,则特别有用,并且如果存在重大更改,则阻止bundler提供更新版本。

#3


14  

First of all, don't do that. If you change your gem, you should be updating its version number. Otherwise, it's just confusing.

首先,不要这样做。如果您更改了gem,则应更新其版本号。否则,这只是令人困惑。

If you really want to do this, however, you can apply the giant hammer of removing your gem first.

但是,如果你真的想这样做,你可以先用巨大的锤子去除你的宝石。

$ gem uninstall foo
$ bundle update

#4


8  

From version 1.11 bundle install just has a --force option that will redownload every gem even if they are already installed.

从版本1.11 bundle install只有一个--force选项,即使它们已经安装,也会重新下载每个gem。

#5


6  

This doesn't answer the exact question above, but I was searching for "How to force update a gem in bundler" on Google and this came up.

这并没有回答上面的确切问题,但我在谷歌搜索“如何强制更新捆绑包中的宝石”,这就出现了。

I'm not trying to force update a gem to rubygems.org but rather I'm trying to reinstall a gem that's installed to a bundle path on my local system. Specifically I'm trying reinstall a gem with a native extension (nokogiri).

我不是试图强制更新gem到rubygems.org,而是我试图重新安装一个安装到我本地系统上的bundle路径的gem。具体来说,我正在尝试重新安装带有原生扩展(nokogiri)的gem。

How I removed it from my project is as follows; assuming your --path is vendor/bundle and you're in the project's root, run:

我如何从我的项目中删除它如下;假设您的--path是vendor / bundle并且您在项目的根目录中,运行:

find vendor/bundle/ruby/2.0.0 -name "*nokogiri*" -depth 2

Verify these files/directories are specific to nokogiri and then remove them with:

验证这些文件/目录是否特定于nokogiri,然后使用以下命令将其删除:

find vendor/bundle/ruby/2.0.0 -name "*nokogiri*" -depth 2 | xargs rm -rf

Now you can run your bundle install command as usual:

现在您可以照常运行bundle install命令:

bundle install --path vendor/bundle

Note: You'll of course need to change 2.0.0 above to your ruby version. ls vendor/bundle/ruby to see which version bundler has installed gems for.

注意:您当然需要将2.0.0更改为您的ruby版本。 ls vendor / bundle / ruby​​来查看哪个版本的Bundler已经安装了gems。

#1


12  

that will not work - there is no "force" option - you will have to modify your .gemspec file and increase the version number, then do gem build ..., and bundle install

这将无法工作 - 没有“强制”选项 - 您将不得不修改.gemspec文件并增加版本号,然后执行gem build ...,并进行捆绑安装

It is critical for bundler to be able to read the version number from your gem, which was introduced in the .gemspec file. It's confusing not only to bundler or gem update , but also confusing to people if you forget to update the version number in the .gemspec file. They would end up having gem-files lying around, and not be able to tell which versions they are, e.g. which one is newer? (of course you could use md5-sum, but that's beside the point here).

对于bundler来说,能够从gem中读取版本号是至关重要的,这是在.gemspec文件中引入的。它不仅令人困惑的是捆绑器或gem更新,而且如果您忘记更新.gemspec文件中的版本号,也会让人感到困惑。他们最终会有宝石文件,并且无法分辨它们是哪个版本,例如:哪一个更新? (当然你可以使用md5-sum,但这不是重点)。

The best thing to do is to correct the mistake in the .gemspec file, and re-release the gem.

最好的办法是纠正.gemspec文件中的错误,然后重新发布gem。

Check the bundler source code for available options:

检查bundler源代码以获取可用选项:

e.g.: bundler-1.0.15/lib/bundler/cli.rb

例如:bundler-1.0.15 / lib / bundler / cli.rb

(search for desc "install")

(搜索desc“安装”)

#2


18  

you can also put the git hashref right in the Gemfile with the :ref option

你也可以使用:ref选项将git hashref放在Gemfile中

gem 'foo', :git => 'git://github.com/foobar/foo.git', :branch => '0.9-beta', :ref => '9af382ed'

especially useful if you don't have control over said gem, and keeps bundler from giving you a newer version in case there are breaking changes.

如果您无法控制所述gem,则特别有用,并且如果存在重大更改,则阻止bundler提供更新版本。

#3


14  

First of all, don't do that. If you change your gem, you should be updating its version number. Otherwise, it's just confusing.

首先,不要这样做。如果您更改了gem,则应更新其版本号。否则,这只是令人困惑。

If you really want to do this, however, you can apply the giant hammer of removing your gem first.

但是,如果你真的想这样做,你可以先用巨大的锤子去除你的宝石。

$ gem uninstall foo
$ bundle update

#4


8  

From version 1.11 bundle install just has a --force option that will redownload every gem even if they are already installed.

从版本1.11 bundle install只有一个--force选项,即使它们已经安装,也会重新下载每个gem。

#5


6  

This doesn't answer the exact question above, but I was searching for "How to force update a gem in bundler" on Google and this came up.

这并没有回答上面的确切问题,但我在谷歌搜索“如何强制更新捆绑包中的宝石”,这就出现了。

I'm not trying to force update a gem to rubygems.org but rather I'm trying to reinstall a gem that's installed to a bundle path on my local system. Specifically I'm trying reinstall a gem with a native extension (nokogiri).

我不是试图强制更新gem到rubygems.org,而是我试图重新安装一个安装到我本地系统上的bundle路径的gem。具体来说,我正在尝试重新安装带有原生扩展(nokogiri)的gem。

How I removed it from my project is as follows; assuming your --path is vendor/bundle and you're in the project's root, run:

我如何从我的项目中删除它如下;假设您的--path是vendor / bundle并且您在项目的根目录中,运行:

find vendor/bundle/ruby/2.0.0 -name "*nokogiri*" -depth 2

Verify these files/directories are specific to nokogiri and then remove them with:

验证这些文件/目录是否特定于nokogiri,然后使用以下命令将其删除:

find vendor/bundle/ruby/2.0.0 -name "*nokogiri*" -depth 2 | xargs rm -rf

Now you can run your bundle install command as usual:

现在您可以照常运行bundle install命令:

bundle install --path vendor/bundle

Note: You'll of course need to change 2.0.0 above to your ruby version. ls vendor/bundle/ruby to see which version bundler has installed gems for.

注意:您当然需要将2.0.0更改为您的ruby版本。 ls vendor / bundle / ruby​​来查看哪个版本的Bundler已经安装了gems。