bundler 2.2.24 → 2.3.7

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 (154) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +246 -1
  3. data/README.md +1 -1
  4. data/exe/bundle +7 -8
  5. data/lib/bundler/.document +1 -0
  6. data/lib/bundler/build_metadata.rb +2 -2
  7. data/lib/bundler/cli/cache.rb +1 -1
  8. data/lib/bundler/cli/config.rb +10 -1
  9. data/lib/bundler/cli/doctor.rb +13 -4
  10. data/lib/bundler/cli/exec.rb +1 -6
  11. data/lib/bundler/cli/gem.rb +101 -11
  12. data/lib/bundler/cli/info.rb +26 -5
  13. data/lib/bundler/cli/install.rb +12 -45
  14. data/lib/bundler/cli/issue.rb +4 -3
  15. data/lib/bundler/cli/list.rb +7 -1
  16. data/lib/bundler/cli/open.rb +1 -2
  17. data/lib/bundler/cli/platform.rb +1 -1
  18. data/lib/bundler/cli/remove.rb +1 -2
  19. data/lib/bundler/cli/update.rb +9 -5
  20. data/lib/bundler/cli.rb +24 -20
  21. data/lib/bundler/compact_index_client/cache.rb +0 -9
  22. data/lib/bundler/compact_index_client/updater.rb +0 -5
  23. data/lib/bundler/compact_index_client.rb +2 -8
  24. data/lib/bundler/definition.rb +97 -161
  25. data/lib/bundler/dependency.rb +5 -7
  26. data/lib/bundler/digest.rb +71 -0
  27. data/lib/bundler/dsl.rb +32 -31
  28. data/lib/bundler/endpoint_specification.rb +21 -11
  29. data/lib/bundler/env.rb +1 -1
  30. data/lib/bundler/environment_preserver.rb +4 -1
  31. data/lib/bundler/errors.rb +19 -3
  32. data/lib/bundler/fetcher/compact_index.rb +9 -14
  33. data/lib/bundler/fetcher/index.rb +0 -26
  34. data/lib/bundler/fetcher.rb +13 -20
  35. data/lib/bundler/friendly_errors.rb +5 -30
  36. data/lib/bundler/gem_helper.rb +7 -18
  37. data/lib/bundler/injector.rb +10 -1
  38. data/lib/bundler/installer/gem_installer.rb +4 -22
  39. data/lib/bundler/installer/standalone.rb +13 -8
  40. data/lib/bundler/installer.rb +1 -5
  41. data/lib/bundler/lazy_specification.rb +19 -3
  42. data/lib/bundler/lockfile_generator.rb +1 -1
  43. data/lib/bundler/lockfile_parser.rb +11 -12
  44. data/lib/bundler/man/bundle-add.1 +10 -2
  45. data/lib/bundler/man/bundle-add.1.ronn +7 -1
  46. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  47. data/lib/bundler/man/bundle-cache.1 +1 -1
  48. data/lib/bundler/man/bundle-check.1 +1 -1
  49. data/lib/bundler/man/bundle-clean.1 +1 -1
  50. data/lib/bundler/man/bundle-config.1 +5 -5
  51. data/lib/bundler/man/bundle-config.1.ronn +5 -5
  52. data/lib/bundler/man/bundle-doctor.1 +1 -1
  53. data/lib/bundler/man/bundle-exec.1 +1 -1
  54. data/lib/bundler/man/bundle-gem.1 +14 -1
  55. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  56. data/lib/bundler/man/bundle-info.1 +1 -1
  57. data/lib/bundler/man/bundle-init.1 +1 -1
  58. data/lib/bundler/man/bundle-inject.1 +1 -1
  59. data/lib/bundler/man/bundle-install.1 +2 -2
  60. data/lib/bundler/man/bundle-install.1.ronn +2 -2
  61. data/lib/bundler/man/bundle-list.1 +1 -1
  62. data/lib/bundler/man/bundle-lock.1 +1 -1
  63. data/lib/bundler/man/bundle-open.1 +1 -1
  64. data/lib/bundler/man/bundle-outdated.1 +1 -1
  65. data/lib/bundler/man/bundle-platform.1 +1 -1
  66. data/lib/bundler/man/bundle-pristine.1 +1 -1
  67. data/lib/bundler/man/bundle-remove.1 +1 -1
  68. data/lib/bundler/man/bundle-show.1 +1 -1
  69. data/lib/bundler/man/bundle-update.1 +2 -2
  70. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  71. data/lib/bundler/man/bundle-viz.1 +1 -1
  72. data/lib/bundler/man/bundle.1 +1 -1
  73. data/lib/bundler/man/gemfile.5 +28 -2
  74. data/lib/bundler/man/gemfile.5.ronn +9 -1
  75. data/lib/bundler/plugin/api/source.rb +1 -0
  76. data/lib/bundler/plugin/installer.rb +3 -1
  77. data/lib/bundler/plugin.rb +23 -6
  78. data/lib/bundler/process_lock.rb +1 -1
  79. data/lib/bundler/remote_specification.rb +7 -0
  80. data/lib/bundler/resolver/spec_group.rb +1 -1
  81. data/lib/bundler/resolver.rb +38 -47
  82. data/lib/bundler/ruby_version.rb +1 -1
  83. data/lib/bundler/rubygems_ext.rb +19 -10
  84. data/lib/bundler/rubygems_gem_installer.rb +25 -5
  85. data/lib/bundler/rubygems_integration.rb +40 -70
  86. data/lib/bundler/runtime.rb +17 -8
  87. data/lib/bundler/self_manager.rb +168 -0
  88. data/lib/bundler/settings.rb +15 -2
  89. data/lib/bundler/setup.rb +2 -2
  90. data/lib/bundler/shared_helpers.rb +4 -19
  91. data/lib/bundler/source/git/git_proxy.rb +8 -6
  92. data/lib/bundler/source/git.rb +22 -4
  93. data/lib/bundler/source/metadata.rb +1 -1
  94. data/lib/bundler/source/rubygems.rb +70 -81
  95. data/lib/bundler/source/rubygems_aggregate.rb +4 -0
  96. data/lib/bundler/source.rb +4 -0
  97. data/lib/bundler/source_list.rb +22 -31
  98. data/lib/bundler/spec_set.rb +14 -36
  99. data/lib/bundler/templates/Executable.bundler +7 -7
  100. data/lib/bundler/templates/Gemfile +0 -2
  101. data/lib/bundler/templates/gems.rb +0 -3
  102. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  103. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  104. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -2
  105. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -15
  106. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  107. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  108. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  109. data/lib/bundler/ui/shell.rb +1 -1
  110. data/lib/bundler/vendor/.document +1 -0
  111. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  112. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  113. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  114. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  115. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  116. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  117. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  118. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  119. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  120. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  121. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  122. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  123. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  124. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  125. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  126. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  127. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  128. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  129. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  130. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  131. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  132. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  133. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  134. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  135. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  136. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  137. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  138. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  139. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  140. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  141. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  142. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  143. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  144. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  145. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  146. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  147. data/lib/bundler/vendored_tsort.rb +4 -0
  148. data/lib/bundler/version.rb +1 -1
  149. data/lib/bundler/worker.rb +19 -4
  150. data/lib/bundler.rb +23 -26
  151. metadata +25 -10
  152. data/lib/bundler/gemdeps.rb +0 -29
  153. data/lib/bundler/psyched_yaml.rb +0 -22
  154. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -12,7 +12,7 @@ module Bundler
12
12
  yield
13
13
  f.flock(File::LOCK_UN)
14
14
  end
15
- rescue Errno::EACCES, Errno::ENOLCK, *[SharedHelpers.const_get_safely(:ENOTSUP, Errno)].compact
15
+ rescue Errno::EACCES, Errno::ENOLCK, Errno::ENOTSUP
16
16
  # In the case the user does not have access to
17
17
  # create the lock file or is using NFS where
18
18
  # locks are not available we skip locking.
@@ -27,6 +27,13 @@ module Bundler
27
27
  @platform = _remote_specification.platform
28
28
  end
29
29
 
30
+ # A fallback is included because the original version of the specification
31
+ # API didn't include that field, so some marshalled specs in the index have it
32
+ # set to +nil+.
33
+ def required_rubygems_version
34
+ @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default
35
+ end
36
+
30
37
  def full_name
31
38
  if platform == Gem::Platform::RUBY || platform.nil?
32
39
  "#{@name}-#{@version}"
@@ -95,7 +95,7 @@ module Bundler
95
95
 
96
96
  def metadata_dependencies(platform)
97
97
  spec = @specs[platform].first
98
- return [] unless spec.is_a?(Gem::Specification)
98
+ return [] if spec.is_a?(LazySpecification)
99
99
  dependencies = []
100
100
  if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
101
101
  dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
@@ -30,10 +30,8 @@ module Bundler
30
30
  @resolver = Molinillo::Resolver.new(self, self)
31
31
  @search_for = {}
32
32
  @base_dg = Molinillo::DependencyGraph.new
33
- aggregate_global_source = @source_requirements[:default].is_a?(Source::RubygemsAggregate)
34
33
  @base.each do |ls|
35
34
  dep = Dependency.new(ls.name, ls.version)
36
- ls.source = source_for(ls.name) unless aggregate_global_source
37
35
  @base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true)
38
36
  end
39
37
  additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) }
@@ -136,6 +134,7 @@ module Bundler
136
134
  end
137
135
  nested.reduce([]) do |groups, (version, specs)|
138
136
  next groups if locked_requirement && !locked_requirement.satisfied_by?(version)
137
+ next groups unless specs.any? {|spec| spec.match_platform(platform) }
139
138
 
140
139
  specs_by_platform = Hash.new do |current_specs, current_platform|
141
140
  current_specs[current_platform] = select_best_platform_match(specs, current_platform)
@@ -147,7 +146,7 @@ module Bundler
147
146
  next groups if @resolving_only_for_ruby
148
147
 
149
148
  spec_group = SpecGroup.create_for(specs_by_platform, @platforms, platform)
150
- groups << spec_group if spec_group
149
+ groups << spec_group
151
150
 
152
151
  groups
153
152
  end
@@ -250,16 +249,11 @@ module Bundler
250
249
  end
251
250
 
252
251
  def verify_gemfile_dependencies_are_found!(requirements)
253
- requirements.each do |requirement|
252
+ requirements.map! do |requirement|
254
253
  name = requirement.name
255
- next if name == "bundler"
256
- next unless search_for(requirement).empty?
257
-
258
- cache_message = begin
259
- " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
260
- rescue GemfileNotFound
261
- nil
262
- end
254
+ next requirement if name == "bundler"
255
+ next requirement unless search_for(requirement).empty?
256
+ next unless requirement.current_platform?
263
257
 
264
258
  if (base = @base[name]) && !base.empty?
265
259
  version = base.first.version
@@ -269,32 +263,38 @@ module Bundler
269
263
  "Try running `bundle update #{name}`\n\n" \
270
264
  "If you are updating multiple gems in your Gemfile at once,\n" \
271
265
  "try passing them all to `bundle update`"
272
- elsif source = @source_requirements[name]
273
- specs = source.specs.search(name)
274
- versions_with_platforms = specs.map {|s| [s.version, s.platform] }
275
- message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
276
- message << if versions_with_platforms.any?
277
- "The source contains the following versions of '#{name}': #{formatted_versions_with_platforms(versions_with_platforms)}"
278
- else
279
- "The source does not contain any versions of '#{name}'"
280
- end
281
266
  else
282
- message = "Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in any of the gem sources " \
283
- "listed in your Gemfile#{cache_message}."
267
+ message = gem_not_found_message(name, requirement, source_for(name))
284
268
  end
285
269
  raise GemNotFound, message
286
- end
270
+ end.compact!
287
271
  end
288
272
 
289
- def formatted_versions_with_platforms(versions_with_platforms)
290
- version_platform_strs = versions_with_platforms.map do |vwp|
291
- version = vwp.first
292
- platform = vwp.last
293
- version_platform_str = String.new(version.to_s)
294
- version_platform_str << " #{platform}" unless platform.nil? || platform == Gem::Platform::RUBY
295
- version_platform_str
273
+ def gem_not_found_message(name, requirement, source, extra_message = "")
274
+ specs = source.specs.search(name)
275
+ matching_part = name
276
+ requirement_label = SharedHelpers.pretty_dependency(requirement)
277
+ cache_message = begin
278
+ " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
279
+ rescue GemfileNotFound
280
+ nil
281
+ end
282
+ specs_matching_requirement = specs.select {| spec| requirement.matches_spec?(spec) }
283
+
284
+ if specs_matching_requirement.any?
285
+ specs = specs_matching_requirement
286
+ matching_part = requirement_label
287
+ requirement_label = "#{requirement_label} #{requirement.__platform}"
288
+ end
289
+
290
+ message = String.new("Could not find gem '#{requirement_label}'#{extra_message} in #{source}#{cache_message}.\n")
291
+
292
+ if specs.any?
293
+ message << "\nThe source contains the following gems matching '#{matching_part}':\n"
294
+ message << specs.map {|s| " * #{s.full_name}" }.join("\n")
296
295
  end
297
- version_platform_strs.join(", ")
296
+
297
+ message
298
298
  end
299
299
 
300
300
  def version_conflict_message(e)
@@ -359,27 +359,18 @@ module Bundler
359
359
  o << "\n"
360
360
  o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
361
361
  o << %(the gems in your Gemfile, which may resolve the conflict.\n)
362
- elsif !conflict.existing
362
+ elsif !conflict.existing && !name.end_with?("\0")
363
363
  o << "\n"
364
364
 
365
365
  relevant_source = conflict.requirement.source || source_for(name)
366
366
 
367
- metadata_requirement = name.end_with?("\0")
368
-
369
- o << "Could not find gem '" unless metadata_requirement
370
- o << SharedHelpers.pretty_dependency(conflict.requirement)
371
- o << "'" unless metadata_requirement
372
- if conflict.requirement_trees.first.size > 1
373
- o << ", which is required by "
374
- o << "gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
375
- end
376
- o << " "
377
-
378
- o << if metadata_requirement
379
- "is not available in #{relevant_source}"
367
+ extra_message = if conflict.requirement_trees.first.size > 1
368
+ ", which is required by gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
380
369
  else
381
- "in #{relevant_source}.\n"
370
+ ""
382
371
  end
372
+
373
+ o << gem_not_found_message(name, conflict.requirement, relevant_source, extra_message)
383
374
  end
384
375
  end,
385
376
  :version_for_spec => lambda {|spec| spec.version },
@@ -103,7 +103,7 @@ module Bundler
103
103
 
104
104
  def self.system
105
105
  ruby_engine = RUBY_ENGINE.dup
106
- ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
106
+ ruby_version = RUBY_VERSION.dup
107
107
  ruby_engine_version = RUBY_ENGINE_VERSION.dup
108
108
  patchlevel = RUBY_PATCHLEVEL.to_s
109
109
 
@@ -4,14 +4,12 @@ require "pathname"
4
4
 
5
5
  require "rubygems/specification"
6
6
 
7
- # Possible use in Gem::Specification#source below and require
8
- # shouldn't be deferred.
9
- require "rubygems/source"
10
-
11
7
  require_relative "match_platform"
12
8
 
13
9
  module Gem
14
10
  class Specification
11
+ include ::Bundler::MatchPlatform
12
+
15
13
  attr_accessor :remote, :location, :relative_loaded_from
16
14
 
17
15
  remove_method :source
@@ -81,10 +79,25 @@ module Gem
81
79
  gemfile
82
80
  end
83
81
 
82
+ # Backfill missing YAML require when not defined. Fixed since 3.1.0.pre1.
83
+ module YamlBackfiller
84
+ def to_yaml(opts = {})
85
+ Gem.load_yaml unless defined?(::YAML)
86
+
87
+ super(opts)
88
+ end
89
+ end
90
+
91
+ prepend YamlBackfiller
92
+
84
93
  def nondevelopment_dependencies
85
94
  dependencies - development_dependencies
86
95
  end
87
96
 
97
+ def deleted_gem?
98
+ !default_gem? && !File.directory?(full_gem_path)
99
+ end
100
+
88
101
  private
89
102
 
90
103
  def dependencies_to_gemfile(dependencies, group = nil)
@@ -134,6 +147,8 @@ module Gem
134
147
  class Requirement
135
148
  module OrderIndependentComparison
136
149
  def ==(other)
150
+ return unless Gem::Requirement === other
151
+
137
152
  if _requirements_sorted? && other._requirements_sorted?
138
153
  super
139
154
  else
@@ -222,9 +237,3 @@ module Gem
222
237
  end
223
238
  end
224
239
  end
225
-
226
- module Gem
227
- class Specification
228
- include ::Bundler::MatchPlatform
229
- end
230
- end
@@ -16,10 +16,12 @@ module Bundler
16
16
  spec.loaded_from = spec_file
17
17
 
18
18
  # Completely remove any previous gem files
19
- FileUtils.rm_rf gem_dir
20
- FileUtils.rm_rf spec.extension_dir
19
+ strict_rm_rf gem_dir
20
+ strict_rm_rf spec.extension_dir
21
21
 
22
- FileUtils.mkdir_p gem_dir, :mode => 0o755
22
+ SharedHelpers.filesystem_access(gem_dir, :create) do
23
+ FileUtils.mkdir_p gem_dir, :mode => 0o755
24
+ end
23
25
 
24
26
  extract_files
25
27
 
@@ -31,7 +33,10 @@ module Bundler
31
33
  generate_plugins
32
34
 
33
35
  write_spec
34
- write_cache_file
36
+
37
+ SharedHelpers.filesystem_access("#{gem_home}/cache", :write) do
38
+ write_cache_file
39
+ end
35
40
 
36
41
  say spec.post_install_message unless spec.post_install_message.nil?
37
42
 
@@ -61,7 +66,10 @@ module Bundler
61
66
 
62
67
  def build_extensions
63
68
  extension_cache_path = options[:bundler_extension_cache_path]
64
- return super unless extension_cache_path && extension_dir = spec.extension_dir
69
+ unless extension_cache_path && extension_dir = spec.extension_dir
70
+ require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
71
+ return super
72
+ end
65
73
 
66
74
  extension_dir = Pathname.new(extension_dir)
67
75
  build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
@@ -71,6 +79,7 @@ module Bundler
71
79
  FileUtils.cp_r extension_cache_path, spec.extension_dir
72
80
  end
73
81
  else
82
+ require "shellwords" # compensate missing require in rubygems before version 3.2.25
74
83
  super
75
84
  if extension_dir.directory? # not made for gems without extensions
76
85
  SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
@@ -83,6 +92,17 @@ module Bundler
83
92
 
84
93
  private
85
94
 
95
+ def strict_rm_rf(dir)
96
+ # FileUtils.rm_rf should probably rise in case of permission issues like
97
+ # `rm -rf` does. However, it fails to delete the folder silently due to
98
+ # https://github.com/ruby/fileutils/issues/57. It should probably be fixed
99
+ # inside `fileutils` but for now I`m checking whether the folder was
100
+ # removed after it completes, and raising otherwise.
101
+ FileUtils.rm_rf dir
102
+
103
+ raise PermissionError.new(dir, :delete) if File.directory?(dir)
104
+ end
105
+
86
106
  def validate_bundler_checksum(checksum)
87
107
  return true if Bundler.settings[:disable_checksum_validation]
88
108
  return true unless checksum
@@ -12,32 +12,30 @@ module Bundler
12
12
  EXT_LOCK = Monitor.new
13
13
  end
14
14
 
15
- def self.version
16
- @version ||= Gem::Version.new(Gem::VERSION)
17
- end
18
-
19
- def self.provides?(req_str)
20
- Gem::Requirement.new(req_str).satisfied_by?(version)
21
- end
22
-
23
15
  def initialize
24
16
  @replaced_methods = {}
25
17
  backport_ext_builder_monitor
26
18
  end
27
19
 
28
20
  def version
29
- self.class.version
21
+ @version ||= Gem.rubygems_version
30
22
  end
31
23
 
32
24
  def provides?(req_str)
33
- self.class.provides?(req_str)
25
+ Gem::Requirement.new(req_str).satisfied_by?(version)
26
+ end
27
+
28
+ def supports_bundler_trampolining?
29
+ provides?(">= 3.3.0.a")
34
30
  end
35
31
 
36
32
  def build_args
33
+ require "rubygems/command"
37
34
  Gem::Command.build_args
38
35
  end
39
36
 
40
37
  def build_args=(args)
38
+ require "rubygems/command"
41
39
  Gem::Command.build_args = args
42
40
  end
43
41
 
@@ -84,16 +82,12 @@ module Bundler
84
82
  def spec_missing_extensions?(spec, default = true)
85
83
  return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
86
84
 
87
- return false if spec_default_gem?(spec)
85
+ return false if spec.default_gem?
88
86
  return false if spec.extensions.empty?
89
87
 
90
88
  default
91
89
  end
92
90
 
93
- def spec_default_gem?(spec)
94
- spec.respond_to?(:default_gem?) && spec.default_gem?
95
- end
96
-
97
91
  def spec_matches_for_glob(spec, glob)
98
92
  return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
99
93
 
@@ -110,18 +104,6 @@ module Bundler
110
104
  obj.to_s
111
105
  end
112
106
 
113
- def configuration
114
- require_relative "psyched_yaml"
115
- Gem.configuration
116
- rescue Gem::SystemExitException, LoadError => e
117
- Bundler.ui.error "#{e.class}: #{e.message}"
118
- Bundler.ui.trace e
119
- raise
120
- rescue YamlLibrarySyntaxError => e
121
- raise YamlSyntaxError.new(e, "Your RubyGems configuration, which is " \
122
- "usually located in ~/.gemrc, contains invalid YAML syntax.")
123
- end
124
-
125
107
  def ruby_engine
126
108
  Gem.ruby_engine
127
109
  end
@@ -144,19 +126,6 @@ module Bundler
144
126
  end
145
127
  end
146
128
 
147
- def sources=(val)
148
- # Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
149
- # If that file exists, its settings (including sources) will overwrite the values we
150
- # are about to set here. In order to avoid that, we force memoizing the config file now.
151
- configuration
152
-
153
- Gem.sources = val
154
- end
155
-
156
- def sources
157
- Gem.sources
158
- end
159
-
160
129
  def gem_dir
161
130
  Gem.dir
162
131
  end
@@ -234,21 +203,9 @@ module Bundler
234
203
  EXT_LOCK
235
204
  end
236
205
 
237
- def with_build_args(args)
238
- ext_lock.synchronize do
239
- old_args = build_args
240
- begin
241
- self.build_args = args
242
- yield
243
- ensure
244
- self.build_args = old_args
245
- end
246
- end
247
- end
248
-
249
206
  def spec_from_gem(path, policy = nil)
250
207
  require "rubygems/security"
251
- require_relative "psyched_yaml"
208
+ require "psych"
252
209
  gem_from_path(path, security_policies[policy]).spec
253
210
  rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
254
211
  if e.is_a?(Gem::Security::Exception) ||
@@ -502,14 +459,15 @@ module Bundler
502
459
  end
503
460
 
504
461
  def fetch_specs(remote, name)
462
+ require "rubygems/remote_fetcher"
505
463
  path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
506
464
  fetcher = gem_remote_fetcher
507
465
  fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
508
466
  string = fetcher.fetch_path(path)
509
467
  Bundler.load_marshal(string)
510
- rescue Gem::RemoteFetcher::FetchError => e
468
+ rescue Gem::RemoteFetcher::FetchError
511
469
  # it's okay for prerelease to fail
512
- raise e unless name == "prerelease_specs"
470
+ raise unless name == "prerelease_specs"
513
471
  end
514
472
 
515
473
  def fetch_all_remote_specs(remote)
@@ -519,12 +477,32 @@ module Bundler
519
477
  specs.concat(pres)
520
478
  end
521
479
 
522
- def download_gem(spec, uri, path)
480
+ def download_gem(spec, uri, cache_dir)
481
+ require "rubygems/remote_fetcher"
523
482
  uri = Bundler.settings.mirror_for(uri)
524
483
  fetcher = gem_remote_fetcher
525
484
  fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
526
485
  Bundler::Retry.new("download gem from #{uri}").attempts do
527
- fetcher.download(spec, uri, path)
486
+ gem_file_name = spec.file_name
487
+ local_gem_path = File.join cache_dir, gem_file_name
488
+ return if File.exist? local_gem_path
489
+
490
+ begin
491
+ remote_gem_path = uri + "gems/#{gem_file_name}"
492
+ remote_gem_path = remote_gem_path.to_s if provides?("< 3.2.0.rc.1")
493
+
494
+ SharedHelpers.filesystem_access(local_gem_path) do
495
+ fetcher.cache_update_path remote_gem_path, local_gem_path
496
+ end
497
+ rescue Gem::RemoteFetcher::FetchError
498
+ raise if spec.original_platform == spec.platform
499
+
500
+ original_gem_file_name = "#{spec.original_name}.gem"
501
+ raise if gem_file_name == original_gem_file_name
502
+
503
+ gem_file_name = original_gem_file_name
504
+ retry
505
+ end
528
506
  end
529
507
  rescue Gem::RemoteFetcher::FetchError => e
530
508
  raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
@@ -532,7 +510,7 @@ module Bundler
532
510
 
533
511
  def gem_remote_fetcher
534
512
  require "rubygems/remote_fetcher"
535
- proxy = configuration[:http_proxy]
513
+ proxy = Gem.configuration[:http_proxy]
536
514
  Gem::RemoteFetcher.new(proxy)
537
515
  end
538
516
 
@@ -552,10 +530,6 @@ module Bundler
552
530
  Gem::REPOSITORY_SUBDIRECTORIES
553
531
  end
554
532
 
555
- def install_with_build_args(args)
556
- yield
557
- end
558
-
559
533
  def path_separator
560
534
  Gem.path_separator
561
535
  end
@@ -585,6 +559,10 @@ module Bundler
585
559
  end
586
560
  end
587
561
 
562
+ def find_bundler(version)
563
+ find_name("bundler").find {|s| s.version.to_s == version }
564
+ end
565
+
588
566
  def find_name(name)
589
567
  Gem::Specification.stubs_for(name).map(&:to_spec)
590
568
  end
@@ -598,14 +576,6 @@ module Bundler
598
576
  Gem::Specification.send(:default_stubs, "*.gemspec")
599
577
  end
600
578
  end
601
-
602
- def use_gemdeps(gemfile)
603
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
604
- require_relative "gemdeps"
605
- runtime = Bundler.setup
606
- activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
607
- [Gemdeps.new(runtime), activated_spec_names]
608
- end
609
579
  end
610
580
 
611
581
  def self.rubygems
@@ -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)
@@ -256,7 +265,7 @@ module Bundler
256
265
 
257
266
  return if manuals.empty?
258
267
  Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
259
- ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
268
+ ENV["MANPATH"] ? ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) : [""]
260
269
  ).uniq.join(File::PATH_SEPARATOR)
261
270
  end
262
271
 
@@ -282,7 +291,7 @@ module Bundler
282
291
  return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
283
292
  return if activated_spec.version == spec.version
284
293
 
285
- suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
294
+ suggestion = if activated_spec.default_gem?
286
295
  "Since #{spec.name} is a default gem, you can either remove your dependency on it" \
287
296
  " or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
288
297
  else