Rubygems: Bundle caching running multiple times

Created on 7 Jan 2021  路  3Comments  路  Source: rubygems/rubygems

Describe the problem as clearly as you can

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.

Post steps to reproduce the problem

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.

What were you expecting to happen?

bundle cache does not attempt to update the cache more than once, regardless of the # of times it's run.

What actually happened?

bundle cache appears to run twice on all but the first invocation.

Environment

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

Bundler Build Metadata

Built At          2021-01-07
Git SHA           unknown
Released Version  false

Bundler settings

  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

Gemfile

Gemfile

# frozen_string_literal: true

source 'https://rubygems.org'

ruby '2.7.2'

gem 'nokogiri'

Gemfile.lock

  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
Bundler

All 3 comments

Thanks @agrobbin, I'll have a look!

@agrobbin I created a fix for this at #4304 :+1:.

Awesome, thanks @deivid-rodriguez!

Was this page helpful?
0 / 5 - 0 ratings