[rubygems/rubygems] Restore working bundle check behaviour

As part of a recent bug fix where bundler was accidentally hitting the
network when not supposed to, I made some refactoring, and the commit I'm
reverting here
(d74830d00b)
was some cleanup that those refactorings allowed according to "past me".

That was completely wrong, `bundle check` should never consider cached
gems, only installed gems, so the code that was removed was necessary.

https://github.com/rubygems/rubygems/commit/5483e98305
This commit is contained in:
David Rodríguez 2021-08-18 09:58:51 +02:00 committed by Hiroshi SHIBATA
parent 71f6711351
commit 3683781f53
Notes: git 2021-08-31 19:07:06 +09:00
6 changed files with 35 additions and 1 deletions

View File

@ -15,7 +15,7 @@ module Bundler
definition.validate_runtime!
begin
definition.resolve_with_cache!
definition.resolve_only_locally!
not_installed = definition.missing_specs
rescue GemNotFound, VersionConflict
Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."

View File

@ -166,6 +166,12 @@ module Bundler
@multisource_allowed
end
def resolve_only_locally!
@remote = false
sources.local_only!
resolve
end
def resolve_with_cache!
sources.cached!
resolve

View File

@ -36,6 +36,8 @@ module Bundler
def local!; end
def local_only!; end
def cached!; end
def remote!; end

View File

@ -26,6 +26,12 @@ module Bundler
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
end
def local_only!
@specs = nil
@allow_local = true
@allow_remote = false
end
def local!
return if @allow_local

View File

@ -136,6 +136,10 @@ module Bundler
different_sources?(lock_sources, replacement_sources)
end
def local_only!
all_sources.each(&:local_only!)
end
def cached!
all_sources.each(&:cached!)
end

View File

@ -137,6 +137,22 @@ RSpec.describe "bundle check" do
expect(exitstatus).to eq(1)
end
it "ensures that gems are actually installed and not just cached in applications' cache" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G
bundle "config set --local path vendor/bundle"
bundle :cache
gem_command "uninstall rack", :env => { "GEM_HOME" => vendored_gems.to_s }
bundle "check", :raise_on_error => false
expect(err).to include("* rack (1.0.0)")
expect(exitstatus).to eq(1)
end
it "ignores missing gems restricted to other platforms" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"