bundler 2.2.26 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +166 -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/check.rb +1 -1
  8. data/lib/bundler/cli/doctor.rb +3 -2
  9. data/lib/bundler/cli/gem.rb +88 -9
  10. data/lib/bundler/cli/info.rb +16 -4
  11. data/lib/bundler/cli/install.rb +2 -3
  12. data/lib/bundler/cli/issue.rb +4 -3
  13. data/lib/bundler/cli/remove.rb +1 -2
  14. data/lib/bundler/cli/update.rb +2 -2
  15. data/lib/bundler/cli.rb +10 -1
  16. data/lib/bundler/compact_index_client/updater.rb +0 -5
  17. data/lib/bundler/compact_index_client.rb +2 -2
  18. data/lib/bundler/definition.rb +77 -124
  19. data/lib/bundler/dependency.rb +5 -7
  20. data/lib/bundler/digest.rb +71 -0
  21. data/lib/bundler/dsl.rb +18 -30
  22. data/lib/bundler/endpoint_specification.rb +0 -8
  23. data/lib/bundler/environment_preserver.rb +4 -1
  24. data/lib/bundler/errors.rb +18 -2
  25. data/lib/bundler/fetcher/compact_index.rb +9 -4
  26. data/lib/bundler/fetcher.rb +4 -6
  27. data/lib/bundler/friendly_errors.rb +5 -30
  28. data/lib/bundler/gem_helper.rb +6 -17
  29. data/lib/bundler/injector.rb +10 -1
  30. data/lib/bundler/installer/gem_installer.rb +1 -6
  31. data/lib/bundler/installer.rb +1 -5
  32. data/lib/bundler/lazy_specification.rb +17 -1
  33. data/lib/bundler/lockfile_parser.rb +10 -12
  34. data/lib/bundler/man/bundle-add.1 +10 -2
  35. data/lib/bundler/man/bundle-add.1.ronn +7 -1
  36. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  37. data/lib/bundler/man/bundle-cache.1 +1 -1
  38. data/lib/bundler/man/bundle-check.1 +1 -1
  39. data/lib/bundler/man/bundle-clean.1 +1 -1
  40. data/lib/bundler/man/bundle-config.1 +5 -5
  41. data/lib/bundler/man/bundle-config.1.ronn +5 -5
  42. data/lib/bundler/man/bundle-doctor.1 +1 -1
  43. data/lib/bundler/man/bundle-exec.1 +1 -1
  44. data/lib/bundler/man/bundle-gem.1 +14 -1
  45. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  46. data/lib/bundler/man/bundle-info.1 +1 -1
  47. data/lib/bundler/man/bundle-init.1 +1 -1
  48. data/lib/bundler/man/bundle-inject.1 +1 -1
  49. data/lib/bundler/man/bundle-install.1 +2 -2
  50. data/lib/bundler/man/bundle-install.1.ronn +2 -2
  51. data/lib/bundler/man/bundle-list.1 +1 -1
  52. data/lib/bundler/man/bundle-lock.1 +1 -1
  53. data/lib/bundler/man/bundle-open.1 +1 -1
  54. data/lib/bundler/man/bundle-outdated.1 +1 -1
  55. data/lib/bundler/man/bundle-platform.1 +1 -1
  56. data/lib/bundler/man/bundle-pristine.1 +1 -1
  57. data/lib/bundler/man/bundle-remove.1 +1 -1
  58. data/lib/bundler/man/bundle-show.1 +1 -1
  59. data/lib/bundler/man/bundle-update.1 +2 -2
  60. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  61. data/lib/bundler/man/bundle-viz.1 +1 -1
  62. data/lib/bundler/man/bundle.1 +1 -1
  63. data/lib/bundler/man/gemfile.5 +28 -2
  64. data/lib/bundler/man/gemfile.5.ronn +9 -1
  65. data/lib/bundler/plugin/api/source.rb +1 -0
  66. data/lib/bundler/plugin/installer.rb +3 -1
  67. data/lib/bundler/plugin.rb +23 -6
  68. data/lib/bundler/process_lock.rb +1 -1
  69. data/lib/bundler/psyched_yaml.rb +1 -13
  70. data/lib/bundler/resolver.rb +34 -31
  71. data/lib/bundler/ruby_version.rb +1 -1
  72. data/lib/bundler/rubygems_ext.rb +6 -0
  73. data/lib/bundler/rubygems_gem_installer.rb +21 -5
  74. data/lib/bundler/rubygems_integration.rb +39 -57
  75. data/lib/bundler/runtime.rb +2 -2
  76. data/lib/bundler/self_manager.rb +94 -0
  77. data/lib/bundler/settings.rb +10 -1
  78. data/lib/bundler/shared_helpers.rb +4 -12
  79. data/lib/bundler/source/git/git_proxy.rb +7 -4
  80. data/lib/bundler/source/git.rb +22 -4
  81. data/lib/bundler/source/metadata.rb +1 -1
  82. data/lib/bundler/source/rubygems.rb +60 -85
  83. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  84. data/lib/bundler/source.rb +3 -1
  85. data/lib/bundler/source_list.rb +11 -29
  86. data/lib/bundler/spec_set.rb +2 -2
  87. data/lib/bundler/templates/Executable.bundler +1 -1
  88. data/lib/bundler/templates/Gemfile +0 -2
  89. data/lib/bundler/templates/gems.rb +0 -3
  90. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  91. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  92. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +4 -3
  93. data/lib/bundler/templates/newgem/newgem.gemspec.tt +14 -14
  94. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  95. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  96. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  97. data/lib/bundler/ui/shell.rb +1 -1
  98. data/lib/bundler/vendor/.document +1 -0
  99. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  101. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  102. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  103. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  104. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  105. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  107. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  108. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  109. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  110. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +5 -3
  111. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  112. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  113. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  114. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  115. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  116. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  117. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  118. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  119. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  120. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  121. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  122. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  123. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  124. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  125. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  126. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  127. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  128. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  129. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  130. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  131. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  132. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  133. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  134. data/lib/bundler/vendored_tsort.rb +4 -0
  135. data/lib/bundler/version.rb +1 -1
  136. data/lib/bundler/worker.rb +2 -2
  137. data/lib/bundler.rb +22 -21
  138. metadata +25 -9
  139. data/lib/bundler/gemdeps.rb +0 -29
  140. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ #
5
+ # This class handles installing and switching to the version of bundler needed
6
+ # by an application.
7
+ #
8
+ class SelfManager
9
+ def restart_with_locked_bundler_if_needed
10
+ return unless needs_switching? && installed?
11
+
12
+ restart_with_locked_bundler
13
+ end
14
+
15
+ def install_locked_bundler_and_restart_with_it_if_needed
16
+ return unless needs_switching?
17
+
18
+ install_and_restart_with_locked_bundler
19
+ end
20
+
21
+ private
22
+
23
+ def install_and_restart_with_locked_bundler
24
+ bundler_dep = Gem::Dependency.new("bundler", lockfile_version)
25
+ spec = fetch_spec_for(bundler_dep)
26
+ return if spec.nil?
27
+
28
+ Bundler.ui.info \
29
+ "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
30
+ "Installing Bundler #{lockfile_version} and restarting using that version."
31
+
32
+ spec.source.install(spec)
33
+ rescue StandardError => e
34
+ Bundler.ui.trace e
35
+ Bundler.ui.warn "There was an error installing the locked bundler version (#{lockfile_version}), rerun with the `--verbose` flag for more details. Going on using bundler #{current_version}."
36
+ else
37
+ restart_with_locked_bundler
38
+ end
39
+
40
+ def fetch_spec_for(bundler_dep)
41
+ source = Bundler::Source::Rubygems.new("remotes" => "https://rubygems.org")
42
+ source.remote!
43
+ source.add_dependency_names("bundler")
44
+ spec = source.specs.search(bundler_dep).first
45
+ if spec.nil?
46
+ Bundler.ui.warn "Your lockfile is locked to a version of bundler (#{lockfile_version}) that doesn't exist at https://rubygems.org/. Going on using #{current_version}"
47
+ end
48
+ spec
49
+ end
50
+
51
+ def restart_with_locked_bundler
52
+ configured_gem_home = ENV["GEM_HOME"]
53
+ configured_gem_path = ENV["GEM_PATH"]
54
+
55
+ cmd = [$PROGRAM_NAME, *ARGV]
56
+ cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
57
+
58
+ Bundler.with_original_env do
59
+ Kernel.exec(
60
+ { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => lockfile_version },
61
+ *cmd
62
+ )
63
+ end
64
+ end
65
+
66
+ def needs_switching?
67
+ ENV["BUNDLER_VERSION"].nil? &&
68
+ Bundler.rubygems.supports_bundler_trampolining? &&
69
+ SharedHelpers.in_bundle? &&
70
+ lockfile_version &&
71
+ !lockfile_version.end_with?(".dev") &&
72
+ lockfile_version != current_version &&
73
+ !updating?
74
+ end
75
+
76
+ def updating?
77
+ "update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
78
+ end
79
+
80
+ def installed?
81
+ Bundler.configure
82
+
83
+ Bundler.rubygems.find_bundler(lockfile_version)
84
+ end
85
+
86
+ def current_version
87
+ @current_version ||= Bundler::VERSION
88
+ end
89
+
90
+ def lockfile_version
91
+ @lockfile_version ||= Bundler::LockfileParser.bundled_with
92
+ end
93
+ end
94
+ end
@@ -219,6 +219,7 @@ module Bundler
219
219
  def path
220
220
  configs.each do |_level, settings|
221
221
  path = value_for("path", settings)
222
+ path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
222
223
  path_system = value_for("path.system", settings)
223
224
  disabled_shared_gems = value_for("disable_shared_gems", settings)
224
225
  next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
@@ -419,7 +420,15 @@ module Bundler
419
420
  elsif is_credential(key)
420
421
  "[REDACTED]"
421
422
  elsif is_userinfo(converted)
422
- converted.gsub(/:.*$/, ":[REDACTED]")
423
+ username, pass = converted.split(":", 2)
424
+
425
+ if pass == "x-oauth-basic"
426
+ username = "[REDACTED]"
427
+ else
428
+ pass = "[REDACTED]"
429
+ end
430
+
431
+ [username, pass].join(":")
423
432
  else
424
433
  converted
425
434
  end
@@ -109,7 +109,7 @@ module Bundler
109
109
  raise VirtualProtocolError.new
110
110
  rescue Errno::ENOSPC
111
111
  raise NoSpaceOnDeviceError.new(path, action)
112
- rescue *[const_get_safely(:ENOTSUP, Errno)].compact
112
+ rescue Errno::ENOTSUP
113
113
  raise OperationNotSupportedError.new(path, action)
114
114
  rescue Errno::EEXIST, Errno::ENOENT
115
115
  raise
@@ -117,13 +117,6 @@ module Bundler
117
117
  raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
118
118
  end
119
119
 
120
- def const_get_safely(constant_name, namespace)
121
- const_in_namespace = namespace.constants.include?(constant_name.to_s) ||
122
- namespace.constants.include?(constant_name.to_sym)
123
- return nil unless const_in_namespace
124
- namespace.const_get(constant_name)
125
- end
126
-
127
120
  def major_deprecation(major_version, message, print_caller_location: false)
128
121
  if print_caller_location
129
122
  caller_location = caller_locations(2, 2).first
@@ -246,7 +239,7 @@ module Bundler
246
239
  current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
247
240
 
248
241
  until !File.directory?(current) || current == previous
249
- if ENV["BUNDLE_SPEC_RUN"]
242
+ if ENV["BUNDLER_SPEC_RUN"]
250
243
  # avoid stepping above the tmp directory when testing
251
244
  gemspec = if ENV["GEM_COMMAND"]
252
245
  # for Ruby Core
@@ -320,12 +313,11 @@ module Bundler
320
313
  end
321
314
 
322
315
  def clean_load_path
323
- bundler_lib = bundler_ruby_lib
324
-
325
316
  loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
326
317
 
327
318
  $LOAD_PATH.reject! do |p|
328
- next if resolve_path(p).start_with?(bundler_lib)
319
+ resolved_path = resolve_path(p)
320
+ next if $LOADED_FEATURES.any? {|lf| lf.start_with?(resolved_path) }
329
321
  loaded_gem_paths.delete(p)
330
322
  end
331
323
  $LOAD_PATH.uniq!
@@ -56,7 +56,6 @@ module Bundler
56
56
  @ref = ref
57
57
  @revision = revision
58
58
  @git = git
59
- raise GitNotInstalledError.new if allow? && !Bundler.git_present?
60
59
  end
61
60
 
62
61
  def revision
@@ -96,12 +95,12 @@ module Bundler
96
95
  SharedHelpers.filesystem_access(path.dirname) do |p|
97
96
  FileUtils.mkdir_p(p)
98
97
  end
99
- git_retry "clone", configured_uri, path.to_s, "--bare", "--no-hardlinks", "--quiet"
98
+ git_retry "clone", "--bare", "--no-hardlinks", "--quiet", "--", configured_uri, path.to_s
100
99
  return unless extra_ref
101
100
  end
102
101
 
103
102
  with_path do
104
- git_retry(*["fetch", "--force", "--quiet", "--tags", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
103
+ git_retry(*["fetch", "--force", "--quiet", "--tags", "--", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
105
104
  end
106
105
  end
107
106
 
@@ -208,7 +207,11 @@ module Bundler
208
207
  end
209
208
 
210
209
  def allow?
211
- @git ? @git.allow_git_ops? : true
210
+ allowed = @git ? @git.allow_git_ops? : true
211
+
212
+ raise GitNotInstalledError.new if allowed && !Bundler.git_present?
213
+
214
+ allowed
212
215
  end
213
216
 
214
217
  def with_path(&blk)
@@ -42,7 +42,7 @@ module Bundler
42
42
  %w[ref branch tag submodules].each do |opt|
43
43
  out << " #{opt}: #{options[opt]}\n" if options[opt]
44
44
  end
45
- out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
45
+ out << " glob: #{@glob}\n" unless default_glob?
46
46
  out << " specs:\n"
47
47
  end
48
48
 
@@ -75,12 +75,20 @@ module Bundler
75
75
  git_proxy.branch
76
76
  end
77
77
 
78
- rev = " (at #{at}@#{shortref_for_display(revision)})"
78
+ rev = "at #{at}@#{shortref_for_display(revision)}"
79
79
  rescue GitError
80
80
  ""
81
81
  end
82
82
 
83
- "#{@safe_uri}#{rev}"
83
+ specifiers = [rev, glob_for_display].compact
84
+ suffix =
85
+ if specifiers.any?
86
+ " (#{specifiers.join(", ")})"
87
+ else
88
+ ""
89
+ end
90
+
91
+ "#{@safe_uri}#{suffix}"
84
92
  end
85
93
 
86
94
  def name
@@ -282,6 +290,14 @@ module Bundler
282
290
  ref[0..11]
283
291
  end
284
292
 
293
+ def glob_for_display
294
+ default_glob? ? nil : "glob: #{@glob}"
295
+ end
296
+
297
+ def default_glob?
298
+ @glob == DEFAULT_GLOB
299
+ end
300
+
285
301
  def uri_hash
286
302
  if uri =~ %r{^\w+://(\w+@)?}
287
303
  # Downcase the domain component of the URI
@@ -291,7 +307,9 @@ module Bundler
291
307
  # If there is no URI scheme, assume it is an ssh/git URI
292
308
  input = uri
293
309
  end
294
- SharedHelpers.digest(:SHA1).hexdigest(input)
310
+ # We use SHA1 here for historical reason and to preserve backward compatibility.
311
+ # But a transition to a simpler mangling algorithm would be welcome.
312
+ Bundler::Digest.sha1(input)
295
313
  end
296
314
 
297
315
  def cached_revision
@@ -25,7 +25,7 @@ module Bundler
25
25
  s.loaded_from = File.expand_path("..", __FILE__)
26
26
  end
27
27
 
28
- if local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
28
+ if local_spec = Bundler.rubygems.find_bundler(VERSION)
29
29
  idx << local_spec
30
30
  end
31
31
 
@@ -26,6 +26,13 @@ module Bundler
26
26
  Array(options["remotes"]).reverse_each {|r| add_remote(r) }
27
27
  end
28
28
 
29
+ def local_only!
30
+ @specs = nil
31
+ @allow_local = true
32
+ @allow_cached = false
33
+ @allow_remote = false
34
+ end
35
+
29
36
  def local!
30
37
  return if @allow_local
31
38
 
@@ -91,26 +98,30 @@ module Bundler
91
98
  out << " specs:\n"
92
99
  end
93
100
 
94
- def to_err
101
+ def to_s
95
102
  if remotes.empty?
96
103
  "locally installed gems"
97
- elsif @allow_remote
104
+ elsif @allow_remote && @allow_cached && @allow_local
105
+ "rubygems repository #{remote_names}, cached gems or installed locally"
106
+ elsif @allow_remote && @allow_local
98
107
  "rubygems repository #{remote_names} or installed locally"
99
- elsif @allow_cached
100
- "cached gems from rubygems repository #{remote_names} or installed locally"
108
+ elsif @allow_remote
109
+ "rubygems repository #{remote_names}"
110
+ elsif @allow_cached && @allow_local
111
+ "cached gems or installed locally"
101
112
  else
102
113
  "locally installed gems"
103
114
  end
104
115
  end
105
116
 
106
- def to_s
117
+ def identifier
107
118
  if remotes.empty?
108
119
  "locally installed gems"
109
120
  else
110
- "rubygems repository #{remote_names} or installed locally"
121
+ "rubygems repository #{remote_names}"
111
122
  end
112
123
  end
113
- alias_method :name, :to_s
124
+ alias_method :name, :identifier
114
125
 
115
126
  def specs
116
127
  @specs ||= begin
@@ -128,7 +139,7 @@ module Bundler
128
139
  force = opts[:force]
129
140
  ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached]
130
141
 
131
- if ensure_builtin_gems_cached && builtin_gem?(spec)
142
+ if ensure_builtin_gems_cached && spec.default_gem?
132
143
  if !cached_path(spec)
133
144
  cached_built_in_gem(spec) unless spec.remote
134
145
  force = true
@@ -137,7 +148,7 @@ module Bundler
137
148
  end
138
149
  end
139
150
 
140
- if (installed?(spec) || Plugin.installed?(spec.name)) && !force
151
+ if installed?(spec) && !force
141
152
  print_using_message "Using #{version_message(spec)}"
142
153
  return nil # no post-install message
143
154
  end
@@ -155,7 +166,7 @@ module Bundler
155
166
  begin
156
167
  s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
157
168
  spec.__swap__(s)
158
- rescue StandardError
169
+ rescue Gem::Package::FormatError
159
170
  Bundler.rm_rf(path)
160
171
  raise
161
172
  end
@@ -167,6 +178,7 @@ module Bundler
167
178
  Bundler.ui.confirm message
168
179
 
169
180
  path = cached_gem(spec)
181
+ raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
170
182
  if requires_sudo?
171
183
  install_path = Bundler.tmp(spec.full_name)
172
184
  bin_path = install_path.join("bin")
@@ -226,12 +238,8 @@ module Bundler
226
238
  end
227
239
 
228
240
  def cache(spec, custom_path = nil)
229
- if builtin_gem?(spec)
230
- cached_path = cached_built_in_gem(spec)
231
- else
232
- cached_path = cached_gem(spec)
233
- end
234
- raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
241
+ cached_path = cached_gem(spec)
242
+ raise GemNotFound, "Missing gem file '#{spec.file_name}'." unless cached_path
235
243
  return if File.dirname(cached_path) == Bundler.app_cache.to_s
236
244
  Bundler.ui.info " * #{File.basename(cached_path)}"
237
245
  FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
@@ -258,10 +266,6 @@ module Bundler
258
266
  @remotes.unshift(uri) unless @remotes.include?(uri)
259
267
  end
260
268
 
261
- def equivalent_remotes?(other_remotes)
262
- other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
263
- end
264
-
265
269
  def spec_names
266
270
  if @allow_remote && dependency_api_available?
267
271
  remote_specs.spec_names
@@ -330,7 +334,11 @@ module Bundler
330
334
  end
331
335
 
332
336
  def credless_remotes
333
- remotes.map(&method(:suppress_configured_credentials))
337
+ if Bundler.settings[:allow_deployment_source_credential_changes]
338
+ remotes.map(&method(:remove_auth))
339
+ else
340
+ remotes.map(&method(:suppress_configured_credentials))
341
+ end
334
342
  end
335
343
 
336
344
  def remotes_for_spec(spec)
@@ -345,14 +353,17 @@ module Bundler
345
353
  end
346
354
 
347
355
  def cached_gem(spec)
348
- cached_gem = cached_path(spec)
349
- unless cached_gem
350
- raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation"
356
+ if spec.default_gem?
357
+ cached_built_in_gem(spec)
358
+ else
359
+ cached_path(spec)
351
360
  end
352
- cached_gem
353
361
  end
354
362
 
355
363
  def cached_path(spec)
364
+ global_cache_path = download_cache_path(spec)
365
+ @caches << global_cache_path if global_cache_path
366
+
356
367
  possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
357
368
  possibilities.find {|p| File.exist?(p) }
358
369
  end
@@ -452,19 +463,26 @@ module Bundler
452
463
 
453
464
  spec.fetch_platform
454
465
 
455
- download_path = requires_sudo? ? Bundler.tmp(spec.full_name) : rubygems_dir
456
- gem_path = "#{rubygems_dir}/cache/#{spec.full_name}.gem"
466
+ cache_path = download_cache_path(spec) || default_cache_path_for(rubygems_dir)
467
+ gem_path = "#{cache_path}/#{spec.file_name}"
468
+
469
+ if requires_sudo?
470
+ download_path = Bundler.tmp(spec.full_name)
471
+ download_cache_path = default_cache_path_for(download_path)
472
+ else
473
+ download_cache_path = cache_path
474
+ end
457
475
 
458
- SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
476
+ SharedHelpers.filesystem_access(download_cache_path) do |p|
459
477
  FileUtils.mkdir_p(p)
460
478
  end
461
- download_gem(spec, download_path)
479
+ download_gem(spec, download_cache_path)
462
480
 
463
481
  if requires_sudo?
464
- SharedHelpers.filesystem_access("#{rubygems_dir}/cache") do |p|
482
+ SharedHelpers.filesystem_access(cache_path) do |p|
465
483
  Bundler.mkdir_p(p)
466
484
  end
467
- Bundler.sudo "mv #{download_path}/cache/#{spec.full_name}.gem #{gem_path}"
485
+ Bundler.sudo "mv #{download_cache_path}/#{spec.file_name} #{gem_path}"
468
486
  end
469
487
 
470
488
  gem_path
@@ -472,16 +490,8 @@ module Bundler
472
490
  Bundler.rm_rf(download_path) if requires_sudo?
473
491
  end
474
492
 
475
- def builtin_gem?(spec)
476
- # Ruby 2.1, where all included gems have this summary
477
- return true if spec.summary =~ /is bundled with Ruby/
478
-
479
- # Ruby 2.0, where gemspecs are stored in specifications/default/
480
- spec.loaded_from && spec.loaded_from.include?("specifications/default/")
481
- end
482
-
483
493
  def installed?(spec)
484
- installed_specs[spec].any?
494
+ installed_specs[spec].any? && !spec.deleted_gem?
485
495
  end
486
496
 
487
497
  def requires_sudo?
@@ -492,6 +502,10 @@ module Bundler
492
502
  Bundler.rubygems.gem_dir
493
503
  end
494
504
 
505
+ def default_cache_path_for(dir)
506
+ "#{dir}/cache"
507
+ end
508
+
495
509
  def cache_path
496
510
  Bundler.app_cache
497
511
  end
@@ -504,52 +518,13 @@ module Bundler
504
518
  # @param [Specification] spec
505
519
  # the spec we want to download or retrieve from the cache.
506
520
  #
507
- # @param [String] download_path
521
+ # @param [String] download_cache_path
508
522
  # the local directory the .gem will end up in.
509
523
  #
510
- def download_gem(spec, download_path)
511
- local_path = File.join(download_path, "cache/#{spec.full_name}.gem")
512
-
513
- if (cache_path = download_cache_path(spec)) && cache_path.file?
514
- SharedHelpers.filesystem_access(local_path) do
515
- FileUtils.cp(cache_path, local_path)
516
- end
517
- else
518
- uri = spec.remote.uri
519
- Bundler.ui.confirm("Fetching #{version_message(spec)}")
520
- rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path)
521
-
522
- # older rubygems return varying file:// variants depending on version
523
- rubygems_local_path = rubygems_local_path.gsub(/\Afile:/, "") unless Bundler.rubygems.provides?(">= 3.2.0.rc.2")
524
- rubygems_local_path = rubygems_local_path.gsub(%r{\A//}, "") if Bundler.rubygems.provides?("< 3.1.0")
525
-
526
- if rubygems_local_path != local_path
527
- SharedHelpers.filesystem_access(local_path) do
528
- FileUtils.mv(rubygems_local_path, local_path)
529
- end
530
- end
531
- cache_globally(spec, local_path)
532
- end
533
- end
534
-
535
- # Checks if the requested spec exists in the global cache. If it does
536
- # not, we create the relevant global cache subdirectory if it does not
537
- # exist and copy the spec from the local cache to the global cache.
538
- #
539
- # @param [Specification] spec
540
- # the spec we want to copy to the global cache.
541
- #
542
- # @param [String] local_cache_path
543
- # the local directory from which we want to copy the .gem.
544
- #
545
- def cache_globally(spec, local_cache_path)
546
- return unless cache_path = download_cache_path(spec)
547
- return if cache_path.exist?
548
-
549
- SharedHelpers.filesystem_access(cache_path.dirname, &:mkpath)
550
- SharedHelpers.filesystem_access(cache_path) do
551
- FileUtils.cp(local_cache_path, cache_path)
552
- end
524
+ def download_gem(spec, download_cache_path)
525
+ uri = spec.remote.uri
526
+ Bundler.ui.confirm("Fetching #{version_message(spec)}")
527
+ Bundler.rubygems.download_gem(spec, uri, download_cache_path)
553
528
  end
554
529
 
555
530
  # Returns the global cache path of the calling Rubygems::Source object.
@@ -568,7 +543,7 @@ module Bundler
568
543
  return unless remote = spec.remote
569
544
  return unless cache_slug = remote.cache_slug
570
545
 
571
- Bundler.user_cache.join("gems", cache_slug, spec.file_name)
546
+ Bundler.user_cache.join("gems", cache_slug)
572
547
  end
573
548
 
574
549
  def extension_cache_slug(spec)
@@ -16,7 +16,7 @@ module Bundler
16
16
  @index
17
17
  end
18
18
 
19
- def to_err
19
+ def identifier
20
20
  to_s
21
21
  end
22
22
 
@@ -36,6 +36,8 @@ module Bundler
36
36
 
37
37
  def local!; end
38
38
 
39
+ def local_only!; end
40
+
39
41
  def cached!; end
40
42
 
41
43
  def remote!; end
@@ -65,7 +67,7 @@ module Bundler
65
67
  "#<#{self.class}:0x#{object_id} #{self}>"
66
68
  end
67
69
 
68
- def to_err
70
+ def identifier
69
71
  to_s
70
72
  end
71
73
 
@@ -98,7 +98,7 @@ module Bundler
98
98
  end
99
99
 
100
100
  def get(source)
101
- source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
101
+ source_list_for(source).find {|s| equivalent_source?(source, s) }
102
102
  end
103
103
 
104
104
  def lock_sources
@@ -106,14 +106,14 @@ module Bundler
106
106
  end
107
107
 
108
108
  def lock_other_sources
109
- (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
109
+ (path_sources + git_sources + plugin_sources).sort_by(&:identifier)
110
110
  end
111
111
 
112
112
  def lock_rubygems_sources
113
113
  if merged_gem_lockfile_sections?
114
114
  [combine_rubygems_sources]
115
115
  else
116
- rubygems_sources.sort_by(&:to_s)
116
+ rubygems_sources.sort_by(&:identifier)
117
117
  end
118
118
  end
119
119
 
@@ -136,6 +136,10 @@ module Bundler
136
136
  different_sources?(lock_sources, replacement_sources)
137
137
  end
138
138
 
139
+ def local_only!
140
+ all_sources.each(&:local_only!)
141
+ end
142
+
139
143
  def cached!
140
144
  all_sources.each(&:cached!)
141
145
  end
@@ -169,7 +173,7 @@ module Bundler
169
173
  end
170
174
 
171
175
  def different_sources?(lock_sources, replacement_sources)
172
- !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
176
+ !equivalent_sources?(lock_sources, replacement_sources)
173
177
  end
174
178
 
175
179
  def rubygems_aggregate_class
@@ -206,34 +210,12 @@ module Bundler
206
210
  end
207
211
  end
208
212
 
209
- def equal_sources?(lock_sources, replacement_sources)
210
- lock_sources.sort_by(&:to_s) == replacement_sources.sort_by(&:to_s)
211
- end
212
-
213
- def equal_source?(source, other_source)
214
- return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems)
215
-
216
- source == other_source
217
- end
218
-
219
- def equivalent_source?(source, other_source)
220
- return false unless Bundler.settings[:allow_deployment_source_credential_changes] && source.is_a?(Source::Rubygems)
221
-
222
- equivalent_rubygems_sources?([source], [other_source])
223
- end
224
-
225
213
  def equivalent_sources?(lock_sources, replacement_sources)
226
- return false unless Bundler.settings[:allow_deployment_source_credential_changes]
227
-
228
- lock_rubygems_sources, lock_other_sources = lock_sources.partition {|s| s.is_a?(Source::Rubygems) }
229
- replacement_rubygems_sources, replacement_other_sources = replacement_sources.partition {|s| s.is_a?(Source::Rubygems) }
230
-
231
- equivalent_rubygems_sources?(lock_rubygems_sources, replacement_rubygems_sources) && equal_sources?(lock_other_sources, replacement_other_sources)
214
+ lock_sources.sort_by(&:identifier) == replacement_sources.sort_by(&:identifier)
232
215
  end
233
216
 
234
- def equivalent_rubygems_sources?(lock_sources, replacement_sources)
235
- actual_remotes = replacement_sources.map(&:remotes).flatten.uniq
236
- lock_sources.all? {|s| s.equivalent_remotes?(actual_remotes) }
217
+ def equivalent_source?(source, other_source)
218
+ source == other_source
237
219
  end
238
220
  end
239
221
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "tsort"
3
+ require_relative "vendored_tsort"
4
4
 
5
5
  module Bundler
6
6
  class SpecSet
@@ -24,7 +24,7 @@ module Bundler
24
24
 
25
25
  specs_for_dep = spec_for_dependency(dep, match_current_platform)
26
26
  if specs_for_dep.any?
27
- specs += specs_for_dep
27
+ match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep
28
28
 
29
29
  specs_for_dep.first.dependencies.each do |d|
30
30
  next if d.type == :development
@@ -73,7 +73,7 @@ m = Module.new do
73
73
 
74
74
  requirement = bundler_gem_version.approximate_recommendation
75
75
 
76
- return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
76
+ return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
77
77
 
78
78
  requirement += ".a" if bundler_gem_version.prerelease?
79
79