bundler 2.5.16 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +194 -0
  3. data/bundler.gemspec +2 -2
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli/add.rb +3 -1
  6. data/lib/bundler/cli/check.rb +3 -3
  7. data/lib/bundler/cli/console.rb +0 -4
  8. data/lib/bundler/cli/doctor.rb +4 -4
  9. data/lib/bundler/cli/exec.rb +1 -0
  10. data/lib/bundler/cli/gem.rb +6 -3
  11. data/lib/bundler/cli/info.rb +2 -2
  12. data/lib/bundler/cli/inject.rb +1 -1
  13. data/lib/bundler/cli/install.rb +13 -4
  14. data/lib/bundler/cli/lock.rb +25 -6
  15. data/lib/bundler/cli/outdated.rb +16 -18
  16. data/lib/bundler/cli/pristine.rb +1 -1
  17. data/lib/bundler/cli/show.rb +2 -2
  18. data/lib/bundler/cli.rb +38 -68
  19. data/lib/bundler/compact_index_client/cache_file.rb +0 -5
  20. data/lib/bundler/compact_index_client/updater.rb +0 -11
  21. data/lib/bundler/definition.rb +186 -119
  22. data/lib/bundler/dependency.rb +1 -1
  23. data/lib/bundler/dsl.rb +67 -52
  24. data/lib/bundler/endpoint_specification.rb +10 -1
  25. data/lib/bundler/errors.rb +17 -5
  26. data/lib/bundler/feature_flag.rb +1 -0
  27. data/lib/bundler/fetcher/compact_index.rb +1 -1
  28. data/lib/bundler/fetcher.rb +12 -5
  29. data/lib/bundler/force_platform.rb +0 -2
  30. data/lib/bundler/gem_helpers.rb +21 -5
  31. data/lib/bundler/injector.rb +2 -2
  32. data/lib/bundler/inline.rb +42 -17
  33. data/lib/bundler/installer/gem_installer.rb +4 -2
  34. data/lib/bundler/installer/parallel_installer.rb +3 -2
  35. data/lib/bundler/installer/standalone.rb +2 -2
  36. data/lib/bundler/installer.rb +11 -47
  37. data/lib/bundler/lazy_specification.rb +74 -26
  38. data/lib/bundler/lockfile_generator.rb +1 -1
  39. data/lib/bundler/lockfile_parser.rb +10 -2
  40. data/lib/bundler/man/bundle-add.1 +42 -25
  41. data/lib/bundler/man/bundle-add.1.ronn +52 -23
  42. data/lib/bundler/man/bundle-binstubs.1 +7 -4
  43. data/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  44. data/lib/bundler/man/bundle-cache.1 +30 -2
  45. data/lib/bundler/man/bundle-cache.1.ronn +31 -2
  46. data/lib/bundler/man/bundle-check.1 +3 -3
  47. data/lib/bundler/man/bundle-check.1.ronn +4 -2
  48. data/lib/bundler/man/bundle-clean.1 +1 -1
  49. data/lib/bundler/man/bundle-config.1 +3 -5
  50. data/lib/bundler/man/bundle-config.1.ronn +2 -7
  51. data/lib/bundler/man/bundle-console.1 +2 -4
  52. data/lib/bundler/man/bundle-console.1.ronn +2 -7
  53. data/lib/bundler/man/bundle-doctor.1 +2 -2
  54. data/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  55. data/lib/bundler/man/bundle-env.1 +9 -0
  56. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  57. data/lib/bundler/man/bundle-exec.1 +5 -2
  58. data/lib/bundler/man/bundle-exec.1.ronn +4 -1
  59. data/lib/bundler/man/bundle-fund.1 +22 -0
  60. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  61. data/lib/bundler/man/bundle-gem.1 +17 -5
  62. data/lib/bundler/man/bundle-gem.1.ronn +27 -6
  63. data/lib/bundler/man/bundle-help.1 +1 -1
  64. data/lib/bundler/man/bundle-info.1 +5 -2
  65. data/lib/bundler/man/bundle-info.1.ronn +6 -2
  66. data/lib/bundler/man/bundle-init.1 +3 -3
  67. data/lib/bundler/man/bundle-init.1.ronn +3 -2
  68. data/lib/bundler/man/bundle-inject.1 +10 -2
  69. data/lib/bundler/man/bundle-inject.1.ronn +9 -1
  70. data/lib/bundler/man/bundle-install.1 +15 -12
  71. data/lib/bundler/man/bundle-install.1.ronn +22 -18
  72. data/lib/bundler/man/bundle-issue.1 +45 -0
  73. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  74. data/lib/bundler/man/bundle-licenses.1 +9 -0
  75. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  76. data/lib/bundler/man/bundle-list.1 +1 -1
  77. data/lib/bundler/man/bundle-list.1.ronn +4 -1
  78. data/lib/bundler/man/bundle-lock.1 +21 -6
  79. data/lib/bundler/man/bundle-lock.1.ronn +25 -4
  80. data/lib/bundler/man/bundle-open.1 +2 -2
  81. data/lib/bundler/man/bundle-open.1.ronn +2 -1
  82. data/lib/bundler/man/bundle-outdated.1 +8 -5
  83. data/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  84. data/lib/bundler/man/bundle-platform.1 +1 -1
  85. data/lib/bundler/man/bundle-plugin.1 +1 -1
  86. data/lib/bundler/man/bundle-pristine.1 +1 -1
  87. data/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  88. data/lib/bundler/man/bundle-remove.1 +1 -1
  89. data/lib/bundler/man/bundle-remove.1.ronn +1 -1
  90. data/lib/bundler/man/bundle-show.1 +5 -2
  91. data/lib/bundler/man/bundle-show.1.ronn +4 -0
  92. data/lib/bundler/man/bundle-update.1 +13 -7
  93. data/lib/bundler/man/bundle-update.1.ronn +14 -6
  94. data/lib/bundler/man/bundle-version.1 +1 -1
  95. data/lib/bundler/man/bundle-viz.1 +4 -4
  96. data/lib/bundler/man/bundle-viz.1.ronn +7 -3
  97. data/lib/bundler/man/bundle.1 +1 -1
  98. data/lib/bundler/man/gemfile.5 +3 -1
  99. data/lib/bundler/man/gemfile.5.ronn +6 -0
  100. data/lib/bundler/man/index.txt +4 -0
  101. data/lib/bundler/materialization.rb +59 -0
  102. data/lib/bundler/plugin/api/source.rb +2 -1
  103. data/lib/bundler/plugin/events.rb +24 -0
  104. data/lib/bundler/plugin/installer.rb +1 -1
  105. data/lib/bundler/plugin.rb +20 -1
  106. data/lib/bundler/process_lock.rb +10 -14
  107. data/lib/bundler/remote_specification.rb +6 -1
  108. data/lib/bundler/resolver/base.rb +12 -6
  109. data/lib/bundler/resolver/candidate.rb +2 -2
  110. data/lib/bundler/resolver/package.rb +10 -1
  111. data/lib/bundler/resolver/spec_group.rb +4 -3
  112. data/lib/bundler/resolver.rb +36 -14
  113. data/lib/bundler/retry.rb +1 -1
  114. data/lib/bundler/ruby_version.rb +7 -1
  115. data/lib/bundler/rubygems_ext.rb +104 -51
  116. data/lib/bundler/rubygems_gem_installer.rb +7 -5
  117. data/lib/bundler/rubygems_integration.rb +23 -62
  118. data/lib/bundler/runtime.rb +22 -7
  119. data/lib/bundler/self_manager.rb +7 -7
  120. data/lib/bundler/settings.rb +6 -1
  121. data/lib/bundler/shared_helpers.rb +29 -17
  122. data/lib/bundler/source/git/git_proxy.rb +0 -2
  123. data/lib/bundler/source/git.rb +93 -40
  124. data/lib/bundler/source/metadata.rb +2 -3
  125. data/lib/bundler/source/path.rb +5 -3
  126. data/lib/bundler/source/rubygems.rb +6 -16
  127. data/lib/bundler/source_list.rb +1 -1
  128. data/lib/bundler/spec_set.rb +82 -57
  129. data/lib/bundler/stub_specification.rb +21 -2
  130. data/lib/bundler/templates/newgem/Gemfile.tt +0 -3
  131. data/lib/bundler/templates/newgem/README.md.tt +7 -3
  132. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +15 -15
  133. data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -4
  134. data/lib/bundler/ui/shell.rb +24 -2
  135. data/lib/bundler/ui/silent.rb +12 -1
  136. data/lib/bundler/uri_credentials_filter.rb +1 -1
  137. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  138. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  139. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +46 -8
  140. data/lib/bundler/vendor/securerandom/.document +1 -0
  141. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  142. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  143. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  144. data/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  145. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  146. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  147. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  148. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  149. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  150. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  151. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  152. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  153. data/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  154. data/lib/bundler/vendor/uri/COPYING +56 -0
  155. data/lib/bundler/vendor/uri/lib/uri/common.rb +37 -14
  156. data/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  157. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  158. data/lib/bundler/vendor/uri/lib/uri/generic.rb +16 -26
  159. data/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  160. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  161. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  162. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  163. data/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  164. data/lib/bundler/vendored_securerandom.rb +12 -0
  165. data/lib/bundler/version.rb +1 -1
  166. data/lib/bundler/yaml_serializer.rb +1 -1
  167. data/lib/bundler.rb +68 -36
  168. metadata +20 -10
  169. data/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  170. data/lib/bundler/vendor/uri/LICENSE.txt +0 -22
@@ -30,24 +30,31 @@ module Gem
30
30
  end
31
31
  end
32
32
 
33
- # Can be removed once RubyGems 3.5.14 support is dropped
34
- unless Gem.respond_to?(:open_file_with_flock)
35
- def self.open_file_with_flock(path, &block)
36
- flags = File.exist?(path) ? "r+" : "a+"
37
-
38
- File.open(path, flags) do |io|
39
- begin
40
- io.flock(File::LOCK_EX)
41
- rescue Errno::ENOSYS, Errno::ENOTSUP
42
- end
43
- yield io
44
- rescue Errno::ENOLCK # NFS
45
- if Thread.main != Thread.current
46
- raise
47
- else
48
- File.open(path, flags, &block)
33
+ # Can be removed once RubyGems 3.5.18 support is dropped
34
+ unless Gem.respond_to?(:open_file_with_lock)
35
+ class << self
36
+ remove_method :open_file_with_flock if Gem.respond_to?(:open_file_with_flock)
37
+
38
+ def open_file_with_flock(path, &block)
39
+ # read-write mode is used rather than read-only in order to support NFS
40
+ mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
41
+ mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)
42
+
43
+ File.open(path, mode) do |io|
44
+ begin
45
+ io.flock(File::LOCK_EX)
46
+ rescue Errno::ENOSYS, Errno::ENOTSUP
47
+ end
48
+ yield io
49
49
  end
50
50
  end
51
+
52
+ def open_file_with_lock(path, &block)
53
+ file_lock = "#{path}.lock"
54
+ open_file_with_flock(file_lock, &block)
55
+ ensure
56
+ FileUtils.rm_f file_lock
57
+ end
51
58
  end
52
59
  end
53
60
 
@@ -72,14 +79,18 @@ module Gem
72
79
  include ::Bundler::MatchMetadata
73
80
  include ::Bundler::MatchPlatform
74
81
 
75
- attr_accessor :remote, :location, :relative_loaded_from
82
+ attr_accessor :remote, :relative_loaded_from
83
+
84
+ module AllowSettingSource
85
+ attr_writer :source
76
86
 
77
- remove_method :source
78
- attr_writer :source
79
- def source
80
- (defined?(@source) && @source) || Gem::Source::Installed.new
87
+ def source
88
+ (defined?(@source) && @source) || super
89
+ end
81
90
  end
82
91
 
92
+ prepend AllowSettingSource
93
+
83
94
  alias_method :rg_full_gem_path, :full_gem_path
84
95
  alias_method :rg_loaded_from, :loaded_from
85
96
 
@@ -115,7 +126,9 @@ module Gem
115
126
  end
116
127
  end
117
128
 
118
- remove_method :gem_dir
129
+ # Can be removed once RubyGems 3.5.21 support is dropped
130
+ remove_method :gem_dir if method_defined?(:gem_dir, false)
131
+
119
132
  def gem_dir
120
133
  full_gem_path
121
134
  end
@@ -137,6 +150,10 @@ module Gem
137
150
  end
138
151
  end
139
152
 
153
+ def insecurely_materialized?
154
+ false
155
+ end
156
+
140
157
  def groups
141
158
  @groups ||= []
142
159
  end
@@ -237,26 +254,20 @@ module Gem
237
254
 
238
255
  include ::Bundler::ForcePlatform
239
256
 
257
+ attr_reader :force_ruby_platform
258
+
240
259
  attr_accessor :source, :groups
241
260
 
242
261
  alias_method :eql?, :==
243
262
 
244
- def force_ruby_platform
245
- return @force_ruby_platform if defined?(@force_ruby_platform) && !@force_ruby_platform.nil?
246
-
247
- @force_ruby_platform = default_force_ruby_platform
248
- end
249
-
250
- def encode_with(coder)
251
- to_yaml_properties.each do |ivar|
252
- coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
263
+ unless method_defined?(:encode_with, false)
264
+ def encode_with(coder)
265
+ [:@name, :@requirement, :@type, :@prerelease, :@version_requirements].each do |ivar|
266
+ coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
267
+ end
253
268
  end
254
269
  end
255
270
 
256
- def to_yaml_properties
257
- instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
258
- end
259
-
260
271
  def to_lock
261
272
  out = String.new(" #{name}")
262
273
  unless requirement.none?
@@ -265,22 +276,15 @@ module Gem
265
276
  end
266
277
  out
267
278
  end
268
- end
269
279
 
270
- # Requirements using lambda operator differentiate trailing zeros since rubygems 3.2.6
271
- if Gem::Requirement.new("~> 2.0").hash == Gem::Requirement.new("~> 2.0.0").hash
272
- class Requirement
273
- module CorrectHashForLambdaOperator
274
- def hash
275
- if requirements.any? {|r| r.first == "~>" }
276
- requirements.map {|r| r.first == "~>" ? [r[0], r[1].to_s] : r }.sort.hash
277
- else
278
- super
279
- end
280
+ if Gem.rubygems_version < Gem::Version.new("3.5.22")
281
+ module FilterIgnoredSpecs
282
+ def matching_specs(platform_only = false)
283
+ super.reject(&:ignored?)
280
284
  end
281
285
  end
282
286
 
283
- prepend CorrectHashForLambdaOperator
287
+ prepend FilterIgnoredSpecs
284
288
  end
285
289
  end
286
290
 
@@ -333,10 +337,6 @@ module Gem
333
337
  without_gnu_nor_abi_modifiers
334
338
  end
335
339
  end
336
-
337
- if RUBY_ENGINE == "truffleruby" && !defined?(REUSE_AS_BINARY_ON_TRUFFLERUBY)
338
- REUSE_AS_BINARY_ON_TRUFFLERUBY = %w[libv8 libv8-node sorbet-static].freeze
339
- end
340
340
  end
341
341
 
342
342
  Platform.singleton_class.module_eval do
@@ -387,6 +387,15 @@ module Gem
387
387
  end
388
388
  end
389
389
  end
390
+
391
+ # Can be removed once RubyGems 3.5.22 support is dropped
392
+ unless new.respond_to?(:ignored?)
393
+ def ignored?
394
+ return @ignored unless @ignored.nil?
395
+
396
+ @ignored = missing_extensions?
397
+ end
398
+ end
390
399
  end
391
400
 
392
401
  require "rubygems/name_tuple"
@@ -413,4 +422,48 @@ module Gem
413
422
  end
414
423
  end
415
424
  end
425
+
426
+ unless Gem.rubygems_version >= Gem::Version.new("3.5.19")
427
+ class Resolver::ActivationRequest
428
+ remove_method :installed?
429
+
430
+ def installed?
431
+ case @spec
432
+ when Gem::Resolver::VendorSpecification then
433
+ true
434
+ else
435
+ this_spec = full_spec
436
+
437
+ Gem::Specification.any? do |s|
438
+ s == this_spec && s.base_dir == this_spec.base_dir
439
+ end
440
+ end
441
+ end
442
+ end
443
+ end
444
+
445
+ if Gem.rubygems_version < Gem::Version.new("3.6.0")
446
+ class Package; end
447
+ require "rubygems/package/tar_reader"
448
+ require "rubygems/package/tar_reader/entry"
449
+
450
+ module FixFullNameEncoding
451
+ def full_name
452
+ super.force_encoding(Encoding::UTF_8)
453
+ end
454
+ end
455
+
456
+ Package::TarReader::Entry.prepend(FixFullNameEncoding)
457
+ end
458
+
459
+ require "rubygems/uri"
460
+
461
+ # Can be removed once RubyGems 3.3.15 support is dropped
462
+ unless Gem::Uri.respond_to?(:redact)
463
+ class Uri
464
+ def self.redact(uri)
465
+ new(uri).redacted
466
+ end
467
+ end
468
+ end
416
469
  end
@@ -23,7 +23,9 @@ module Bundler
23
23
  FileUtils.mkdir_p gem_dir, mode: 0o755
24
24
  end
25
25
 
26
- extract_files
26
+ SharedHelpers.filesystem_access(gem_dir, :write) do
27
+ extract_files
28
+ end
27
29
 
28
30
  build_extensions if spec.extensions.any?
29
31
  write_build_info_file
@@ -81,11 +83,11 @@ module Bundler
81
83
  end
82
84
  end
83
85
 
84
- if Bundler.rubygems.provides?("< 3.5.15")
86
+ if Bundler.rubygems.provides?("< 3.5.19")
85
87
  def generate_bin_script(filename, bindir)
86
88
  bin_script_path = File.join bindir, formatted_program_filename(filename)
87
89
 
88
- Gem.open_file_with_flock("#{bin_script_path}.lock") do
90
+ Gem.open_file_with_lock(bin_script_path) do
89
91
  require "fileutils"
90
92
  FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
91
93
 
@@ -145,17 +147,17 @@ module Bundler
145
147
  SharedHelpers.filesystem_access(extension_dir, :create) do
146
148
  FileUtils.mkdir_p extension_dir
147
149
  end
148
- require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
149
150
  end
150
151
 
151
152
  def strict_rm_rf(dir)
152
153
  return unless File.exist?(dir)
154
+ return if Dir.empty?(dir)
153
155
 
154
156
  parent = File.dirname(dir)
155
157
  parent_st = File.stat(parent)
156
158
 
157
159
  if parent_st.world_writable? && !parent_st.sticky?
158
- raise InsecureInstallPathError.new(parent)
160
+ raise InsecureInstallPathError.new(spec.full_name, dir)
159
161
  end
160
162
 
161
163
  begin
@@ -20,10 +20,6 @@ module Bundler
20
20
  Gem::Requirement.new(req_str).satisfied_by?(version)
21
21
  end
22
22
 
23
- def supports_bundler_trampolining?
24
- provides?(">= 3.3.0.a")
25
- end
26
-
27
23
  def build_args
28
24
  require "rubygems/command"
29
25
  Gem::Command.build_args
@@ -34,6 +30,10 @@ module Bundler
34
30
  Gem::Command.build_args = args
35
31
  end
36
32
 
33
+ def set_target_rbconfig(path)
34
+ Gem.set_target_rbconfig(path)
35
+ end
36
+
37
37
  def loaded_specs(name)
38
38
  Gem.loaded_specs[name]
39
39
  end
@@ -57,28 +57,6 @@ module Bundler
57
57
  nil
58
58
  end
59
59
 
60
- def set_installed_by_version(spec, installed_by_version = Gem::VERSION)
61
- return unless spec.respond_to?(:installed_by_version=)
62
- spec.installed_by_version = Gem::Version.create(installed_by_version)
63
- end
64
-
65
- def spec_missing_extensions?(spec, default = true)
66
- return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
67
-
68
- return false if spec.default_gem?
69
- return false if spec.extensions.empty?
70
-
71
- default
72
- end
73
-
74
- def spec_matches_for_glob(spec, glob)
75
- return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
76
-
77
- spec.load_paths.flat_map do |lp|
78
- Dir["#{lp}/#{glob}#{suffix_pattern}"]
79
- end
80
- end
81
-
82
60
  def stub_set_spec(stub, spec)
83
61
  stub.instance_variable_set(:@spec, spec)
84
62
  end
@@ -156,6 +134,18 @@ module Bundler
156
134
  loaded_gem_paths.flatten
157
135
  end
158
136
 
137
+ def load_plugins
138
+ Gem.load_plugins
139
+ end
140
+
141
+ def load_plugin_files(plugin_files)
142
+ Gem.load_plugin_files(plugin_files)
143
+ end
144
+
145
+ def load_env_plugins
146
+ Gem.load_env_plugins
147
+ end
148
+
159
149
  def ui=(obj)
160
150
  Gem::DefaultUserInteraction.ui = obj
161
151
  end
@@ -242,9 +232,7 @@ module Bundler
242
232
  end
243
233
  end
244
234
 
245
- # Used to make bin stubs that are not created by bundler work
246
- # under bundler. The new Gem.bin_path only considers gems in
247
- # +specs+
235
+ # Used to give better error messages when activating specs outside of the current bundle
248
236
  def replace_bin_path(specs_by_name)
249
237
  gem_class = (class << Gem; self; end)
250
238
 
@@ -283,31 +271,6 @@ module Bundler
283
271
 
284
272
  spec
285
273
  end
286
-
287
- redefine_method(gem_class, :activate_bin_path) do |name, *args|
288
- exec_name = args.first
289
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
290
-
291
- # Copy of Rubygems activate_bin_path impl
292
- requirement = args.last
293
- spec = find_spec_for_exe name, exec_name, [requirement]
294
-
295
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
296
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
297
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
298
- end
299
-
300
- redefine_method(gem_class, :bin_path) do |name, *args|
301
- exec_name = args.first
302
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
303
-
304
- spec = find_spec_for_exe(name, *args)
305
- exec_name ||= spec.default_executable
306
-
307
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
308
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
309
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
310
- end
311
274
  end
312
275
 
313
276
  # Replace or hook into RubyGems to provide a bundlerized view
@@ -324,7 +287,7 @@ module Bundler
324
287
  Gem::BUNDLED_GEMS.replace_require(specs) if Gem::BUNDLED_GEMS.respond_to?(:replace_require)
325
288
  end
326
289
  replace_gem(specs, specs_by_name)
327
- stub_rubygems(specs)
290
+ stub_rubygems(specs_by_name.values)
328
291
  replace_bin_path(specs_by_name)
329
292
 
330
293
  Gem.clear_paths
@@ -353,11 +316,7 @@ module Bundler
353
316
  @replaced_methods.each do |(sym, klass), method|
354
317
  redefine_method(klass, sym, method)
355
318
  end
356
- if Binding.public_method_defined?(:source_location)
357
- post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
358
- else
359
- post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
360
- end
319
+ post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
361
320
  @replaced_methods.clear
362
321
  end
363
322
 
@@ -434,7 +393,9 @@ module Bundler
434
393
  def download_gem(spec, uri, cache_dir, fetcher)
435
394
  require "rubygems/remote_fetcher"
436
395
  uri = Bundler.settings.mirror_for(uri)
437
- Bundler::Retry.new("download gem from #{uri}").attempts do
396
+ redacted_uri = Gem::Uri.redact(uri)
397
+
398
+ Bundler::Retry.new("download gem from #{redacted_uri}").attempts do
438
399
  gem_file_name = spec.file_name
439
400
  local_gem_path = File.join cache_dir, gem_file_name
440
401
  return if File.exist? local_gem_path
@@ -456,7 +417,7 @@ module Bundler
456
417
  end
457
418
  end
458
419
  rescue Gem::RemoteFetcher::FetchError => e
459
- raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
420
+ raise Bundler::HTTPError, "Could not download gem from #{redacted_uri} due to underlying error <#{e.message}>"
460
421
  end
461
422
 
462
423
  def build(spec, skip_validation = false)
@@ -41,12 +41,17 @@ module Bundler
41
41
  groups.map!(&:to_sym)
42
42
  groups = [:default] if groups.empty?
43
43
 
44
- @definition.dependencies.each do |dep|
45
- # Skip the dependency if it is not in any of the requested groups, or
46
- # not for the current platform, or doesn't match the gem constraints.
47
- next unless (dep.groups & groups).any? && dep.should_include?
44
+ dependencies = @definition.dependencies.select do |dep|
45
+ # Select the dependency if it is in any of the requested groups, and
46
+ # for the current platform, and matches the gem constraints.
47
+ (dep.groups & groups).any? && dep.should_include?
48
+ end
49
+
50
+ Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE_ALL, dependencies)
48
51
 
52
+ dependencies.each do |dep|
49
53
  required_file = nil
54
+ Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE, dep)
50
55
 
51
56
  begin
52
57
  # Loop through all the specified autorequires for the
@@ -76,7 +81,13 @@ module Bundler
76
81
  end
77
82
  end
78
83
  end
84
+
85
+ Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE, dep)
79
86
  end
87
+
88
+ Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE_ALL, dependencies)
89
+
90
+ dependencies
80
91
  end
81
92
 
82
93
  def self.definition_method(meth)
@@ -125,7 +136,11 @@ module Bundler
125
136
  specs_to_cache.each do |spec|
126
137
  next if spec.name == "bundler"
127
138
  next if spec.source.is_a?(Source::Gemspec)
128
- spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
139
+ if spec.source.respond_to?(:migrate_cache)
140
+ spec.source.migrate_cache(custom_path, local: local)
141
+ elsif spec.source.respond_to?(:cache)
142
+ spec.source.cache(spec, custom_path)
143
+ end
129
144
  end
130
145
 
131
146
  Dir[cache_path.join("*/.git")].each do |git_dir|
@@ -257,10 +272,10 @@ module Bundler
257
272
 
258
273
  def setup_manpath
259
274
  # Add man/ subdirectories from activated bundles to MANPATH for man(1)
260
- manuals = $LOAD_PATH.map do |path|
275
+ manuals = $LOAD_PATH.filter_map do |path|
261
276
  man_subdir = path.sub(/lib$/, "man")
262
277
  man_subdir unless Dir[man_subdir + "/man?/"].empty?
263
- end.compact
278
+ end
264
279
 
265
280
  return if manuals.empty?
266
281
  Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
@@ -84,8 +84,9 @@ module Bundler
84
84
  require "shellwords"
85
85
  cmd = [*Shellwords.shellsplit(bundler_spec_original_cmd), *ARGV]
86
86
  else
87
- cmd = [$PROGRAM_NAME, *ARGV]
88
- cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
87
+ argv0 = File.exist?($PROGRAM_NAME) ? $PROGRAM_NAME : Process.argv0
88
+ cmd = [argv0, *ARGV]
89
+ cmd.unshift(Gem.ruby) unless File.executable?(argv0)
89
90
  end
90
91
 
91
92
  Bundler.with_original_env do
@@ -98,15 +99,14 @@ module Bundler
98
99
 
99
100
  def needs_switching?
100
101
  autoswitching_applies? &&
101
- released?(lockfile_version) &&
102
- !running?(lockfile_version) &&
103
- !updating? &&
104
- Bundler.settings[:version] != "system"
102
+ Bundler.settings[:version] != "system" &&
103
+ released?(restart_version) &&
104
+ !running?(restart_version) &&
105
+ !updating?
105
106
  end
106
107
 
107
108
  def autoswitching_applies?
108
109
  ENV["BUNDLER_VERSION"].nil? &&
109
- Bundler.rubygems.supports_bundler_trampolining? &&
110
110
  ruby_can_restart_with_same_arguments? &&
111
111
  SharedHelpers.in_bundle? &&
112
112
  lockfile_version
@@ -32,6 +32,7 @@ module Bundler
32
32
  ignore_messages
33
33
  init_gems_rb
34
34
  inline
35
+ lockfile_checksums
35
36
  no_install
36
37
  no_prune
37
38
  path_relative_to_cwd
@@ -425,8 +426,12 @@ module Bundler
425
426
  Validator.validate!(raw_key, converted_value(value, raw_key), hash)
426
427
 
427
428
  return unless file
429
+
430
+ SharedHelpers.filesystem_access(file.dirname, :create) do |p|
431
+ FileUtils.mkdir_p(p)
432
+ end
433
+
428
434
  SharedHelpers.filesystem_access(file) do |p|
429
- FileUtils.mkdir_p(p.dirname)
430
435
  p.open("w") {|f| f.write(serializer_class.dump(hash)) }
431
436
  end
432
437
  end
@@ -96,14 +96,16 @@ module Bundler
96
96
  # given block
97
97
  #
98
98
  # @example
99
- # filesystem_access("vendor/cache", :write) do
99
+ # filesystem_access("vendor/cache", :create) do
100
100
  # FileUtils.mkdir_p("vendor/cache")
101
101
  # end
102
102
  #
103
103
  # @see {Bundler::PermissionError}
104
104
  def filesystem_access(path, action = :write, &block)
105
105
  yield(path.dup)
106
- rescue Errno::EACCES
106
+ rescue Errno::EACCES => e
107
+ raise unless e.message.include?(path.to_s) || action == :create
108
+
107
109
  raise PermissionError.new(path, action)
108
110
  rescue Errno::EAGAIN
109
111
  raise TemporaryResourceError.new(path, action)
@@ -116,7 +118,7 @@ module Bundler
116
118
  rescue Errno::EEXIST, Errno::ENOENT
117
119
  raise
118
120
  rescue SystemCallError => e
119
- raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
121
+ raise GenericSystemCallError.new(e, "There was an error #{[:create, :write].include?(action) ? "creating" : "accessing"} `#{path}`.")
120
122
  end
121
123
 
122
124
  def major_deprecation(major_version, message, removed_message: nil, print_caller_location: false)
@@ -160,10 +162,10 @@ module Bundler
160
162
  extra_deps = new_deps - old_deps
161
163
  return if extra_deps.empty?
162
164
 
163
- Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has either corrupted API or lockfile dependencies" \
165
+ Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has corrupted API dependencies" \
164
166
  " (was expecting #{old_deps.map(&:to_s)}, but the real spec has #{new_deps.map(&:to_s)})"
165
167
  raise APIResponseMismatchError,
166
- "Downloading #{spec.full_name} revealed dependencies not in the API or the lockfile (#{extra_deps.join(", ")})." \
168
+ "Downloading #{spec.full_name} revealed dependencies not in the API (#{extra_deps.join(", ")})." \
167
169
  "\nRunning `bundle update #{spec.name}` should fix the problem."
168
170
  end
169
171
 
@@ -274,15 +276,7 @@ module Bundler
274
276
  until !File.directory?(current) || current == previous
275
277
  if ENV["BUNDLER_SPEC_RUN"]
276
278
  # avoid stepping above the tmp directory when testing
277
- gemspec = if ENV["GEM_COMMAND"]
278
- # for Ruby Core
279
- "lib/bundler/bundler.gemspec"
280
- else
281
- "bundler.gemspec"
282
- end
283
-
284
- # avoid stepping above the tmp directory when testing
285
- return nil if File.file?(File.join(current, gemspec))
279
+ return nil if File.directory?(File.join(current, "tmp"))
286
280
  end
287
281
 
288
282
  names.each do |name|
@@ -314,18 +308,36 @@ module Bundler
314
308
 
315
309
  def bundle_bin_path
316
310
  # bundler exe & lib folders have same root folder, typical gem installation
317
- exe_file = File.expand_path("../../exe/bundle", __dir__)
311
+ exe_file = File.join(source_root, "exe/bundle")
318
312
 
319
313
  # for Ruby core repository testing
320
- exe_file = File.expand_path("../../libexec/bundle", __dir__) unless File.exist?(exe_file)
314
+ exe_file = File.join(source_root, "libexec/bundle") unless File.exist?(exe_file)
321
315
 
322
316
  # bundler is a default gem, exe path is separate
323
- exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
317
+ exe_file = Gem.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
324
318
 
325
319
  exe_file
326
320
  end
327
321
  public :bundle_bin_path
328
322
 
323
+ def gemspec_path
324
+ # inside a gem repository, typical gem installation
325
+ gemspec_file = File.join(source_root, "../../specifications/bundler-#{VERSION}.gemspec")
326
+
327
+ # for Ruby core repository testing
328
+ gemspec_file = File.expand_path("bundler.gemspec", __dir__) unless File.exist?(gemspec_file)
329
+
330
+ # bundler is a default gem
331
+ gemspec_file = File.join(Gem.default_specifications_dir, "bundler-#{VERSION}.gemspec") unless File.exist?(gemspec_file)
332
+
333
+ gemspec_file
334
+ end
335
+ public :gemspec_path
336
+
337
+ def source_root
338
+ File.expand_path("../..", __dir__)
339
+ end
340
+
329
341
  def set_path
330
342
  validate_bundle_path
331
343
  paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
@@ -332,8 +332,6 @@ module Bundler
332
332
  config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
333
333
  remote.userinfo ||= config_auth
334
334
  remote.to_s
335
- elsif File.exist?(uri)
336
- "file://#{uri}"
337
335
  else
338
336
  uri.to_s
339
337
  end