bundler 2.2.24 → 2.2.25

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bc6a3aafe599f19f103462212788c65ebd7558c7c0ba8208730b58f06a07d2a
4
- data.tar.gz: 36328d242818c34ef2a7477ea918941cbbd9469d3e747eed35eacbc178709a65
3
+ metadata.gz: 42284d8028f6f07937bba73b6c9e55c511c9d14c599b5b2e3b951599a6cff7e7
4
+ data.tar.gz: dcda6b29a424bc079333e3a9f5f02f679e7cae039b3dd07e25cb6da6ebf29b4c
5
5
  SHA512:
6
- metadata.gz: 1bbd69e10ba06b85eba9d4d282c0ca7337b2d97c614418dfa036883ae9cf0ff34eb50ecfb025a7555abf65026d64359b061ade7fdb76a57558d3f9b025ffff8e
7
- data.tar.gz: affea641347f4d123b2d24b39ea6b2eb0f0a97fb8377b9d3a52812dab08faa7c0a134f41a33cf785fc498ba3cf32162f5d213a33f825d24bcdd053ed90332b20
6
+ metadata.gz: 9cb7f2e44d450503a5c0786dcc9e3972cfa830180a518de00c5733965c9fe790ab1090611e1da3d2a8cffbd911e2a3c7531b0707a3712efd8c162b95723e827b
7
+ data.tar.gz: 0dc46959901b2edf345dbb4b0b448a9762caa91179011899d36939f927379af22b8406ddf4bb17e67c410a7d65c76c43f3c4fcb9c3ec6a4b92dcce82364cdf91
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ # 2.2.25 (July 30, 2021)
2
+
3
+ ## Deprecations:
4
+
5
+ - Deprecate Gemfile without an explicit global source [#4779](https://github.com/rubygems/rubygems/pull/4779)
6
+ - Deprecate `bundle cache --path` [#4496](https://github.com/rubygems/rubygems/pull/4496)
7
+
8
+ ## Enhancements:
9
+
10
+ - Give better errors when materialization fails [#4788](https://github.com/rubygems/rubygems/pull/4788)
11
+ - Lazily load `shellwords` library [#4786](https://github.com/rubygems/rubygems/pull/4786)
12
+ - Show original error and backtrace directly on `bundle install` errors instead of a more brittle `gem install` hint [#4778](https://github.com/rubygems/rubygems/pull/4778)
13
+ - Remove LoadError message in regards to requiring a relative file [#4772](https://github.com/rubygems/rubygems/pull/4772)
14
+
15
+ ## Bug fixes:
16
+
17
+ - Fix `BUNDLE_USER_CONFIG` no longer respected as config location [#4797](https://github.com/rubygems/rubygems/pull/4797)
18
+ - Fix `--standalone` installation of default gems [#4782](https://github.com/rubygems/rubygems/pull/4782)
19
+ - Fix `--quiet` flag not printing warnings [#4781](https://github.com/rubygems/rubygems/pull/4781)
20
+ - Fix bundler binstub version selection [#4775](https://github.com/rubygems/rubygems/pull/4775)
21
+ - Fix interrupt handling in Bundler workers [#4767](https://github.com/rubygems/rubygems/pull/4767)
22
+
1
23
  # 2.2.24 (July 15, 2021)
2
24
 
3
25
  ## Bug fixes:
data/lib/bundler.rb CHANGED
@@ -653,10 +653,6 @@ EOF
653
653
  rescue ScriptError, StandardError => e
654
654
  msg = "There was an error while loading `#{path.basename}`: #{e.message}"
655
655
 
656
- if e.is_a?(LoadError)
657
- msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
658
- end
659
-
660
656
  raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
661
657
  end
662
658
 
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2021-07-15".freeze
8
- @git_commit_sha = "d78b1ee235".freeze
7
+ @built_at = "2021-07-30".freeze
8
+ @git_commit_sha = "7f0f257c7a".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
data/lib/bundler/cli.rb CHANGED
@@ -456,6 +456,12 @@ module Bundler
456
456
  "do in future versions. Instead please use `bundle config set cache_all true`, " \
457
457
  "and stop using this flag" if ARGV.include?("--all")
458
458
 
459
+ SharedHelpers.major_deprecation 2,
460
+ "The `--path` flag is deprecated because its semantics are unclear. " \
461
+ "Use `bundle config cache_path` to configure the path of your cache of gems, " \
462
+ "and `bundle config path` to configure the path where your gems are installed, " \
463
+ "and stop using this flag" if ARGV.include?("--path")
464
+
459
465
  require_relative "cli/cache"
460
466
  Cache.new(options).run
461
467
  end
@@ -9,7 +9,7 @@ module Bundler
9
9
  end
10
10
 
11
11
  def run
12
- Bundler.ui.level = "error" if options[:quiet]
12
+ Bundler.ui.level = "warn" if options[:quiet]
13
13
  Bundler.settings.set_command_option_if_given :path, options[:path]
14
14
  Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
15
15
 
@@ -61,7 +61,7 @@ module Bundler
61
61
  end
62
62
 
63
63
  def run
64
- Bundler.ui.level = "error" if options[:quiet]
64
+ Bundler.ui.level = "warn" if options[:quiet]
65
65
  Bundler.settings.validate!
66
66
  check!
67
67
 
@@ -8,7 +8,7 @@ module Bundler
8
8
  end
9
9
 
10
10
  def run
11
- Bundler.ui.level = "error" if options[:quiet]
11
+ Bundler.ui.level = "warn" if options[:quiet]
12
12
 
13
13
  warn_if_root
14
14
 
@@ -60,7 +60,7 @@ module Bundler
60
60
  installer = Installer.install(Bundler.root, definition, options)
61
61
 
62
62
  Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
63
- Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
63
+ Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
64
64
  end
65
65
 
66
66
  Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
@@ -83,22 +83,9 @@ module Bundler
83
83
  end
84
84
 
85
85
  Bundler::CLI::Common.output_fund_metadata_summary
86
- rescue GemNotFound, VersionConflict => e
87
- if options[:local] && Bundler.app_cache.exist?
88
- Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
89
- end
90
-
91
- unless Bundler.definition.has_rubygems_remotes?
92
- Bundler.ui.warn <<-WARN, :wrap => true
93
- Your Gemfile has no gem server sources. If you need gems that are \
94
- not already on your machine, add a line like this to your Gemfile:
95
- source 'https://rubygems.org'
96
- WARN
97
- end
98
- raise e
99
- rescue Gem::InvalidSpecificationException => e
86
+ rescue Gem::InvalidSpecificationException
100
87
  Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed."
101
- raise e
88
+ raise
102
89
  end
103
90
 
104
91
  private
@@ -16,7 +16,13 @@ module Bundler
16
16
  specs = if @only_group.any? || @without_group.any?
17
17
  filtered_specs_by_groups
18
18
  else
19
- Bundler.load.specs
19
+ begin
20
+ Bundler.load.specs
21
+ rescue GemNotFound => e
22
+ Bundler.ui.error e.message
23
+ Bundler.ui.warn "Install missing gems with `bundle install`."
24
+ exit 1
25
+ end
20
26
  end.reject {|s| s.name == "bundler" }.sort_by(&:name)
21
27
 
22
28
  return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class CLI::Open
7
5
  attr_reader :options, :name
@@ -19,6 +17,7 @@ module Bundler
19
17
  else
20
18
  path = spec.full_gem_path
21
19
  Dir.chdir(path) do
20
+ require "shellwords"
22
21
  command = Shellwords.split(editor) + [path]
23
22
  Bundler.with_original_env do
24
23
  system(*command)
@@ -9,7 +9,7 @@ module Bundler
9
9
  end
10
10
 
11
11
  def run
12
- Bundler.ui.level = "error" if options[:quiet]
12
+ Bundler.ui.level = "warn" if options[:quiet]
13
13
 
14
14
  Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
15
15
 
@@ -133,7 +133,7 @@ module Bundler
133
133
  @unlock[:gems] ||= @dependencies.map(&:name)
134
134
  else
135
135
  eager_unlock = expand_dependencies(@unlock[:gems] || [], true)
136
- @unlock[:gems] = @locked_specs.for(eager_unlock, false, false, false).map(&:name)
136
+ @unlock[:gems] = @locked_specs.for(eager_unlock, false, false).map(&:name)
137
137
  end
138
138
 
139
139
  @dependency_changes = converge_dependencies
@@ -185,15 +185,7 @@ module Bundler
185
185
  #
186
186
  # @return [Bundler::SpecSet]
187
187
  def specs
188
- @specs ||= add_bundler_to(resolve.materialize(requested_dependencies))
189
- rescue GemNotFound => e # Handle yanked gem
190
- gem_name, gem_version = extract_gem_info(e)
191
- locked_gem = @locked_specs[gem_name].last
192
- raise if locked_gem.nil? || locked_gem.version.to_s != gem_version || !@remote
193
- raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
194
- "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
195
- "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
196
- "removed in order to install."
188
+ @specs ||= materialize(requested_dependencies)
197
189
  end
198
190
 
199
191
  def new_specs
@@ -205,9 +197,7 @@ module Bundler
205
197
  end
206
198
 
207
199
  def missing_specs
208
- missing = []
209
- resolve.materialize(requested_dependencies, missing)
210
- missing
200
+ resolve.materialize(requested_dependencies).missing_specs
211
201
  end
212
202
 
213
203
  def missing_specs?
@@ -241,7 +231,7 @@ module Bundler
241
231
  def specs_for(groups)
242
232
  groups = requested_groups if groups.empty?
243
233
  deps = dependencies_for(groups)
244
- add_bundler_to(resolve.materialize(expand_dependencies(deps)))
234
+ materialize(expand_dependencies(deps))
245
235
  end
246
236
 
247
237
  def dependencies_for(groups)
@@ -274,10 +264,6 @@ module Bundler
274
264
  end
275
265
  end
276
266
 
277
- def has_rubygems_remotes?
278
- sources.rubygems_sources.any? {|s| s.remotes.any? }
279
- end
280
-
281
267
  def spec_git_paths
282
268
  sources.git_sources.map {|s| File.realpath(s.path) if File.exist?(s.path) }.compact
283
269
  end
@@ -493,7 +479,23 @@ module Bundler
493
479
 
494
480
  private
495
481
 
496
- def add_bundler_to(specs)
482
+ def materialize(dependencies)
483
+ specs = resolve.materialize(dependencies)
484
+ missing_specs = specs.missing_specs
485
+
486
+ if missing_specs.any?
487
+ missing_specs.each do |s|
488
+ locked_gem = @locked_specs[s.name].last
489
+ next if locked_gem.nil? || locked_gem.version != s.version || !@remote
490
+ raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
491
+ "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
492
+ "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
493
+ "removed in order to install."
494
+ end
495
+
496
+ raise GemNotFound, "Could not find #{missing_specs.map(&:full_name).join(", ")} in any of the sources"
497
+ end
498
+
497
499
  unless specs["bundler"].any?
498
500
  bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
499
501
  specs["bundler"] = bundler
@@ -712,7 +714,7 @@ module Bundler
712
714
  @locked_specs.each do |s|
713
715
  # Replace the locked dependency's source with the equivalent source from the Gemfile
714
716
  dep = @dependencies.find {|d| s.satisfies?(d) }
715
- s.source = (dep && dep.source) || sources.get(s.source)
717
+ s.source = (dep && dep.source) || sources.get(s.source) unless multisource_allowed?
716
718
 
717
719
  # Don't add a spec to the list if its source is expired. For example,
718
720
  # if you change a Git gem to RubyGems.
@@ -730,7 +732,7 @@ module Bundler
730
732
  # if we won't need the source (according to the lockfile),
731
733
  # don't error if the path/git source isn't available
732
734
  next if @locked_specs.
733
- for(requested_dependencies, false, true, false).
735
+ for(requested_dependencies, false, true).
734
736
  none? {|locked_spec| locked_spec.source == s.source }
735
737
 
736
738
  raise
@@ -750,7 +752,7 @@ module Bundler
750
752
 
751
753
  resolve = SpecSet.new(converged)
752
754
  @locked_specs_incomplete_for_platform = !resolve.for(expand_dependencies(requested_dependencies & deps), true, true)
753
- resolve = SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false, false).reject{|s| @unlock[:gems].include?(s.name) })
755
+ resolve = SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) })
754
756
  diff = nil
755
757
 
756
758
  # Now, we unlock any sources that do not have anymore gems pinned to it
@@ -854,12 +856,6 @@ module Bundler
854
856
  current == proposed
855
857
  end
856
858
 
857
- def extract_gem_info(error)
858
- # This method will extract the error message like "Could not find foo-1.2.3 in any of the sources"
859
- # to an array. The first element will be the gem name (e.g. foo), the second will be the version number.
860
- error.message.scan(/Could not find (\w+)-(\d+(?:\.\d+)+)/).flatten
861
- end
862
-
863
859
  def compute_requires
864
860
  dependencies.reduce({}) do |requires, dep|
865
861
  next requires unless dep.should_include?
data/lib/bundler/dsl.rb CHANGED
@@ -447,8 +447,21 @@ repo_name ||= user_name
447
447
  end
448
448
 
449
449
  def check_rubygems_source_safety
450
- return unless @sources.aggregate_global_source?
450
+ if @sources.implicit_global_source?
451
+ implicit_global_source_warning
452
+ elsif @sources.aggregate_global_source?
453
+ multiple_global_source_warning
454
+ end
455
+ end
456
+
457
+ def implicit_global_source_warning
458
+ Bundler::SharedHelpers.major_deprecation 2, "This Gemfile does not include an explicit global source. " \
459
+ "Not using an explicit global source may result in a different lockfile being generated depending on " \
460
+ "the gems you have installed locally before bundler is run." \
461
+ "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\"."
462
+ end
451
463
 
464
+ def multiple_global_source_warning
452
465
  if Bundler.feature_flag.bundler_3_mode?
453
466
  msg = "This Gemfile contains multiple primary sources. " \
454
467
  "Each source after the first must include a block to indicate which gems " \
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class GemInstaller
7
5
  attr_reader :spec, :standalone, :worker, :force, :installer
@@ -31,34 +29,23 @@ module Bundler
31
29
 
32
30
  def specific_failure_message(e)
33
31
  message = "#{e.class}: #{e.message}\n"
34
- message += " " + e.backtrace.join("\n ") + "\n\n" if Bundler.ui.debug?
32
+ message += " " + e.backtrace.join("\n ") + "\n\n"
35
33
  message = message.lines.first + Bundler.ui.add_color(message.lines.drop(1).join, :clear)
36
34
  message + Bundler.ui.add_color(failure_message, :red)
37
35
  end
38
36
 
39
37
  def failure_message
40
- return install_error_message if spec.source.options["git"]
41
- "#{install_error_message}\n#{gem_install_message}"
38
+ install_error_message
42
39
  end
43
40
 
44
41
  def install_error_message
45
42
  "An error occurred while installing #{spec.name} (#{spec.version}), and Bundler cannot continue."
46
43
  end
47
44
 
48
- def gem_install_message
49
- source = spec.source
50
- return unless source.respond_to?(:remotes)
51
-
52
- if source.remotes.size == 1
53
- "Make sure that `gem install #{spec.name} -v '#{spec.version}' --source '#{source.remotes.first}'` succeeds before bundling."
54
- else
55
- "Make sure that `gem install #{spec.name} -v '#{spec.version}'` succeeds before bundling."
56
- end
57
- end
58
-
59
45
  def spec_settings
60
46
  # Fetch the build settings, if there are any
61
47
  if settings = Bundler.settings["build.#{spec.name}"]
48
+ require "shellwords"
62
49
  Shellwords.shellsplit(settings)
63
50
  end
64
51
  end
@@ -195,6 +195,7 @@ module Bundler
195
195
  platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
196
196
  @current_spec = LazySpecification.new(name, version, platform)
197
197
  @current_spec.source = @current_source
198
+ @current_source.add_dependency_names(name)
198
199
 
199
200
  @specs[@current_spec.identifier] = @current_spec
200
201
  elsif spaces.size == 6
@@ -61,7 +61,10 @@ module Bundler
61
61
 
62
62
  def build_extensions
63
63
  extension_cache_path = options[:bundler_extension_cache_path]
64
- return super unless extension_cache_path && extension_dir = spec.extension_dir
64
+ unless extension_cache_path && extension_dir = spec.extension_dir
65
+ require "shellwords" # compensate missing require in rubygems before version 3.2.25
66
+ return super
67
+ end
65
68
 
66
69
  extension_dir = Pathname.new(extension_dir)
67
70
  build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
@@ -71,6 +74,7 @@ module Bundler
71
74
  FileUtils.cp_r extension_cache_path, spec.extension_dir
72
75
  end
73
76
  else
77
+ require "shellwords" # compensate missing require in rubygems before version 3.2.25
74
78
  super
75
79
  if extension_dir.directory? # not made for gems without extensions
76
80
  SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
@@ -22,10 +22,6 @@ module Bundler
22
22
 
23
23
  # Activate the specs
24
24
  load_paths = specs.map do |spec|
25
- unless spec.loaded_from
26
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
27
- end
28
-
29
25
  check_for_activated_spec!(spec)
30
26
 
31
27
  Bundler.rubygems.mark_loaded(spec)
@@ -104,7 +100,7 @@ module Bundler
104
100
 
105
101
  alias_method :gems, :specs
106
102
 
107
- def cache(custom_path = nil)
103
+ def cache(custom_path = nil, local = false)
108
104
  cache_path = Bundler.app_cache(custom_path)
109
105
  SharedHelpers.filesystem_access(cache_path) do |p|
110
106
  FileUtils.mkdir_p(p)
@@ -112,7 +108,20 @@ module Bundler
112
108
 
113
109
  Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
114
110
 
115
- specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
111
+ specs_to_cache = if Bundler.settings[:cache_all_platforms]
112
+ @definition.resolve.materialized_for_all_platforms
113
+ else
114
+ begin
115
+ specs
116
+ rescue GemNotFound
117
+ if local
118
+ Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
119
+ end
120
+
121
+ raise
122
+ end
123
+ end
124
+
116
125
  specs_to_cache.each do |spec|
117
126
  next if spec.name == "bundler"
118
127
  next if spec.source.is_a?(Source::Gemspec)
@@ -428,6 +428,8 @@ module Bundler
428
428
  def global_config_file
429
429
  if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
430
430
  Pathname.new(ENV["BUNDLE_CONFIG"])
431
+ elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
432
+ Pathname.new(ENV["BUNDLE_USER_CONFIG"])
431
433
  elsif Bundler.rubygems.user_home && !Bundler.rubygems.user_home.empty?
432
434
  Pathname.new(Bundler.rubygems.user_home).join(".bundle/config")
433
435
  end
data/lib/bundler/setup.rb CHANGED
@@ -9,10 +9,10 @@ if Bundler::SharedHelpers.in_bundle?
9
9
  begin
10
10
  Bundler.ui.silence { Bundler.setup }
11
11
  rescue Bundler::BundlerError => e
12
- Bundler.ui.warn "\e[31m#{e.message}\e[0m"
12
+ Bundler.ui.error e.message
13
13
  Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
14
14
  if e.is_a?(Bundler::GemNotFound)
15
- Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m"
15
+ Bundler.ui.warn "Run `bundle install` to install missing gems."
16
16
  end
17
17
  exit e.status_code
18
18
  end
@@ -152,13 +152,6 @@ module Bundler
152
152
  Bundler.ui.warn message
153
153
  end
154
154
 
155
- def trap(signal, override = false, &block)
156
- prior = Signal.trap(signal) do
157
- block.call
158
- prior.call unless override
159
- end
160
- end
161
-
162
155
  def ensure_same_dependencies(spec, old_deps, new_deps)
163
156
  new_deps = new_deps.reject {|d| d.type == :development }
164
157
  old_deps = old_deps.reject {|d| d.type == :development }
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class Source
7
5
  class Git
@@ -224,6 +222,7 @@ module Bundler
224
222
  end
225
223
 
226
224
  def check_allowed(command)
225
+ require "shellwords"
227
226
  command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
228
227
  raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
229
228
  command_with_no_credentials
@@ -71,6 +71,10 @@ module Bundler
71
71
  @remotes.size > 1
72
72
  end
73
73
 
74
+ def no_remotes?
75
+ @remotes.size == 0
76
+ end
77
+
74
78
  def can_lock?(spec)
75
79
  return super unless multiple_remotes?
76
80
  include?(spec.source)
@@ -37,6 +37,10 @@ module Bundler
37
37
  global_rubygems_source.multiple_remotes?
38
38
  end
39
39
 
40
+ def implicit_global_source?
41
+ global_rubygems_source.no_remotes?
42
+ end
43
+
40
44
  def add_path_source(options = {})
41
45
  if options["gemspec"]
42
46
  add_source_to_list Source::Gemspec.new(options), path_sources
@@ -117,7 +121,8 @@ module Bundler
117
121
  def replace_sources!(replacement_sources)
118
122
  return false if replacement_sources.empty?
119
123
 
120
- @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
124
+ @rubygems_sources, @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
125
+ @global_rubygems_source = global_replacement_source(replacement_sources)
121
126
 
122
127
  different_sources?(lock_sources, replacement_sources)
123
128
  end
@@ -152,13 +157,21 @@ module Bundler
152
157
  end
153
158
 
154
159
  def map_sources(replacement_sources)
155
- [path_sources, git_sources, plugin_sources].map do |sources|
160
+ [@rubygems_sources, @path_sources, @git_sources, @plugin_sources].map do |sources|
156
161
  sources.map do |source|
157
162
  replacement_sources.find {|s| s == source } || source
158
163
  end
159
164
  end
160
165
  end
161
166
 
167
+ def global_replacement_source(replacement_sources)
168
+ replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
169
+ return global_rubygems_source unless replacement_source
170
+
171
+ replacement_source.local!
172
+ replacement_source
173
+ end
174
+
162
175
  def different_sources?(lock_sources, replacement_sources)
163
176
  !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
164
177
  end
@@ -202,7 +215,7 @@ module Bundler
202
215
  end
203
216
 
204
217
  def equal_source?(source, other_source)
205
- return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems) && !merged_gem_lockfile_sections?
218
+ return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems)
206
219
 
207
220
  source == other_source
208
221
  end
@@ -11,7 +11,7 @@ module Bundler
11
11
  @specs = specs
12
12
  end
13
13
 
14
- def for(dependencies, check = false, match_current_platform = false, raise_on_missing = true)
14
+ def for(dependencies, check = false, match_current_platform = false)
15
15
  handled = []
16
16
  deps = dependencies.dup
17
17
  specs = []
@@ -33,11 +33,6 @@ module Bundler
33
33
  end
34
34
  elsif check
35
35
  return false
36
- elsif raise_on_missing
37
- others = lookup[dep.name] if match_current_platform
38
- message = "Unable to find a spec satisfying #{dep} in the set. Perhaps the lockfile is corrupted?"
39
- message += " Found #{others.join(", ")} that did not match the current platform." if others && !others.empty?
40
- raise GemNotFound, message
41
36
  end
42
37
  end
43
38
 
@@ -71,52 +66,35 @@ module Bundler
71
66
  lookup.dup
72
67
  end
73
68
 
74
- def materialize(deps, missing_specs = nil)
75
- materialized = self.for(deps, false, true, !missing_specs)
76
-
77
- materialized.group_by(&:source).each do |source, specs|
78
- next unless specs.any?{|s| s.is_a?(LazySpecification) }
79
-
80
- source.local!
81
- names = -> { specs.map(&:name).uniq }
82
- source.double_check_for(names)
83
- end
69
+ def materialize(deps)
70
+ materialized = self.for(deps, false, true)
84
71
 
85
72
  materialized.map! do |s|
86
73
  next s unless s.is_a?(LazySpecification)
87
- spec = s.__materialize__
88
- unless spec
89
- unless missing_specs
90
- raise GemNotFound, "Could not find #{s.full_name} in any of the sources"
91
- end
92
- missing_specs << s
93
- end
94
- spec
74
+ s.source.local!
75
+ s.__materialize__ || s
95
76
  end
96
- SpecSet.new(missing_specs ? materialized.compact : materialized)
77
+ SpecSet.new(materialized)
97
78
  end
98
79
 
99
80
  # Materialize for all the specs in the spec set, regardless of what platform they're for
100
81
  # This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform)
101
82
  # @return [Array<Gem::Specification>]
102
83
  def materialized_for_all_platforms
103
- @specs.group_by(&:source).each do |source, specs|
104
- next unless specs.any?{|s| s.is_a?(LazySpecification) }
105
-
106
- source.local!
107
- source.remote!
108
- names = -> { specs.map(&:name).uniq }
109
- source.double_check_for(names)
110
- end
111
-
112
84
  @specs.map do |s|
113
85
  next s unless s.is_a?(LazySpecification)
86
+ s.source.local!
87
+ s.source.remote!
114
88
  spec = s.__materialize__
115
89
  raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
116
90
  spec
117
91
  end
118
92
  end
119
93
 
94
+ def missing_specs
95
+ @specs.select {|s| s.is_a?(LazySpecification) }
96
+ end
97
+
120
98
  def merge(set)
121
99
  arr = sorted.dup
122
100
  set.each do |set_spec|
@@ -60,16 +60,16 @@ m = Module.new do
60
60
  Regexp.last_match(1)
61
61
  end
62
62
 
63
- def bundler_version
64
- @bundler_version ||=
63
+ def bundler_requirement
64
+ @bundler_requirement ||=
65
65
  env_var_version || cli_arg_version ||
66
- lockfile_version
66
+ bundler_requirement_for(lockfile_version)
67
67
  end
68
68
 
69
- def bundler_requirement
70
- return "#{Gem::Requirement.default}.a" unless bundler_version
69
+ def bundler_requirement_for(version)
70
+ return "#{Gem::Requirement.default}.a" unless version
71
71
 
72
- bundler_gem_version = Gem::Version.new(bundler_version)
72
+ bundler_gem_version = Gem::Version.new(version)
73
73
 
74
74
  requirement = bundler_gem_version.approximate_recommendation
75
75
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.2.24".freeze
4
+ VERSION = "2.2.25".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
@@ -26,7 +26,7 @@ module Bundler
26
26
  @func = func
27
27
  @size = size
28
28
  @threads = nil
29
- SharedHelpers.trap("INT") { abort_threads }
29
+ @previous_interrupt_handler = nil
30
30
  end
31
31
 
32
32
  # Enqueue a request to be executed in the worker pool
@@ -68,13 +68,16 @@ module Bundler
68
68
  # so as worker threads after retrieving it, shut themselves down
69
69
  def stop_threads
70
70
  return unless @threads
71
+
71
72
  @threads.each { @request_queue.enq POISON }
72
73
  @threads.each(&:join)
74
+
75
+ remove_interrupt_handler
76
+
73
77
  @threads = nil
74
78
  end
75
79
 
76
80
  def abort_threads
77
- return unless @threads
78
81
  Bundler.ui.debug("\n#{caller.join("\n")}")
79
82
  @threads.each(&:exit)
80
83
  exit 1
@@ -94,11 +97,23 @@ module Bundler
94
97
  end
95
98
  end.compact
96
99
 
100
+ add_interrupt_handler unless @threads.empty?
101
+
97
102
  return if creation_errors.empty?
98
103
 
99
104
  message = "Failed to create threads for the #{name} worker: #{creation_errors.map(&:to_s).uniq.join(", ")}"
100
105
  raise ThreadCreationError, message if @threads.empty?
101
106
  Bundler.ui.info message
102
107
  end
108
+
109
+ def add_interrupt_handler
110
+ @previous_interrupt_handler = trap("INT") { abort_threads }
111
+ end
112
+
113
+ def remove_interrupt_handler
114
+ return unless @previous_interrupt_handler
115
+
116
+ trap "INT", @previous_interrupt_handler
117
+ end
103
118
  end
104
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.24
4
+ version: 2.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -22,7 +22,7 @@ authors:
22
22
  autorequire:
23
23
  bindir: exe
24
24
  cert_chain: []
25
- date: 2021-07-15 00:00:00.000000000 Z
25
+ date: 2021-07-30 00:00:00.000000000 Z
26
26
  dependencies: []
27
27
  description: Bundler manages an application's dependencies through its entire life,
28
28
  across many machines, systematically and repeatably
@@ -354,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
354
354
  - !ruby/object:Gem::Version
355
355
  version: 2.5.2
356
356
  requirements: []
357
- rubygems_version: 3.2.24
357
+ rubygems_version: 3.2.25
358
358
  signing_key:
359
359
  specification_version: 4
360
360
  summary: The best way to manage your application's dependencies