When running bundle cache, it appears the cache is actually being updated multiple times, resulting in much slower performance when dealing with particularly large bundles.
Consider the Gemfile included in the bundle env output below ...
The first time bundle cache is run, this is the output:
Using bundler 2.3.0.dev
Using racc 1.5.2
Using nokogiri 1.11.1 (x86_64-darwin)
Bundle complete! 1 Gemfile dependency, 3 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Updating files in vendor/cache
* racc-1.5.2.gem
* nokogiri-1.11.1-x86_64-darwin.gem
Seems normal! What's weird is what happens any subsequent time bundle cache is run:
Using bundler 2.3.0.dev
Using racc 1.5.2
Using nokogiri 1.11.1 (x86_64-darwin)
Updating files in vendor/cache
Bundle complete! 1 Gemfile dependency, 3 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Updating files in vendor/cache
Notice the 2nd Updating line at the bottom of the output!
With a small Gemfile like this, this might not be a huge concern, but in an application with a couple hundred dependencies, some of which with platform-specific versions, this gets very slow.
bundle cache does not attempt to update the cache more than once, regardless of the # of times it's run.
bundle cache appears to run twice on all but the first invocation.
Bundler 2.3.0.dev
Platforms ruby, x86_64-darwin-19
Ruby 2.7.2p137 (2020-10-01 revision 5445e0435260b449decf2ac16f9d09bae3cafe72) [x86_64-darwin19]
Full Path /usr/local/var/rbenv/versions/2.7.2/bin/ruby
Config Dir /usr/local/var/rbenv/versions/2.7.2/etc
RubyGems 3.3.0.dev
Gem Home /usr/local/var/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
Gem Path /Users/alexrobbin/.gem/ruby/2.7.0:/usr/local/var/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
User Home /Users/alexrobbin
User Path /Users/alexrobbin/.gem/ruby/2.7.0
Bin Dir /usr/local/var/rbenv/versions/2.7.2/bin
Tools
Git 2.30.0
RVM not installed
rbenv rbenv 1.1.2
chruby not installed
Built At 2021-01-07
Git SHA unknown
Released Version false
Set for the current user (/Users/alexrobbin/.bundle/config): 7
cache_all
Set for your local app (/Users/alexrobbin/Downloads/bundler-nokogiri/.bundle/config): false
# frozen_string_literal: true
source 'https://rubygems.org'
ruby '2.7.2'
gem 'nokogiri'
remote: https://rubygems.org/
specs:
nokogiri (1.11.1-x86_64-darwin)
racc (~> 1.4)
racc (1.5.2)
PLATFORMS
x86_64-darwin-19
DEPENDENCIES
nokogiri
RUBY VERSION
ruby 2.7.2p137
BUNDLED WITH
2.3.0.dev
Thanks @agrobbin, I'll have a look!
@agrobbin I created a fix for this at #4304 :+1:.
Awesome, thanks @deivid-rodriguez!