rubygems
rubygems copied to clipboard
bundle install --local tries to access rubygems.org
Describe the problem as clearly as you can
I'm running Bundler for benchmarking in some infrastructure which does not have internet access. I'm running with multiple Ruby versions, so they don't all have the same Bundler. I run it like:
$ bundle config --local cache_path some/path
$ bundle config --local without postgresql mysql
$ bundle config --local path vendor/bundle
$ bundle install --local --no-cache
However this unexpectedly tries to reach to rubygems.org, which fails but takes a long time to fail.
If bundler 2.3.26 is not in the cache_path:
$ bundle install --local --no-cache
Bundler 2.3.7 is running, but your lockfile was generated with 2.3.26. Installing Bundler 2.3.26 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.26
Installing bundler 2.3.26
Installing rake 13.0.6
Installing mini_mime 1.1.2
Using bundler 2.3.26
...
...
If bundler 2.3.26 is in the cache_path, it still queries rubygems.org, that sounds like a bug:
$ bundle install --local --no-cache
Bundler 2.3.7 is running, but your lockfile was generated with 2.3.26. Installing Bundler 2.3.26 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Installing bundler 2.3.26
Installing rake 13.0.6
Installing marcel 1.0.2
Using bundler 2.3.26
...
Without internet access and without bundler 2.3.26 in cache_path it looks like:
$ bundle install --local --no-cache
Bundler 2.3.7 is running, but your lockfile was generated with 2.3.26. Installing Bundler 2.3.26 and restarting using that version.
Bundler 2.3.7 is running, but your lockfile was generated with 2.3.26. Installing Bundler 2.3.26 and restarting using that version.
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Errno::ENETUNREACH: Failed to open TCP connection to rubygems.org:443 (Network is unreachable - connect(2) for [2a04:4e42:200::483]:443) (https://rubygems.org/specs.4.8.gz)>
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Errno::ENETUNREACH: Failed to open TCP connection to rubygems.org:443 (Network is unreachable - connect(2) for [2a04:4e42:200::483]:443) (https://rubygems.org/specs.4.8.gz)>
There was an error installing the locked bundler version (2.3.26), rerun with the `--verbose` flag for more details. Going on using bundler 2.3.7.
Fetching source index from https://rubygems.org/
Fetching source index from https://rubygems.org/
Installing rake 13.0.6
...
Did you try upgrading rubygems & bundler?
That's not possible since the Ruby being benchmarked is installed in a system location.
If not included with the output of your command, run bundle env and paste the output below
I'm running this on Ruby 3.1.2, which ships with Bundler 2.3.7. The Gemflie.lock is BUNDLED WITH 2.3.26.
Environment
Bundler 2.3.7
Platforms ruby, x86_64-linux
Ruby 3.1.2p20 (2022-04-12 revision 4491bb740a9506d76391ac44bb2fe6e483fec952) [x86_64-linux]
Full Path /home/eregon/.rubies/ruby-3.1.2/bin/ruby
Config Dir /home/eregon/.rubies/ruby-3.1.2/etc
RubyGems 3.3.7
Gem Home /home/eregon/code/truffleruby-ws/truffleruby/test/truffle/ecosystem/blog6/vendor/bundle/ruby/3.1.0
Gem Path /home/eregon/code/truffleruby-ws/truffleruby/test/truffle/ecosystem/blog6/vendor/bundle/ruby/3.1.0
User Home /home/eregon
User Path /home/eregon/.local/share/gem/ruby/3.1.0
Bin Dir /home/eregon/code/truffleruby-ws/truffleruby/test/truffle/ecosystem/blog6/vendor/bundle/ruby/3.1.0/bin
Tools
Git 2.35.1
RVM not installed
rbenv not installed
chruby 0.3.9
Bundler Build Metadata
Built At 2023-02-23
Git SHA unknown
Released Version false
Bundler settings
cache_path
Set for your local app (/home/eregon/code/truffleruby-ws/truffleruby/test/truffle/ecosystem/blog6/.bundle/config): "/home/eregon/code/truffleruby-ws/truffleruby/truffleruby-gem-test-pack/gem-cache"
path
Set for your local app (/home/eregon/code/truffleruby-ws/truffleruby/test/truffle/ecosystem/blog6/.bundle/config): "vendor/bundle"
without
Set for your local app (/home/eregon/code/truffleruby-ws/truffleruby/test/truffle/ecosystem/blog6/.bundle/config): [:postgresql, :mysql]
Gemfile
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '>= 2.3.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0'
group :postgresql do
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
end
group :mysql do
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
end
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# App-specific
gem 'asciidoctor'
# Use a more recent mail gem to have the correct dependencies
gem 'mail', '>= 2.8.0.rc1'
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.4.1)
actionpack (= 6.1.4.1)
activesupport (= 6.1.4.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.4.1)
actionpack (= 6.1.4.1)
activejob (= 6.1.4.1)
activerecord (= 6.1.4.1)
activestorage (= 6.1.4.1)
activesupport (= 6.1.4.1)
mail (>= 2.7.1)
actionmailer (6.1.4.1)
actionpack (= 6.1.4.1)
actionview (= 6.1.4.1)
activejob (= 6.1.4.1)
activesupport (= 6.1.4.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.4.1)
actionview (= 6.1.4.1)
activesupport (= 6.1.4.1)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.4.1)
actionpack (= 6.1.4.1)
activerecord (= 6.1.4.1)
activestorage (= 6.1.4.1)
activesupport (= 6.1.4.1)
nokogiri (>= 1.8.5)
actionview (6.1.4.1)
activesupport (= 6.1.4.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.4.1)
activesupport (= 6.1.4.1)
globalid (>= 0.3.6)
activemodel (6.1.4.1)
activesupport (= 6.1.4.1)
activerecord (6.1.4.1)
activemodel (= 6.1.4.1)
activesupport (= 6.1.4.1)
activestorage (6.1.4.1)
actionpack (= 6.1.4.1)
activejob (= 6.1.4.1)
activerecord (= 6.1.4.1)
activesupport (= 6.1.4.1)
marcel (~> 1.0.0)
mini_mime (>= 1.1.0)
activesupport (6.1.4.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
asciidoctor (2.0.16)
builder (3.2.4)
concurrent-ruby (1.1.9)
crass (1.0.6)
erubi (1.10.0)
ffi (1.15.4)
globalid (0.5.2)
activesupport (>= 5.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jbuilder (2.11.2)
activesupport (>= 5.0.0)
loofah (2.12.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.8.0.rc1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
minitest (5.14.4)
mysql2 (0.5.3)
net-imap (0.3.1)
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.1.3)
timeout
net-smtp (0.3.2)
net-protocol
nio4r (2.5.8)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
pg (1.2.3)
puma (3.12.6)
racc (1.5.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.4.1)
actioncable (= 6.1.4.1)
actionmailbox (= 6.1.4.1)
actionmailer (= 6.1.4.1)
actionpack (= 6.1.4.1)
actiontext (= 6.1.4.1)
actionview (= 6.1.4.1)
activejob (= 6.1.4.1)
activemodel (= 6.1.4.1)
activerecord (= 6.1.4.1)
activestorage (= 6.1.4.1)
activesupport (= 6.1.4.1)
bundler (>= 1.15.0)
railties (= 6.1.4.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (6.1.4.1)
actionpack (= 6.1.4.1)
activesupport (= 6.1.4.1)
method_source
rake (>= 0.13)
thor (~> 1.0)
rake (13.0.6)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
thor (1.1.0)
tilt (2.0.10)
timeout (0.3.0)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.2)
PLATFORMS
ruby
DEPENDENCIES
asciidoctor
jbuilder (~> 2.5)
mail (>= 2.8.0.rc1)
mysql2 (>= 0.4.4, < 0.6.0)
pg (>= 0.18, < 2.0)
puma (~> 3.11)
rails (~> 6.0)
sass-rails (>= 6)
sqlite3
turbolinks (~> 5)
tzinfo-data
RUBY VERSION
ruby 2.4.4p0 (truffleruby 0.0-c3a45cc6)
BUNDLED WITH
2.3.26
BTW, is there a way to disable this "install the BUNDLED WITH Bundler"? It could be a useful workaround here and in various other situations.
Also to add to eregon's example (and I pointed this out on another issue at the core bug tracker of ruby) - there are situations when sometimes some of the internet works, but other parts do not work. For instance, I currently have access to the internet on my main machine, and I can install gems again (I could not a few days ago), so HTTPS works somewhat.
But when I recently tried to compile something that depended on rust, rust wanted to download something from the internet, but curl is somehow bugged on my system right now, so that step failed. And, in consequence, the whole compile-attempt failed (I think I tried to compile librsvg; there is something messed up with openssl on my system, but I managed to get gems to work, so I can upload/publish gems, and I stopped investigating it further as that is my main use case actually. chrome-browser seems to be doing just fine even with https-sites here, curl for some reason struggles though - no idea why rust requires internet connection, I think this is bad design that appears to have increased in the last some years, where it is automatically assumed that an internet connection must exist, and it must work flawlessly when it does, which I think is a simplistic assumption rather than solid engineering. I guess everyone who encounters similar problems will understand eregon's problem quickly).
So, I think in general, the best strategy is to not depend on internet access IF that is possible, and start from there. And when it works, it's ok to go that route - but before that happens, we should try to make sure that all the core parts work as much as that is possible, e. g. in eregon's example, to not have to depend on an internet connection if we can avoid it before we have to depend on it.
WORKAROUND: Specifying a Bundler version using bundle _$VERSION_ ... disables that functionality, so for now you can do something like: bundle _2.3.7_ install --local --no-cache.
That said, this functionality should definitely respect --local, and print a warning or similar instead of trying to auto-install the appropriate Bundler version in that case.
I also think it makes sense to have the auto-installing functionality able to be disabled entirely — probably replacing it with the same warning as --local would have.
https://github.com/rubygems/rubygems/pull/5182/commits/f63d08647a80f0024a1633414284a279ceb44564 is probably a good place to look for writing a failing spec for this
Another workaround is to remove the BUNDLED WITH section, but that needs to be done manually so rather messy.
(it makes a lot of sense for Gemfile.lock files in TruffleRuby repo though as we never want to use another Bundler than the one shipped by TruffleRuby for TruffleRuby tests)
For another workaround, running with BUNDLE_VERSION=system will skip the trampolining as well, iirc