bundler 2.2.13 → 2.2.17

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.

Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -5
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/common.rb +15 -2
  5. data/lib/bundler/cli/gem.rb +9 -1
  6. data/lib/bundler/cli/outdated.rb +1 -1
  7. data/lib/bundler/cli.rb +3 -2
  8. data/lib/bundler/compact_index_client/updater.rb +10 -6
  9. data/lib/bundler/current_ruby.rb +1 -0
  10. data/lib/bundler/definition.rb +26 -12
  11. data/lib/bundler/dsl.rb +3 -6
  12. data/lib/bundler/feature_flag.rb +0 -1
  13. data/lib/bundler/fetcher/downloader.rb +8 -4
  14. data/lib/bundler/fetcher.rb +2 -1
  15. data/lib/bundler/gem_helper.rb +16 -0
  16. data/lib/bundler/injector.rb +2 -2
  17. data/lib/bundler/inline.rb +1 -1
  18. data/lib/bundler/installer/parallel_installer.rb +36 -15
  19. data/lib/bundler/lazy_specification.rb +6 -1
  20. data/lib/bundler/lockfile_parser.rb +2 -16
  21. data/lib/bundler/man/bundle-add.1 +1 -1
  22. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  23. data/lib/bundler/man/bundle-cache.1 +1 -1
  24. data/lib/bundler/man/bundle-check.1 +1 -1
  25. data/lib/bundler/man/bundle-clean.1 +1 -1
  26. data/lib/bundler/man/bundle-config.1 +21 -4
  27. data/lib/bundler/man/bundle-config.1.ronn +21 -3
  28. data/lib/bundler/man/bundle-doctor.1 +1 -1
  29. data/lib/bundler/man/bundle-exec.1 +1 -1
  30. data/lib/bundler/man/bundle-gem.1 +1 -1
  31. data/lib/bundler/man/bundle-info.1 +1 -1
  32. data/lib/bundler/man/bundle-init.1 +1 -1
  33. data/lib/bundler/man/bundle-inject.1 +1 -1
  34. data/lib/bundler/man/bundle-install.1 +1 -1
  35. data/lib/bundler/man/bundle-list.1 +1 -1
  36. data/lib/bundler/man/bundle-lock.1 +1 -1
  37. data/lib/bundler/man/bundle-open.1 +1 -1
  38. data/lib/bundler/man/bundle-outdated.1 +1 -1
  39. data/lib/bundler/man/bundle-platform.1 +1 -1
  40. data/lib/bundler/man/bundle-pristine.1 +1 -1
  41. data/lib/bundler/man/bundle-remove.1 +1 -1
  42. data/lib/bundler/man/bundle-show.1 +1 -1
  43. data/lib/bundler/man/bundle-update.1 +1 -1
  44. data/lib/bundler/man/bundle-viz.1 +1 -1
  45. data/lib/bundler/man/bundle.1 +1 -1
  46. data/lib/bundler/man/gemfile.5 +1 -1
  47. data/lib/bundler/plugin/api/source.rb +7 -0
  48. data/lib/bundler/plugin.rb +2 -2
  49. data/lib/bundler/retry.rb +1 -1
  50. data/lib/bundler/settings.rb +60 -10
  51. data/lib/bundler/source/metadata.rb +0 -4
  52. data/lib/bundler/source/path/installer.rb +1 -1
  53. data/lib/bundler/source/path.rb +3 -1
  54. data/lib/bundler/source/rubygems.rb +22 -6
  55. data/lib/bundler/source.rb +6 -0
  56. data/lib/bundler/source_list.rb +15 -5
  57. data/lib/bundler/spec_set.rb +18 -5
  58. data/lib/bundler/templates/Gemfile +1 -1
  59. data/lib/bundler/templates/gems.rb +1 -1
  60. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -4
  61. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  62. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +1 -1
  63. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  64. data/lib/bundler/version.rb +1 -1
  65. metadata +3 -3
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-PRISTINE" "1" "January 2021" "" ""
4
+ .TH "BUNDLE\-PRISTINE" "1" "April 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-REMOVE" "1" "January 2021" "" ""
4
+ .TH "BUNDLE\-REMOVE" "1" "April 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-remove\fR \- Removes gems from the Gemfile
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-SHOW" "1" "January 2021" "" ""
4
+ .TH "BUNDLE\-SHOW" "1" "April 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-UPDATE" "1" "January 2021" "" ""
4
+ .TH "BUNDLE\-UPDATE" "1" "April 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-update\fR \- Update your gems to the latest available versions
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-VIZ" "1" "January 2021" "" ""
4
+ .TH "BUNDLE\-VIZ" "1" "April 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE" "1" "January 2021" "" ""
4
+ .TH "BUNDLE" "1" "April 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\fR \- Ruby Dependency Management
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GEMFILE" "5" "January 2021" "" ""
4
+ .TH "GEMFILE" "5" "April 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
@@ -140,6 +140,13 @@ module Bundler
140
140
  end
141
141
  end
142
142
 
143
+ # Set internal representation to fetch the gems/specs locally.
144
+ #
145
+ # When this is called, the source should try to fetch the specs and
146
+ # install from the local system.
147
+ def local!
148
+ end
149
+
143
150
  # Set internal representation to fetch the gems/specs from remote.
144
151
  #
145
152
  # When this is called, the source should try to fetch the specs and
@@ -164,7 +164,7 @@ module Bundler
164
164
  end
165
165
 
166
166
  # To be called from Cli class to pass the command and argument to
167
- # approriate plugin class
167
+ # appropriate plugin class
168
168
  def exec_command(command, args)
169
169
  raise UndefinedCommandError, "Command `#{command}` not found" unless command? command
170
170
 
@@ -183,7 +183,7 @@ module Bundler
183
183
  !index.source_plugin(name.to_s).nil?
184
184
  end
185
185
 
186
- # @return [Class] that handles the source. The calss includes API::Source
186
+ # @return [Class] that handles the source. The class includes API::Source
187
187
  def source(name)
188
188
  raise UnknownSourceError, "Source #{name} not found" unless source? name
189
189
 
data/lib/bundler/retry.rb CHANGED
@@ -49,7 +49,7 @@ module Bundler
49
49
  raise e
50
50
  end
51
51
  return true unless name
52
- Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this
52
+ Bundler.ui.info "" unless Bundler.ui.debug? # Add new line in case dots preceded this
53
53
  Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
54
54
  end
55
55
 
@@ -13,6 +13,7 @@ module Bundler
13
13
  auto_install
14
14
  cache_all
15
15
  cache_all_platforms
16
+ clean
16
17
  default_install_uses_path
17
18
  deployment
18
19
  deployment_means_frozen
@@ -26,14 +27,16 @@ module Bundler
26
27
  force_ruby_platform
27
28
  forget_cli_options
28
29
  frozen
30
+ gem.changelog
29
31
  gem.coc
30
32
  gem.mit
33
+ git.allow_insecure
31
34
  global_gem_cache
32
35
  ignore_messages
33
36
  init_gems_rb
37
+ inline
34
38
  no_install
35
39
  no_prune
36
- only_update_to_newer_versions
37
40
  path_relative_to_cwd
38
41
  path.system
39
42
  plugins
@@ -61,6 +64,22 @@ module Bundler
61
64
  without
62
65
  ].freeze
63
66
 
67
+ STRING_KEYS = %w[
68
+ bin
69
+ cache_path
70
+ console
71
+ gem.ci
72
+ gem.github_username
73
+ gem.linter
74
+ gem.rubocop
75
+ gem.test
76
+ gemfile
77
+ path
78
+ shebang
79
+ system_bindir
80
+ trust-policy
81
+ ].freeze
82
+
64
83
  DEFAULT_CONFIG = {
65
84
  "BUNDLE_SILENCE_DEPRECATIONS" => false,
66
85
  "BUNDLE_DISABLE_VERSION_CHECK" => true,
@@ -126,8 +145,8 @@ module Bundler
126
145
  keys = @temporary.keys | @global_config.keys | @local_config.keys | @env_config.keys
127
146
 
128
147
  keys.map do |key|
129
- key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
130
- end
148
+ key.sub(/^BUNDLE_/, "").gsub(/___/, "-").gsub(/__/, ".").downcase
149
+ end.sort
131
150
  end
132
151
 
133
152
  def local_overrides
@@ -173,19 +192,19 @@ module Bundler
173
192
  locations = []
174
193
 
175
194
  if value = @temporary[key]
176
- locations << "Set for the current command: #{converted_value(value, exposed_key).inspect}"
195
+ locations << "Set for the current command: #{printable_value(value, exposed_key).inspect}"
177
196
  end
178
197
 
179
198
  if value = @local_config[key]
180
- locations << "Set for your local app (#{local_config_file}): #{converted_value(value, exposed_key).inspect}"
199
+ locations << "Set for your local app (#{local_config_file}): #{printable_value(value, exposed_key).inspect}"
181
200
  end
182
201
 
183
202
  if value = @env_config[key]
184
- locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}"
203
+ locations << "Set via #{key}: #{printable_value(value, exposed_key).inspect}"
185
204
  end
186
205
 
187
206
  if value = @global_config[key]
188
- locations << "Set for the current user (#{global_config_file}): #{converted_value(value, exposed_key).inspect}"
207
+ locations << "Set for the current user (#{global_config_file}): #{printable_value(value, exposed_key).inspect}"
189
208
  end
190
209
 
191
210
  return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
@@ -277,9 +296,7 @@ module Bundler
277
296
  end
278
297
 
279
298
  def key_for(key)
280
- key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
281
- key = key.to_s.gsub(".", "__").upcase
282
- "BUNDLE_#{key}"
299
+ self.class.key_for(key)
283
300
  end
284
301
 
285
302
  private
@@ -314,6 +331,10 @@ module Bundler
314
331
  BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s))
315
332
  end
316
333
 
334
+ def is_string(name)
335
+ STRING_KEYS.include?(name.to_s) || name.to_s.start_with?("local.") || name.to_s.start_with?("mirror.") || name.to_s.start_with?("build.")
336
+ end
337
+
317
338
  def to_bool(value)
318
339
  case value
319
340
  when nil, /\A(false|f|no|n|0|)\z/i, false
@@ -331,6 +352,14 @@ module Bundler
331
352
  ARRAY_KEYS.include?(key.to_s)
332
353
  end
333
354
 
355
+ def is_credential(key)
356
+ key == "gem.push_key"
357
+ end
358
+
359
+ def is_userinfo(value)
360
+ value.include?(":")
361
+ end
362
+
334
363
  def to_array(value)
335
364
  return [] unless value
336
365
  value.split(":").map(&:to_sym)
@@ -377,6 +406,21 @@ module Bundler
377
406
  end
378
407
  end
379
408
 
409
+ def printable_value(value, key)
410
+ converted = converted_value(value, key)
411
+ return converted unless converted.is_a?(String)
412
+
413
+ if is_string(key)
414
+ converted
415
+ elsif is_credential(key)
416
+ "[REDACTED]"
417
+ elsif is_userinfo(converted)
418
+ converted.gsub(/:.*$/, ":[REDACTED]")
419
+ else
420
+ converted
421
+ end
422
+ end
423
+
380
424
  def global_config_file
381
425
  if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
382
426
  Pathname.new(ENV["BUNDLE_CONFIG"])
@@ -416,6 +460,12 @@ module Bundler
416
460
  \z
417
461
  /ix.freeze
418
462
 
463
+ def self.key_for(key)
464
+ key = normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
465
+ key = key.to_s.gsub(".", "__").gsub("-", "___").upcase
466
+ "BUNDLE_#{key}"
467
+ end
468
+
419
469
  # TODO: duplicates Rubygems#normalize_uri
420
470
  # TODO: is this the correct place to validate mirror URIs?
421
471
  def self.normalize_uri(uri)
@@ -33,10 +33,6 @@ module Bundler
33
33
  end
34
34
  end
35
35
 
36
- def cached!; end
37
-
38
- def remote!; end
39
-
40
36
  def options
41
37
  {}
42
38
  end
@@ -35,7 +35,7 @@ module Bundler
35
35
  run_hooks(:post_build)
36
36
  end
37
37
 
38
- generate_bin unless spec.executables.nil? || spec.executables.empty?
38
+ generate_bin unless spec.executables.empty?
39
39
 
40
40
  run_hooks(:post_install)
41
41
  ensure
@@ -82,7 +82,9 @@ module Bundler
82
82
  end
83
83
 
84
84
  def install(spec, options = {})
85
- print_using_message "Using #{version_message(spec)} from #{self}"
85
+ using_message = "Using #{version_message(spec)} from #{self}"
86
+ using_message += " and installing its executables" unless spec.executables.empty?
87
+ print_using_message using_message
86
88
  generate_bin(spec, :disable_extensions => true)
87
89
  nil # no post-install message
88
90
  end
@@ -20,17 +20,29 @@ module Bundler
20
20
  @dependency_names = []
21
21
  @allow_remote = false
22
22
  @allow_cached = false
23
+ @allow_local = options["allow_local"] || false
23
24
  @caches = [cache_path, *Bundler.rubygems.gem_cache]
24
25
 
25
- Array(options["remotes"] || []).reverse_each {|r| add_remote(r) }
26
+ Array(options["remotes"]).reverse_each {|r| add_remote(r) }
27
+ end
28
+
29
+ def local!
30
+ return if @allow_local
31
+
32
+ @specs = nil
33
+ @allow_local = true
26
34
  end
27
35
 
28
36
  def remote!
37
+ return if @allow_remote
38
+
29
39
  @specs = nil
30
40
  @allow_remote = true
31
41
  end
32
42
 
33
43
  def cached!
44
+ return if @allow_cached
45
+
34
46
  @specs = nil
35
47
  @allow_cached = true
36
48
  end
@@ -49,8 +61,12 @@ module Bundler
49
61
  o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
50
62
  end
51
63
 
64
+ def disable_multisource?
65
+ @remotes.size <= 1
66
+ end
67
+
52
68
  def can_lock?(spec)
53
- return super if Bundler.feature_flag.disable_multisource?
69
+ return super if disable_multisource?
54
70
  spec.source.is_a?(Rubygems)
55
71
  end
56
72
 
@@ -87,7 +103,7 @@ module Bundler
87
103
  # small_idx.use large_idx.
88
104
  idx = @allow_remote ? remote_specs.dup : Index.new
89
105
  idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
90
- idx.use(installed_specs, :override_dupes)
106
+ idx.use(installed_specs, :override_dupes) if @allow_local
91
107
  idx
92
108
  end
93
109
  end
@@ -365,7 +381,7 @@ module Bundler
365
381
 
366
382
  def cached_specs
367
383
  @cached_specs ||= begin
368
- idx = installed_specs.dup
384
+ idx = @allow_local ? installed_specs.dup : Index.new
369
385
 
370
386
  Dir["#{cache_path}/*.gem"].each do |gemfile|
371
387
  next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
@@ -407,11 +423,11 @@ module Bundler
407
423
  def fetch_names(fetchers, dependency_names, index, override_dupes)
408
424
  fetchers.each do |f|
409
425
  if dependency_names
410
- Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug?
426
+ Bundler.ui.info "Fetching gem metadata from #{URICredentialsFilter.credential_filtered_uri(f.uri)}", Bundler.ui.debug?
411
427
  index.use f.specs_with_retry(dependency_names, self), override_dupes
412
428
  Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
413
429
  else
414
- Bundler.ui.info "Fetching source index from #{f.uri}"
430
+ Bundler.ui.info "Fetching source index from #{URICredentialsFilter.credential_filtered_uri(f.uri)}"
415
431
  index.use f.specs_with_retry(nil, self), override_dupes
416
432
  end
417
433
  end
@@ -33,6 +33,12 @@ module Bundler
33
33
  spec.source == self
34
34
  end
35
35
 
36
+ def local!; end
37
+
38
+ def cached!; end
39
+
40
+ def remote!; end
41
+
36
42
  # it's possible that gems from one source depend on gems from some
37
43
  # other source, so now we download gemspecs and iterate over those
38
44
  # dependencies, looking for gems we don't have info on yet.
@@ -9,7 +9,7 @@ module Bundler
9
9
  :metadata_source
10
10
 
11
11
  def global_rubygems_source
12
- @global_rubygems_source ||= rubygems_aggregate_class.new
12
+ @global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
13
13
  end
14
14
 
15
15
  def initialize
@@ -20,6 +20,16 @@ module Bundler
20
20
  @global_path_source = nil
21
21
  @rubygems_sources = []
22
22
  @metadata_source = Source::Metadata.new
23
+
24
+ @disable_multisource = true
25
+ end
26
+
27
+ def disable_multisource?
28
+ @disable_multisource
29
+ end
30
+
31
+ def merged_gem_lockfile_sections!
32
+ @disable_multisource = false
23
33
  end
24
34
 
25
35
  def add_path_source(options = {})
@@ -47,7 +57,7 @@ module Bundler
47
57
  end
48
58
 
49
59
  def global_rubygems_source=(uri)
50
- @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri)
60
+ @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri, "allow_local" => true)
51
61
  end
52
62
 
53
63
  def add_rubygems_remote(uri)
@@ -77,8 +87,8 @@ module Bundler
77
87
 
78
88
  def lock_sources
79
89
  lock_sources = (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
80
- if Bundler.feature_flag.disable_multisource?
81
- lock_sources + rubygems_sources.sort_by(&:to_s)
90
+ if disable_multisource?
91
+ lock_sources + rubygems_sources.sort_by(&:to_s).uniq
82
92
  else
83
93
  lock_sources << combine_rubygems_sources
84
94
  end
@@ -94,7 +104,7 @@ module Bundler
94
104
  end
95
105
  end
96
106
 
97
- replacement_rubygems = !Bundler.feature_flag.disable_multisource? &&
107
+ replacement_rubygems = !disable_multisource? &&
98
108
  replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
99
109
  @global_rubygems_source = replacement_rubygems if replacement_rubygems
100
110
 
@@ -78,10 +78,17 @@ module Bundler
78
78
 
79
79
  def materialize(deps, missing_specs = nil)
80
80
  materialized = self.for(deps, [], false, true, !missing_specs).to_a
81
- deps = materialized.map(&:name).uniq
81
+
82
+ materialized.group_by(&:source).each do |source, specs|
83
+ next unless specs.any?{|s| s.is_a?(LazySpecification) }
84
+
85
+ source.local!
86
+ names = -> { specs.map(&:name).uniq }
87
+ source.double_check_for(names)
88
+ end
89
+
82
90
  materialized.map! do |s|
83
91
  next s unless s.is_a?(LazySpecification)
84
- s.source.dependency_names = deps if s.source.respond_to?(:dependency_names=)
85
92
  spec = s.__materialize__
86
93
  unless spec
87
94
  unless missing_specs
@@ -98,11 +105,17 @@ module Bundler
98
105
  # This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform)
99
106
  # @return [Array<Gem::Specification>]
100
107
  def materialized_for_all_platforms
101
- names = @specs.map(&:name).uniq
108
+ @specs.group_by(&:source).each do |source, specs|
109
+ next unless specs.any?{|s| s.is_a?(LazySpecification) }
110
+
111
+ source.local!
112
+ source.remote!
113
+ names = -> { specs.map(&:name).uniq }
114
+ source.double_check_for(names)
115
+ end
116
+
102
117
  @specs.map do |s|
103
118
  next s unless s.is_a?(LazySpecification)
104
- s.source.dependency_names = names if s.source.respond_to?(:dependency_names=)
105
- s.source.remote!
106
119
  spec = s.__materialize__
107
120
  raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
108
121
  spec