bundler 2.2.26 → 2.3.26

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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +501 -1
  3. data/README.md +1 -1
  4. data/bundler.gemspec +6 -8
  5. data/exe/bundle +7 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/cli/check.rb +1 -1
  10. data/lib/bundler/cli/common.rb +3 -2
  11. data/lib/bundler/cli/config.rb +10 -1
  12. data/lib/bundler/cli/doctor.rb +12 -3
  13. data/lib/bundler/cli/gem.rb +98 -9
  14. data/lib/bundler/cli/info.rb +27 -6
  15. data/lib/bundler/cli/init.rb +5 -1
  16. data/lib/bundler/cli/install.rb +13 -30
  17. data/lib/bundler/cli/issue.rb +4 -3
  18. data/lib/bundler/cli/outdated.rb +12 -3
  19. data/lib/bundler/cli/platform.rb +2 -2
  20. data/lib/bundler/cli/remove.rb +1 -2
  21. data/lib/bundler/cli/show.rb +1 -1
  22. data/lib/bundler/cli/update.rb +8 -4
  23. data/lib/bundler/cli.rb +23 -19
  24. data/lib/bundler/compact_index_client/cache.rb +0 -9
  25. data/lib/bundler/compact_index_client/updater.rb +16 -8
  26. data/lib/bundler/compact_index_client.rb +2 -8
  27. data/lib/bundler/current_ruby.rb +16 -6
  28. data/lib/bundler/definition.rb +204 -217
  29. data/lib/bundler/dependency.rb +23 -71
  30. data/lib/bundler/digest.rb +71 -0
  31. data/lib/bundler/dsl.rb +28 -45
  32. data/lib/bundler/endpoint_specification.rb +19 -13
  33. data/lib/bundler/env.rb +1 -1
  34. data/lib/bundler/environment_preserver.rb +4 -1
  35. data/lib/bundler/errors.rb +28 -2
  36. data/lib/bundler/feature_flag.rb +0 -1
  37. data/lib/bundler/fetcher/base.rb +6 -8
  38. data/lib/bundler/fetcher/compact_index.rb +9 -14
  39. data/lib/bundler/fetcher/index.rb +0 -26
  40. data/lib/bundler/fetcher.rb +20 -22
  41. data/lib/bundler/friendly_errors.rb +26 -34
  42. data/lib/bundler/gem_helper.rb +7 -18
  43. data/lib/bundler/gem_helpers.rb +9 -2
  44. data/lib/bundler/gem_version_promoter.rb +14 -25
  45. data/lib/bundler/index.rb +10 -40
  46. data/lib/bundler/injector.rb +16 -2
  47. data/lib/bundler/inline.rb +2 -12
  48. data/lib/bundler/installer/gem_installer.rb +13 -5
  49. data/lib/bundler/installer/standalone.rb +30 -3
  50. data/lib/bundler/installer.rb +18 -29
  51. data/lib/bundler/lazy_specification.rb +52 -35
  52. data/lib/bundler/lockfile_generator.rb +2 -2
  53. data/lib/bundler/lockfile_parser.rb +12 -10
  54. data/lib/bundler/man/bundle-add.1 +21 -5
  55. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  56. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  57. data/lib/bundler/man/bundle-cache.1 +7 -1
  58. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  59. data/lib/bundler/man/bundle-check.1 +1 -1
  60. data/lib/bundler/man/bundle-clean.1 +2 -2
  61. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  62. data/lib/bundler/man/bundle-config.1 +33 -14
  63. data/lib/bundler/man/bundle-config.1.ronn +30 -18
  64. data/lib/bundler/man/bundle-console.1 +53 -0
  65. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  66. data/lib/bundler/man/bundle-doctor.1 +1 -1
  67. data/lib/bundler/man/bundle-exec.1 +2 -2
  68. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  69. data/lib/bundler/man/bundle-gem.1 +14 -1
  70. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  71. data/lib/bundler/man/bundle-help.1 +13 -0
  72. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  73. data/lib/bundler/man/bundle-info.1 +1 -1
  74. data/lib/bundler/man/bundle-init.1 +1 -1
  75. data/lib/bundler/man/bundle-inject.1 +5 -2
  76. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  77. data/lib/bundler/man/bundle-install.1 +6 -2
  78. data/lib/bundler/man/bundle-install.1.ronn +8 -2
  79. data/lib/bundler/man/bundle-list.1 +1 -1
  80. data/lib/bundler/man/bundle-lock.1 +1 -1
  81. data/lib/bundler/man/bundle-open.1 +1 -1
  82. data/lib/bundler/man/bundle-outdated.1 +3 -10
  83. data/lib/bundler/man/bundle-outdated.1.ronn +1 -10
  84. data/lib/bundler/man/bundle-platform.1 +16 -6
  85. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  86. data/lib/bundler/man/bundle-plugin.1 +81 -0
  87. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  88. data/lib/bundler/man/bundle-pristine.1 +1 -1
  89. data/lib/bundler/man/bundle-remove.1 +1 -1
  90. data/lib/bundler/man/bundle-show.1 +1 -1
  91. data/lib/bundler/man/bundle-update.1 +2 -2
  92. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  93. data/lib/bundler/man/bundle-version.1 +35 -0
  94. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  95. data/lib/bundler/man/bundle-viz.1 +4 -1
  96. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  97. data/lib/bundler/man/bundle.1 +15 -10
  98. data/lib/bundler/man/bundle.1.ronn +12 -7
  99. data/lib/bundler/man/gemfile.5 +117 -80
  100. data/lib/bundler/man/gemfile.5.ronn +105 -84
  101. data/lib/bundler/man/index.txt +4 -0
  102. data/lib/bundler/match_metadata.rb +13 -0
  103. data/lib/bundler/match_platform.rb +0 -1
  104. data/lib/bundler/match_remote_metadata.rb +29 -0
  105. data/lib/bundler/plugin/api/source.rb +4 -9
  106. data/lib/bundler/plugin/installer/git.rb +0 -4
  107. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  108. data/lib/bundler/plugin/installer.rb +3 -1
  109. data/lib/bundler/plugin.rb +25 -6
  110. data/lib/bundler/process_lock.rb +1 -1
  111. data/lib/bundler/remote_specification.rb +10 -4
  112. data/lib/bundler/resolver/base.rb +50 -0
  113. data/lib/bundler/resolver/spec_group.rb +31 -49
  114. data/lib/bundler/resolver.rb +183 -192
  115. data/lib/bundler/ruby_dsl.rb +1 -1
  116. data/lib/bundler/ruby_version.rb +5 -18
  117. data/lib/bundler/rubygems_ext.rb +138 -20
  118. data/lib/bundler/rubygems_gem_installer.rb +42 -16
  119. data/lib/bundler/rubygems_integration.rb +42 -90
  120. data/lib/bundler/runtime.rb +2 -3
  121. data/lib/bundler/self_manager.rb +168 -0
  122. data/lib/bundler/settings.rb +13 -4
  123. data/lib/bundler/shared_helpers.rb +15 -24
  124. data/lib/bundler/source/git/git_proxy.rb +7 -4
  125. data/lib/bundler/source/git.rb +29 -13
  126. data/lib/bundler/source/metadata.rb +3 -3
  127. data/lib/bundler/source/path.rb +1 -1
  128. data/lib/bundler/source/rubygems.rb +148 -161
  129. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  130. data/lib/bundler/source.rb +6 -5
  131. data/lib/bundler/source_list.rb +15 -29
  132. data/lib/bundler/source_map.rb +15 -2
  133. data/lib/bundler/spec_set.rb +52 -32
  134. data/lib/bundler/stub_specification.rb +5 -3
  135. data/lib/bundler/templates/Executable +2 -4
  136. data/lib/bundler/templates/Executable.bundler +2 -2
  137. data/lib/bundler/templates/Executable.standalone +2 -4
  138. data/lib/bundler/templates/Gemfile +0 -2
  139. data/lib/bundler/templates/gems.rb +0 -3
  140. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  141. data/lib/bundler/templates/newgem/README.md.tt +3 -9
  142. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  143. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +5 -4
  144. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +5 -4
  145. data/lib/bundler/templates/newgem/newgem.gemspec.tt +16 -16
  146. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  147. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  148. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  149. data/lib/bundler/ui/shell.rb +1 -1
  150. data/lib/bundler/vendor/.document +1 -0
  151. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  152. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  153. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  154. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  155. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  156. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  157. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  158. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -3
  159. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +32 -26
  160. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  161. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  162. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  163. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  164. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  165. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  166. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  167. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  168. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  169. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  170. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  171. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  172. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  173. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  174. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  175. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  176. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  177. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  178. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  179. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  180. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  181. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  182. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  183. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  184. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  185. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  186. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  187. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  188. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  189. data/lib/bundler/vendored_tsort.rb +4 -0
  190. data/lib/bundler/version.rb +1 -1
  191. data/lib/bundler/worker.rb +2 -2
  192. data/lib/bundler.rb +40 -29
  193. metadata +37 -12
  194. data/lib/bundler/dep_proxy.rb +0 -55
  195. data/lib/bundler/gemdeps.rb +0 -29
  196. data/lib/bundler/psyched_yaml.rb +0 -22
  197. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -20,6 +20,7 @@ module Bundler
20
20
  class TooManyRequestsError < HTTPError; end
21
21
  # This error is raised if the API returns a 413 (only printed in verbose)
22
22
  class FallbackError < HTTPError; end
23
+
23
24
  # This is the error raised if OpenSSL fails the cert verification
24
25
  class CertificateFailureError < HTTPError
25
26
  def initialize(remote_uri)
@@ -28,10 +29,12 @@ module Bundler
28
29
  " is a chance you are experiencing a man-in-the-middle attack, but" \
29
30
  " most likely your system doesn't have the CA certificates needed" \
30
31
  " for verification. For information about OpenSSL certificates, see" \
31
- " http://bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile" \
32
+ " https://railsapps.github.io/openssl-certificate-verify-failed.html." \
33
+ " To connect without using SSL, edit your Gemfile" \
32
34
  " sources and change 'https' to 'http'."
33
35
  end
34
36
  end
37
+
35
38
  # This is the error raised when a source is HTTPS and OpenSSL didn't load
36
39
  class SSLError < HTTPError
37
40
  def initialize(msg = nil)
@@ -41,6 +44,7 @@ module Bundler
41
44
  "using RVM are available at rvm.io/packages/openssl."
42
45
  end
43
46
  end
47
+
44
48
  # This error is raised if HTTP authentication is required, but not provided.
45
49
  class AuthenticationRequiredError < HTTPError
46
50
  def initialize(remote_uri)
@@ -51,6 +55,7 @@ module Bundler
51
55
  "or by storing the credentials in the `#{Settings.key_for(remote_uri)}` environment variable"
52
56
  end
53
57
  end
58
+
54
59
  # This error is raised if HTTP authentication is provided, but incorrect.
55
60
  class BadAuthenticationError < HTTPError
56
61
  def initialize(remote_uri)
@@ -70,8 +75,8 @@ module Bundler
70
75
  :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
71
76
  FAIL_ERRORS = begin
72
77
  fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
73
- fail_errors << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError)
74
- fail_errors.concat(NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact)
78
+ fail_errors << Gem::Requirement::BadRequirementError
79
+ fail_errors.concat(NET_ERRORS.map {|e| Net.const_get(e) })
75
80
  end.freeze
76
81
 
77
82
  class << self
@@ -121,7 +126,6 @@ module Bundler
121
126
 
122
127
  # return the specs in the bundler format as an index
123
128
  def specs(gem_names, source)
124
- old = Bundler.rubygems.sources
125
129
  index = Bundler::Index.new
126
130
 
127
131
  if Bundler::Fetcher.disable_endpoint
@@ -129,17 +133,15 @@ module Bundler
129
133
  specs = fetchers.last.specs(gem_names)
130
134
  else
131
135
  specs = []
132
- fetchers.shift until fetchers.first.available? || fetchers.empty?
133
- fetchers.dup.each do |f|
134
- break unless f.api_fetcher? && !gem_names || !specs = f.specs(gem_names)
135
- fetchers.delete(f)
136
+ @fetchers = fetchers.drop_while do |f|
137
+ !f.available? || (f.api_fetcher? && !gem_names) || !specs = f.specs(gem_names)
136
138
  end
137
139
  @use_api = false if fetchers.none?(&:api_fetcher?)
138
140
  end
139
141
 
140
142
  specs.each do |name, version, platform, dependencies, metadata|
141
143
  spec = if dependencies
142
- EndpointSpecification.new(name, version, platform, dependencies, metadata)
144
+ EndpointSpecification.new(name, version, platform, self, dependencies, metadata)
143
145
  else
144
146
  RemoteSpecification.new(name, version, platform, self)
145
147
  end
@@ -152,8 +154,6 @@ module Bundler
152
154
  rescue CertificateFailureError
153
155
  Bundler.ui.info "" if gem_names && use_api # newline after dots
154
156
  raise
155
- ensure
156
- Bundler.rubygems.sources = old
157
157
  end
158
158
 
159
159
  def use_api
@@ -230,6 +230,7 @@ module Bundler
230
230
  "GO_SERVER_URL" => "go",
231
231
  "SNAP_CI" => "snap",
232
232
  "GITLAB_CI" => "gitlab",
233
+ "GITHUB_ACTIONS" => "github",
233
234
  "CI_NAME" => ENV["CI_NAME"],
234
235
  "CI" => "ci",
235
236
  }
@@ -239,12 +240,12 @@ module Bundler
239
240
  def connection
240
241
  @connection ||= begin
241
242
  needs_ssl = remote_uri.scheme == "https" ||
242
- Bundler.settings[:ssl_verify_mode] ||
243
- Bundler.settings[:ssl_client_cert]
243
+ Bundler.settings[:ssl_verify_mode] ||
244
+ Bundler.settings[:ssl_client_cert]
244
245
  raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
245
246
 
246
247
  con = PersistentHTTP.new :name => "bundler", :proxy => :ENV
247
- if gem_proxy = Bundler.rubygems.configuration[:http_proxy]
248
+ if gem_proxy = Gem.configuration[:http_proxy]
248
249
  con.proxy = Bundler::URI.parse(gem_proxy) if gem_proxy != :no_proxy
249
250
  end
250
251
 
@@ -255,8 +256,8 @@ module Bundler
255
256
  end
256
257
 
257
258
  ssl_client_cert = Bundler.settings[:ssl_client_cert] ||
258
- (Bundler.rubygems.configuration.ssl_client_cert if
259
- Bundler.rubygems.configuration.respond_to?(:ssl_client_cert))
259
+ (Gem.configuration.ssl_client_cert if
260
+ Gem.configuration.respond_to?(:ssl_client_cert))
260
261
  if ssl_client_cert
261
262
  pem = File.read(ssl_client_cert)
262
263
  con.cert = OpenSSL::X509::Certificate.new(pem)
@@ -274,8 +275,7 @@ module Bundler
274
275
  # cached gem specification path, if one exists
275
276
  def gemspec_cached_path(spec_file_name)
276
277
  paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
277
- paths = paths.select {|path| File.file? path }
278
- paths.first
278
+ paths.find {|path| File.file? path }
279
279
  end
280
280
 
281
281
  HTTP_ERRORS = [
@@ -288,8 +288,8 @@ module Bundler
288
288
  def bundler_cert_store
289
289
  store = OpenSSL::X509::Store.new
290
290
  ssl_ca_cert = Bundler.settings[:ssl_ca_cert] ||
291
- (Bundler.rubygems.configuration.ssl_ca_cert if
292
- Bundler.rubygems.configuration.respond_to?(:ssl_ca_cert))
291
+ (Gem.configuration.ssl_ca_cert if
292
+ Gem.configuration.respond_to?(:ssl_ca_cert))
293
293
  if ssl_ca_cert
294
294
  if File.directory? ssl_ca_cert
295
295
  store.add_path ssl_ca_cert
@@ -303,8 +303,6 @@ module Bundler
303
303
  store
304
304
  end
305
305
 
306
- private
307
-
308
306
  def remote_uri
309
307
  @remote.uri
310
308
  end
@@ -29,8 +29,11 @@ module Bundler
29
29
  Bundler.ui.error error.message
30
30
  Bundler.ui.trace error.orig_exception
31
31
  when BundlerError
32
- Bundler.ui.error error.message, :wrap => true
33
- Bundler.ui.trace error
32
+ if Bundler.ui.debug?
33
+ Bundler.ui.trace error
34
+ else
35
+ Bundler.ui.error error.message, :wrap => true
36
+ end
34
37
  when Thor::Error
35
38
  Bundler.ui.error error.message
36
39
  when LoadError
@@ -63,38 +66,9 @@ module Bundler
63
66
  def request_issue_report_for(e)
64
67
  Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, nil
65
68
  --- ERROR REPORT TEMPLATE -------------------------------------------------------
66
- # Error Report
67
-
68
- ## Questions
69
-
70
- Please fill out answers to these questions, it'll help us figure out
71
- why things are going wrong.
72
-
73
- - **What did you do?**
74
-
75
- I ran the command `#{$PROGRAM_NAME} #{ARGV.join(" ")}`
76
-
77
- - **What did you expect to happen?**
78
-
79
- I expected Bundler to...
80
-
81
- - **What happened instead?**
82
-
83
- Instead, what happened was...
84
-
85
- - **Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?**
86
-
87
- I tried...
88
-
89
- - **Have you read our issues document, https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/ISSUES.md?**
90
-
91
- ...
92
-
93
- ## Backtrace
94
69
 
95
70
  ```
96
- #{e.class}: #{e.message}
97
- #{e.backtrace && e.backtrace.join("\n ").chomp}
71
+ #{exception_message(e)}
98
72
  ```
99
73
 
100
74
  #{Bundler::Env.report}
@@ -109,8 +83,22 @@ module Bundler
109
83
  First, try this link to see if there are any existing issue reports for this error:
110
84
  #{issues_url(e)}
111
85
 
112
- If there aren't any reports for this error yet, please copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
113
- https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md
86
+ If there aren't any reports for this error yet, please fill in the new issue form located at #{new_issue_url}, and copy and paste the report template above in there.
87
+ EOS
88
+ end
89
+
90
+ def exception_message(error)
91
+ message = serialized_exception_for(error)
92
+ cause = error.cause
93
+ return message unless cause
94
+
95
+ message + serialized_exception_for(cause)
96
+ end
97
+
98
+ def serialized_exception_for(e)
99
+ <<-EOS.gsub(/^ {8}/, "")
100
+ #{e.class}: #{e.message}
101
+ #{e.backtrace && e.backtrace.join("\n ").chomp}
114
102
  EOS
115
103
  end
116
104
 
@@ -121,6 +109,10 @@ module Bundler
121
109
  "https://github.com/rubygems/rubygems/search?q=" \
122
110
  "#{CGI.escape(message)}&type=Issues"
123
111
  end
112
+
113
+ def new_issue_url
114
+ "https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md"
115
+ end
124
116
  end
125
117
 
126
118
  def self.with_friendly_errors
@@ -76,7 +76,7 @@ module Bundler
76
76
  tag_version { git_push(args[:remote]) } unless already_tagged?
77
77
  end
78
78
 
79
- task "release:rubygem_push" do
79
+ task "release:rubygem_push" => "build" do
80
80
  rubygem_push(built_gem_path) if gem_push?
81
81
  end
82
82
 
@@ -98,10 +98,7 @@ module Bundler
98
98
  built_gem_path ||= build_gem
99
99
  cmd = [*gem_command, "install", built_gem_path.to_s]
100
100
  cmd << "--local" if local
101
- _, status = sh_with_status(cmd)
102
- unless status.success?
103
- raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output"
104
- end
101
+ sh(cmd)
105
102
  Bundler.ui.confirm "#{name} (#{version}) installed."
106
103
  end
107
104
 
@@ -110,9 +107,9 @@ module Bundler
110
107
  SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) }
111
108
  file_name = "#{File.basename(built_gem_path)}.sha512"
112
109
  require "digest/sha2"
113
- checksum = Digest::SHA512.new.hexdigest(built_gem_path.to_s)
110
+ checksum = ::Digest::SHA512.file(built_gem_path).hexdigest
114
111
  target = File.join(base, "checksums", file_name)
115
- File.write(target, checksum)
112
+ File.write(target, checksum + "\n")
116
113
  Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}."
117
114
  end
118
115
 
@@ -132,8 +129,8 @@ module Bundler
132
129
 
133
130
  def git_push(remote = nil)
134
131
  remote ||= default_remote
135
- perform_git_push "#{remote} refs/heads/#{current_branch}"
136
- perform_git_push "#{remote} refs/tags/#{version_tag}"
132
+ sh("git push #{remote} refs/heads/#{current_branch}".shellsplit)
133
+ sh("git push #{remote} refs/tags/#{version_tag}".shellsplit)
137
134
  Bundler.ui.confirm "Pushed git commits and release tag."
138
135
  end
139
136
 
@@ -161,13 +158,6 @@ module Bundler
161
158
  allowed_push_host || env_rubygems_host || "rubygems.org"
162
159
  end
163
160
 
164
- def perform_git_push(options = "")
165
- cmd = "git push #{options}"
166
- out, status = sh_with_status(cmd.shellsplit)
167
- return if status.success?
168
- raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n"
169
- end
170
-
171
161
  def already_tagged?
172
162
  return false unless sh(%w[git tag]).split(/\n/).include?(version_tag)
173
163
  Bundler.ui.confirm "Tag #{version_tag} has already been created."
@@ -218,8 +208,7 @@ module Bundler
218
208
  def sh(cmd, &block)
219
209
  out, status = sh_with_status(cmd, &block)
220
210
  unless status.success?
221
- cmd = cmd.shelljoin if cmd.respond_to?(:shelljoin)
222
- raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
211
+ raise("Running `#{cmd.shelljoin}` failed with the following output:\n\n#{out}\n")
223
212
  end
224
213
  out
225
214
  end
@@ -10,6 +10,7 @@ module Bundler
10
10
  [Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],
11
11
  [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
12
12
  [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
13
+ [Gem::Platform.new("x64-mingw-ucrt"), Gem::Platform.new("x64-mingw-ucrt")],
13
14
  [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")],
14
15
  ].freeze
15
16
 
@@ -42,15 +43,21 @@ module Bundler
42
43
 
43
44
  def select_best_platform_match(specs, platform)
44
45
  matching = specs.select {|spec| spec.match_platform(platform) }
46
+
47
+ sort_best_platform_match(matching, platform)
48
+ end
49
+ module_function :select_best_platform_match
50
+
51
+ def sort_best_platform_match(matching, platform)
45
52
  exact = matching.select {|spec| spec.platform == platform }
46
53
  return exact if exact.any?
47
54
 
48
55
  sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
49
56
  exemplary_spec = sorted_matching.first
50
57
 
51
- sorted_matching.take_while{|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
58
+ sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
52
59
  end
53
- module_function :select_best_platform_match
60
+ module_function :sort_best_platform_match
54
61
 
55
62
  class PlatformMatch
56
63
  def self.specificity_score(spec_platform, user_platform)
@@ -55,19 +55,17 @@ module Bundler
55
55
  @level = v
56
56
  end
57
57
 
58
- # Given a Dependency and an Array of SpecGroups of available versions for a
59
- # gem, this method will return the Array of SpecGroups sorted (and possibly
58
+ # Given a Dependency and an Array of Specifications of available versions for a
59
+ # gem, this method will return the Array of Specifications sorted (and possibly
60
60
  # truncated if strict is true) in an order to give preference to the current
61
61
  # level (:major, :minor or :patch) when resolution is deciding what versions
62
62
  # best resolve all dependencies in the bundle.
63
63
  # @param dep [Dependency] The Dependency of the gem.
64
- # @param spec_groups [SpecGroup] An array of SpecGroups for the same gem
64
+ # @param spec_groups [Specification] An array of Specifications for the same gem
65
65
  # named in the @dep param.
66
- # @return [SpecGroup] A new instance of the SpecGroup Array sorted and
66
+ # @return [Specification] A new instance of the Specification Array sorted and
67
67
  # possibly filtered.
68
68
  def sort_versions(dep, spec_groups)
69
- before_result = "before sort_versions: #{debug_format_result(dep, spec_groups).inspect}" if DEBUG
70
-
71
69
  @sort_versions[dep] ||= begin
72
70
  gem_name = dep.name
73
71
 
@@ -79,15 +77,14 @@ module Bundler
79
77
  filter_dep_specs(spec_groups, locked_spec)
80
78
  else
81
79
  sort_dep_specs(spec_groups, locked_spec)
82
- end.tap do |specs|
83
- if DEBUG
84
- puts before_result
85
- puts " after sort_versions: #{debug_format_result(dep, specs).inspect}"
86
- end
87
80
  end
88
81
  end
89
82
  end
90
83
 
84
+ def reset
85
+ @sort_versions = {}
86
+ end
87
+
91
88
  # @return [bool] Convenience method for testing value of level variable.
92
89
  def major?
93
90
  level == :major
@@ -119,15 +116,14 @@ module Bundler
119
116
  end
120
117
 
121
118
  def sort_dep_specs(spec_groups, locked_spec)
122
- return spec_groups unless locked_spec
123
- @gem_name = locked_spec.name
124
- @locked_version = locked_spec.version
119
+ @locked_version = locked_spec&.version
120
+ @gem_name = locked_spec&.name
125
121
 
126
122
  result = spec_groups.sort do |a, b|
127
123
  @a_ver = a.version
128
124
  @b_ver = b.version
129
125
 
130
- unless @prerelease_specified[@gem_name]
126
+ unless @gem_name && @prerelease_specified[@gem_name]
131
127
  a_pre = @a_ver.prerelease?
132
128
  b_pre = @b_ver.prerelease?
133
129
 
@@ -151,7 +147,7 @@ module Bundler
151
147
  end
152
148
 
153
149
  def either_version_older_than_locked
154
- @a_ver < @locked_version || @b_ver < @locked_version
150
+ @locked_version && (@a_ver < @locked_version || @b_ver < @locked_version)
155
151
  end
156
152
 
157
153
  def segments_do_not_match(level)
@@ -160,7 +156,7 @@ module Bundler
160
156
  end
161
157
 
162
158
  def unlocking_gem?
163
- unlock_gems.empty? || unlock_gems.include?(@gem_name)
159
+ unlock_gems.empty? || (@gem_name && unlock_gems.include?(@gem_name))
164
160
  end
165
161
 
166
162
  # Specific version moves can't always reliably be done during sorting
@@ -168,7 +164,7 @@ module Bundler
168
164
  def post_sort(result)
169
165
  # default :major behavior in Bundler does not do this
170
166
  return result if major?
171
- if unlocking_gem?
167
+ if unlocking_gem? || @locked_version.nil?
172
168
  result
173
169
  else
174
170
  move_version_to_end(result, @locked_version)
@@ -179,12 +175,5 @@ module Bundler
179
175
  move, keep = result.partition {|s| s.version.to_s == version.to_s }
180
176
  keep.concat(move)
181
177
  end
182
-
183
- def debug_format_result(dep, spec_groups)
184
- a = [dep.to_s,
185
- spec_groups.map {|sg| [sg.version, sg.dependencies_for_activated_platforms.map {|dp| [dp.name, dp.requirement.to_s] }] }]
186
- last_map = a.last.map {|sg_data| [sg_data.first.version, sg_data.last.map {|aa| aa.join(" ") }] }
187
- [a.first, last_map, level, strict ? :strict : :not_strict]
188
- end
189
178
  end
190
179
  end
data/lib/bundler/index.rb CHANGED
@@ -56,45 +56,21 @@ module Bundler
56
56
 
57
57
  # Search this index's specs, and any source indexes that this index knows
58
58
  # about, returning all of the results.
59
- def search(query, base = nil)
60
- sort_specs(unsorted_search(query, base))
61
- end
62
-
63
- def unsorted_search(query, base)
64
- results = local_search(query, base)
65
-
66
- seen = results.map(&:full_name).uniq unless @sources.empty?
59
+ def search(query)
60
+ results = local_search(query)
61
+ return results unless @sources.any?
67
62
 
68
63
  @sources.each do |source|
69
- source.unsorted_search(query, base).each do |spec|
70
- next if seen.include?(spec.full_name)
71
-
72
- seen << spec.full_name
73
- results << spec
74
- end
64
+ results.concat(source.search(query))
75
65
  end
76
-
77
- results
78
- end
79
- protected :unsorted_search
80
-
81
- def self.sort_specs(specs)
82
- specs.sort_by do |s|
83
- platform_string = s.platform.to_s
84
- [s.version, platform_string == RUBY ? NULL : platform_string]
85
- end
86
- end
87
-
88
- def sort_specs(specs)
89
- self.class.sort_specs(specs)
66
+ results.uniq(&:full_name)
90
67
  end
91
68
 
92
- def local_search(query, base = nil)
69
+ def local_search(query)
93
70
  case query
94
71
  when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
95
72
  when String then specs_by_name(query)
96
- when Gem::Dependency then search_by_dependency(query, base)
97
- when DepProxy then search_by_dependency(query.dep, base)
73
+ when Gem::Dependency then search_by_dependency(query)
98
74
  else
99
75
  raise "You can't search for a #{query.inspect}."
100
76
  end
@@ -185,18 +161,12 @@ module Bundler
185
161
  @specs[name].values
186
162
  end
187
163
 
188
- def search_by_dependency(dependency, base = nil)
189
- @cache[base || false] ||= {}
190
- @cache[base || false][dependency] ||= begin
164
+ def search_by_dependency(dependency)
165
+ @cache[dependency] ||= begin
191
166
  specs = specs_by_name(dependency.name)
192
- specs += base if base
193
167
  found = specs.select do |spec|
194
168
  next true if spec.source.is_a?(Source::Gemspec)
195
- if base # allow all platforms when searching from a lockfile
196
- dependency.matches_spec?(spec)
197
- else
198
- dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec)
199
- end
169
+ dependency.matches_spec?(spec)
200
170
  end
201
171
 
202
172
  found
@@ -70,8 +70,12 @@ module Bundler
70
70
 
71
71
  show_warning("No gems were removed from the gemfile.") if deps.empty?
72
72
 
73
- deps.each {|dep| Bundler.ui.confirm "#{SharedHelpers.pretty_dependency(dep, false)} was removed." }
73
+ deps.each {|dep| Bundler.ui.confirm "#{SharedHelpers.pretty_dependency(dep)} was removed." }
74
74
  end
75
+
76
+ # Invalidate the cached Bundler.definition.
77
+ # This prevents e.g. `bundle remove ...` from using outdated information.
78
+ Bundler.reset_paths!
75
79
  end
76
80
 
77
81
  private
@@ -111,10 +115,14 @@ module Bundler
111
115
  end
112
116
 
113
117
  source = ", :source => \"#{d.source}\"" unless d.source.nil?
118
+ path = ", :path => \"#{d.path}\"" unless d.path.nil?
114
119
  git = ", :git => \"#{d.git}\"" unless d.git.nil?
120
+ github = ", :github => \"#{d.github}\"" unless d.github.nil?
115
121
  branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
122
+ ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
123
+ require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
116
124
 
117
- %(gem #{name}#{requirement}#{group}#{source}#{git}#{branch})
125
+ %(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{require_path})
118
126
  end.join("\n")
119
127
  end
120
128
 
@@ -269,5 +277,11 @@ module Bundler
269
277
  def show_warning(message)
270
278
  Bundler.ui.info Bundler.ui.add_color(message, :yellow)
271
279
  end
280
+
281
+ def convert_autorequire(autorequire)
282
+ autorequire = autorequire.first
283
+ return autorequire if autorequire == "false"
284
+ autorequire.inspect
285
+ end
272
286
  end
273
287
  end
@@ -38,12 +38,7 @@ def gemfile(install = false, options = {}, &gemfile)
38
38
  raise ArgumentError, "Unknown options: #{opts.keys.join(", ")}" unless opts.empty?
39
39
 
40
40
  begin
41
- old_root = Bundler.method(:root)
42
- bundler_module = class << Bundler; self; end
43
- bundler_module.send(:remove_method, :root)
44
- def Bundler.root
45
- Bundler::SharedHelpers.pwd.expand_path
46
- end
41
+ Bundler.instance_variable_set(:@bundle_path, Pathname.new(Gem.dir))
47
42
  old_gemfile = ENV["BUNDLE_GEMFILE"]
48
43
  Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", "Gemfile"
49
44
 
@@ -59,7 +54,7 @@ def gemfile(install = false, options = {}, &gemfile)
59
54
 
60
55
  Bundler.ui = install ? ui : Bundler::UI::Silent.new
61
56
  if install || definition.missing_specs?
62
- Bundler.settings.temporary(:inline => true) do
57
+ Bundler.settings.temporary(:inline => true, :no_install => false) do
63
58
  installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
64
59
  installer.post_install_messages.each do |name, message|
65
60
  Bundler.ui.info "Post-install message from #{name}:\n#{message}"
@@ -71,11 +66,6 @@ def gemfile(install = false, options = {}, &gemfile)
71
66
  runtime.setup.require
72
67
  end
73
68
  ensure
74
- if bundler_module
75
- bundler_module.send(:remove_method, :root)
76
- bundler_module.send(:define_method, :root, old_root)
77
- end
78
-
79
69
  if old_gemfile
80
70
  ENV["BUNDLE_GEMFILE"] = old_gemfile
81
71
  else
@@ -13,7 +13,7 @@ module Bundler
13
13
  end
14
14
 
15
15
  def install_from_spec
16
- post_install_message = spec_settings ? install_with_settings : install
16
+ post_install_message = install
17
17
  Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
18
18
  generate_executable_stubs
19
19
  return true, post_install_message
@@ -51,12 +51,20 @@ module Bundler
51
51
  end
52
52
 
53
53
  def install
54
- spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => Array(spec_settings))
54
+ spec.source.install(
55
+ spec,
56
+ :force => force,
57
+ :ensure_builtin_gems_cached => standalone,
58
+ :build_args => Array(spec_settings),
59
+ :previous_spec => previous_spec,
60
+ )
55
61
  end
56
62
 
57
- def install_with_settings
58
- # Build arguments are global, so this is mutexed
59
- Bundler.rubygems.install_with_build_args([spec_settings]) { install }
63
+ def previous_spec
64
+ locked_gems = installer.definition.locked_gems
65
+ return unless locked_gems
66
+
67
+ locked_gems.specs.find {|s| s.name == spec.name }
60
68
  end
61
69
 
62
70
  def out_of_space_message