[rubygems/rubygems] Fix standalone install of default gems

Rubygems source replacement was broken.

https://github.com/rubygems/rubygems/commit/3549c122f6
This commit is contained in:
David Rodríguez 2021-07-25 16:23:15 +02:00 коммит произвёл Hiroshi SHIBATA
Родитель 9e7249da4e
Коммит c2f376bcc0
3 изменённых файлов: 51 добавлений и 2 удалений

Просмотреть файл

@ -195,6 +195,7 @@ module Bundler
platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
@current_spec = LazySpecification.new(name, version, platform)
@current_spec.source = @current_source
@current_source.add_dependency_names(name)
@specs[@current_spec.identifier] = @current_spec
elsif spaces.size == 6

Просмотреть файл

@ -121,7 +121,8 @@ module Bundler
def replace_sources!(replacement_sources)
return false if replacement_sources.empty?
@path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
@rubygems_sources, @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
@global_rubygems_source = global_replacement_source(replacement_sources)
different_sources?(lock_sources, replacement_sources)
end
@ -156,13 +157,21 @@ module Bundler
end
def map_sources(replacement_sources)
[path_sources, git_sources, plugin_sources].map do |sources|
[@rubygems_sources, @path_sources, @git_sources, @plugin_sources].map do |sources|
sources.map do |source|
replacement_sources.find {|s| s == source } || source
end
end
end
def global_replacement_source(replacement_sources)
replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
return global_rubygems_source unless replacement_source
replacement_source.local!
replacement_source
end
def different_sources?(lock_sources, replacement_sources)
!equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
end

Просмотреть файл

@ -108,6 +108,45 @@ RSpec.shared_examples "bundle install --standalone" do
include_examples "common functionality"
end
describe "with default gems and a lockfile", :ruby_repo do
before do
skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2
skip "does not work on old rubies because the realworld gems that need to be installed don't support them" if RUBY_VERSION < "2.7.0"
realworld_system_gems "fiddle --version 1.0.6", "tsort --version 0.1.0"
necessary_system_gems = ["optparse --version 0.1.1", "psych --version 3.3.2", "yaml --version 0.1.1", "logger --version 1.4.3", "etc --version 1.2.0"]
necessary_system_gems += ["shellwords --version 0.1.0", "base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.3.a")
realworld_system_gems(*necessary_system_gems, :path => scoped_gem_path(bundled_app("bundle")))
build_gem "foo", "1.0.0", :to_system => true, :default => true do |s|
s.add_dependency "bar"
end
build_gem "bar", "1.0.0", :to_system => true, :default => true
build_repo4 do
build_gem "foo", "1.0.0" do |s|
s.add_dependency "bar"
end
build_gem "bar", "1.0.0"
end
gemfile <<-G
source "https://gem.repo4"
gem "foo"
G
bundle "lock", :dir => cwd, :artifice => "compact_index"
end
it "works" do
bundle "config set --local path #{bundled_app("bundle")}"
bundle :install, :standalone => true, :dir => cwd, :artifice => "compact_index", :env => { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }
end
end
describe "with gems with native extension", :ruby_repo do
before do
bundle "config set --local path #{bundled_app("bundle")}"