mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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:
parent
9e7249da4e
commit
c2f376bcc0
Notes:
git
2021-08-31 19:07:25 +09:00
3 changed files with 51 additions and 2 deletions
|
@ -195,6 +195,7 @@ module Bundler
|
||||||
platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
|
platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
|
||||||
@current_spec = LazySpecification.new(name, version, platform)
|
@current_spec = LazySpecification.new(name, version, platform)
|
||||||
@current_spec.source = @current_source
|
@current_spec.source = @current_source
|
||||||
|
@current_source.add_dependency_names(name)
|
||||||
|
|
||||||
@specs[@current_spec.identifier] = @current_spec
|
@specs[@current_spec.identifier] = @current_spec
|
||||||
elsif spaces.size == 6
|
elsif spaces.size == 6
|
||||||
|
|
|
@ -121,7 +121,8 @@ module Bundler
|
||||||
def replace_sources!(replacement_sources)
|
def replace_sources!(replacement_sources)
|
||||||
return false if replacement_sources.empty?
|
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)
|
different_sources?(lock_sources, replacement_sources)
|
||||||
end
|
end
|
||||||
|
@ -156,13 +157,21 @@ module Bundler
|
||||||
end
|
end
|
||||||
|
|
||||||
def map_sources(replacement_sources)
|
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|
|
sources.map do |source|
|
||||||
replacement_sources.find {|s| s == source } || source
|
replacement_sources.find {|s| s == source } || source
|
||||||
end
|
end
|
||||||
end
|
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)
|
def different_sources?(lock_sources, replacement_sources)
|
||||||
!equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
|
!equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,6 +108,45 @@ RSpec.shared_examples "bundle install --standalone" do
|
||||||
include_examples "common functionality"
|
include_examples "common functionality"
|
||||||
end
|
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
|
describe "with gems with native extension", :ruby_repo do
|
||||||
before do
|
before do
|
||||||
bundle "config set --local path #{bundled_app("bundle")}"
|
bundle "config set --local path #{bundled_app("bundle")}"
|
||||||
|
|
Loading…
Reference in a new issue