Bundle install runs twice on Mac
➜ k_rails_template git:(main) ✗ bundle install
Using Local GEMs
Using Local GEMs <----
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/........... <----
Resolving dependencies....
Using rake 12.3.3
.
.
.
I have checked the various .zsh configurations to find out if there is something going on there and I have reinstalled a fresh Ruby 2.7.6
using asdf
.
I manually checked these files to see if there was an issue
- .zshenv
- .zprofile
- .zshrc
Gem File
# frozen_string_literal: true
source 'https://rubygems.org'
gemspec
puts 'Using Local GEMs'
group :development, :test do
gem 'guard-bundler'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'rake', '~> 12.0'
gem 'rake-compiler', require: false
gem 'rspec', '~> 3.0'
gem 'rubocop'
gem 'rubocop-rake', require: false
gem 'rubocop-rspec', require: false
end
group :test do
gem 'simplecov', require: false
end
gem env
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.6
- RUBY VERSION: 2.7.6 (2022-04-12 patchlevel 219) [x86_64-darwin21]
- INSTALLATION DIRECTORY: /Users/xmen/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/xmen/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/xmen/.asdf/installs/ruby/2.7.6/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /Users/xmen/.asdf/installs/ruby/2.7.6/bin
- SPEC CACHE DIRECTORY: /Users/xmen/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/xmen/.asdf/installs/ruby/2.7.6/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-21
- GEM PATHS:
- /Users/xmen/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0
- /Users/xmen/.gem/ruby/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/xmen/.asdf/installs/ruby/2.7.6/bin
- /usr/local/opt/[email protected]/bin
- /Users/xmen/.asdf/shims
- /Users/xmen/.asdf/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/go/bin
- /usr/local/MacGPG2/bin
- /usr/local/share/dotnet
- ~/.dotnet/tools
- /Library/Apple/usr/bin
- /Library/Frameworks/Mono.framework/Versions/Current/Commands
- /Users/xmen/Library/Python/3.9/bin
- /Users/xmen/.dotnet/tools
- /Users/xmen/.gem/ruby/2.7.0/bin
- /usr/local/opt/fzf/bin
CodePudding user response:
bundle install
is not running twice. It is the internal bundler logic that does the second fetch.
# Gemfile
source "https://rubygems.org"
gem "guard-bundler"
For example, using bundler v2.2.6 the above Gemfile will make bundler run two fetch requests.
Fetching gem metadata from https://rubygems.org/..............
Fetching gem metadata from https://rubygems.org/.
The second request comes from double checking logic:
https://github.com/rubygems/rubygems/blob/bundler-v2.2.6/bundler/lib/bundler/source/rubygems.rb#L261
Surprisingly, the second fetch was double checking for bundler gem itself. This pull request fixed that in v2.2.7.
Upgrading to bundler v2.2.7 issues only a single request. However, with more gems in the Gemfile there will be more to double check for bundler. I'd assume there are more performance/logic improvements with later versions as well.
You can see why bundler is running a second fetch by using --verbose
option:
$ bundle update --verbose
...
Double checking for ["bundler"] in rubygems repository https://rubygems.org/ or installed locally
Fetching gem metadata from https://rubygems.org/
Looking up gems ["bundler"]
...