bundler 1.17.3 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (249) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +794 -570
  3. data/LICENSE.md +18 -19
  4. data/README.md +9 -8
  5. data/bundler.gemspec +8 -25
  6. data/exe/bundle +19 -3
  7. data/lib/bundler.rb +202 -87
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/capistrano.rb +4 -4
  10. data/lib/bundler/cli.rb +178 -140
  11. data/lib/bundler/cli/add.rb +28 -16
  12. data/lib/bundler/cli/cache.rb +25 -13
  13. data/lib/bundler/cli/common.rb +11 -12
  14. data/lib/bundler/cli/config.rb +161 -86
  15. data/lib/bundler/cli/console.rb +1 -1
  16. data/lib/bundler/cli/doctor.rb +4 -4
  17. data/lib/bundler/cli/exec.rb +4 -16
  18. data/lib/bundler/cli/gem.rb +5 -5
  19. data/lib/bundler/cli/info.rb +17 -5
  20. data/lib/bundler/cli/init.rb +1 -1
  21. data/lib/bundler/cli/install.rb +11 -10
  22. data/lib/bundler/cli/issue.rb +3 -3
  23. data/lib/bundler/cli/open.rb +10 -6
  24. data/lib/bundler/cli/outdated.rb +85 -81
  25. data/lib/bundler/cli/plugin.rb +9 -2
  26. data/lib/bundler/cli/pristine.rb +1 -1
  27. data/lib/bundler/cli/show.rb +1 -1
  28. data/lib/bundler/cli/update.rb +32 -12
  29. data/lib/bundler/compact_index_client.rb +25 -9
  30. data/lib/bundler/compact_index_client/updater.rb +2 -6
  31. data/lib/bundler/current_ruby.rb +9 -7
  32. data/lib/bundler/definition.rb +35 -26
  33. data/lib/bundler/dependency.rb +16 -4
  34. data/lib/bundler/deployment.rb +1 -1
  35. data/lib/bundler/dsl.rb +16 -40
  36. data/lib/bundler/env.rb +8 -13
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +23 -34
  39. data/lib/bundler/fetcher.rb +16 -13
  40. data/lib/bundler/fetcher/compact_index.rb +26 -12
  41. data/lib/bundler/fetcher/dependency.rb +1 -1
  42. data/lib/bundler/fetcher/downloader.rb +5 -2
  43. data/lib/bundler/fetcher/index.rb +5 -3
  44. data/lib/bundler/friendly_errors.rb +6 -7
  45. data/lib/bundler/gem_helper.rb +40 -25
  46. data/lib/bundler/gem_helpers.rb +2 -4
  47. data/lib/bundler/gem_tasks.rb +1 -1
  48. data/lib/bundler/gem_version_promoter.rb +3 -3
  49. data/lib/bundler/graph.rb +2 -2
  50. data/lib/bundler/injector.rb +10 -8
  51. data/lib/bundler/inline.rb +40 -30
  52. data/lib/bundler/installer.rb +7 -14
  53. data/lib/bundler/installer/gem_installer.rb +5 -1
  54. data/lib/bundler/installer/parallel_installer.rb +4 -8
  55. data/lib/bundler/installer/standalone.rb +1 -2
  56. data/lib/bundler/lazy_specification.rb +2 -3
  57. data/lib/bundler/lockfile_parser.rb +14 -21
  58. data/lib/bundler/match_platform.rb +1 -1
  59. data/lib/bundler/mirror.rb +3 -3
  60. data/lib/bundler/plugin.rb +42 -29
  61. data/lib/bundler/plugin/api.rb +1 -1
  62. data/lib/bundler/plugin/api/source.rb +4 -6
  63. data/lib/bundler/plugin/index.rb +14 -3
  64. data/lib/bundler/plugin/installer.rb +28 -15
  65. data/lib/bundler/psyched_yaml.rb +1 -1
  66. data/lib/bundler/remote_specification.rb +0 -2
  67. data/lib/bundler/resolver.rb +72 -24
  68. data/lib/bundler/resolver/spec_group.rb +3 -2
  69. data/lib/bundler/retry.rb +2 -2
  70. data/lib/bundler/ruby_version.rb +4 -19
  71. data/lib/bundler/rubygems_ext.rb +11 -67
  72. data/lib/bundler/rubygems_gem_installer.rb +1 -8
  73. data/lib/bundler/rubygems_integration.rb +148 -400
  74. data/lib/bundler/runtime.rb +2 -9
  75. data/lib/bundler/settings.rb +22 -51
  76. data/lib/bundler/setup.rb +11 -12
  77. data/lib/bundler/shared_helpers.rb +51 -77
  78. data/lib/bundler/similarity_detector.rb +2 -2
  79. data/lib/bundler/source.rb +5 -5
  80. data/lib/bundler/source/git.rb +24 -17
  81. data/lib/bundler/source/git/git_proxy.rb +38 -41
  82. data/lib/bundler/source/metadata.rb +7 -2
  83. data/lib/bundler/source/path.rb +13 -8
  84. data/lib/bundler/source/rubygems.rb +14 -8
  85. data/lib/bundler/source/rubygems/remote.rb +2 -3
  86. data/lib/bundler/source_list.rb +9 -12
  87. data/lib/bundler/spec_set.rb +23 -12
  88. data/lib/bundler/stub_specification.rb +18 -30
  89. data/lib/bundler/templates/Executable.bundler +23 -14
  90. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
  91. data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
  92. data/lib/bundler/templates/newgem/README.md.tt +4 -3
  93. data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -27
  94. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +1 -1
  95. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  96. data/lib/bundler/ui.rb +3 -3
  97. data/lib/bundler/ui/rg_proxy.rb +1 -1
  98. data/lib/bundler/ui/shell.rb +4 -8
  99. data/lib/bundler/uri_credentials_filter.rb +7 -3
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  101. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  102. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  103. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  104. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +273 -147
  105. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  111. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  112. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  116. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
  117. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  118. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +273 -304
  119. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  120. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  121. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  122. data/lib/bundler/vendor/thor/lib/thor.rb +19 -4
  123. data/lib/bundler/vendor/thor/lib/thor/actions.rb +27 -12
  124. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  125. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  126. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  127. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +16 -7
  128. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
  129. data/lib/bundler/vendor/thor/lib/thor/base.rb +54 -43
  130. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  131. data/lib/bundler/vendor/thor/lib/thor/error.rb +78 -0
  132. data/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  133. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  134. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  135. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  136. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  137. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  138. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  139. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +2 -2
  140. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  141. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +20 -5
  142. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  143. data/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
  144. data/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
  145. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +62 -8
  146. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -2
  147. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  148. data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  149. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  150. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  151. data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  152. data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  153. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  154. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  155. data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  156. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  157. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  158. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  159. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  160. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  161. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  162. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  163. data/lib/bundler/vendored_fileutils.rb +1 -6
  164. data/lib/bundler/vendored_molinillo.rb +1 -1
  165. data/lib/bundler/vendored_persistent.rb +7 -5
  166. data/lib/bundler/vendored_thor.rb +2 -2
  167. data/lib/bundler/vendored_uri.rb +4 -0
  168. data/lib/bundler/version.rb +1 -20
  169. data/lib/bundler/version_ranges.rb +51 -5
  170. data/lib/bundler/vlad.rb +2 -2
  171. data/lib/bundler/worker.rb +1 -3
  172. data/lib/bundler/yaml_serializer.rb +2 -3
  173. data/man/bundle-add.1 +10 -2
  174. data/man/bundle-add.1.txt +11 -5
  175. data/man/bundle-add.ronn +7 -1
  176. data/man/bundle-binstubs.1 +2 -2
  177. data/man/bundle-binstubs.1.txt +2 -2
  178. data/man/bundle-binstubs.ronn +1 -1
  179. data/man/bundle-cache.1 +55 -0
  180. data/man/bundle-cache.1.txt +78 -0
  181. data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
  182. data/man/bundle-check.1 +1 -1
  183. data/man/bundle-check.1.txt +6 -6
  184. data/man/bundle-clean.1 +1 -1
  185. data/man/bundle-clean.1.txt +1 -1
  186. data/man/bundle-config.1 +36 -36
  187. data/man/bundle-config.1.txt +66 -67
  188. data/man/bundle-config.ronn +42 -40
  189. data/man/bundle-doctor.1 +1 -1
  190. data/man/bundle-doctor.1.txt +1 -1
  191. data/man/bundle-exec.1 +2 -2
  192. data/man/bundle-exec.1.txt +2 -2
  193. data/man/bundle-exec.ronn +1 -1
  194. data/man/bundle-gem.1 +1 -1
  195. data/man/bundle-gem.1.txt +3 -3
  196. data/man/bundle-info.1 +1 -1
  197. data/man/bundle-info.1.txt +1 -1
  198. data/man/bundle-init.1 +2 -2
  199. data/man/bundle-init.1.txt +2 -2
  200. data/man/bundle-init.ronn +1 -1
  201. data/man/bundle-inject.1 +1 -1
  202. data/man/bundle-inject.1.txt +1 -1
  203. data/man/bundle-install.1 +8 -5
  204. data/man/bundle-install.1.txt +56 -51
  205. data/man/bundle-install.ronn +9 -4
  206. data/man/bundle-list.1 +1 -1
  207. data/man/bundle-list.1.txt +1 -1
  208. data/man/bundle-lock.1 +1 -1
  209. data/man/bundle-lock.1.txt +16 -16
  210. data/man/bundle-open.1 +1 -1
  211. data/man/bundle-open.1.txt +1 -1
  212. data/man/bundle-outdated.1 +1 -1
  213. data/man/bundle-outdated.1.txt +1 -1
  214. data/man/bundle-platform.1 +1 -1
  215. data/man/bundle-platform.1.txt +1 -1
  216. data/man/bundle-pristine.1 +1 -1
  217. data/man/bundle-pristine.1.txt +1 -1
  218. data/man/bundle-remove.1 +1 -1
  219. data/man/bundle-remove.1.txt +1 -1
  220. data/man/bundle-show.1 +1 -1
  221. data/man/bundle-show.1.txt +1 -1
  222. data/man/bundle-update.1 +4 -4
  223. data/man/bundle-update.1.txt +64 -65
  224. data/man/bundle-update.ronn +3 -3
  225. data/man/bundle-viz.1 +1 -1
  226. data/man/bundle-viz.1.txt +1 -1
  227. data/man/bundle.1 +3 -3
  228. data/man/bundle.1.txt +8 -8
  229. data/man/bundle.ronn +2 -2
  230. data/man/gemfile.5 +17 -20
  231. data/man/gemfile.5.ronn +14 -18
  232. data/man/gemfile.5.txt +108 -112
  233. data/man/index.txt +1 -1
  234. metadata +34 -110
  235. data/exe/bundle_ruby +0 -60
  236. data/lib/bundler/cli/package.rb +0 -49
  237. data/lib/bundler/compatibility_guard.rb +0 -14
  238. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  239. data/lib/bundler/ssl_certs/.document +0 -1
  240. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  241. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  242. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  243. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  244. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  245. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  246. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  247. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  248. data/man/bundle-package.1 +0 -55
  249. data/man/bundle-package.1.txt +0 -79
@@ -28,7 +28,7 @@ module Bundler
28
28
 
29
29
  protected
30
30
 
31
- # http://www.informit.com/articles/article.aspx?p=683059&seqNum=36
31
+ # https://www.informit.com/articles/article.aspx?p=683059&seqNum=36
32
32
  def levenshtein_distance(this, that, ins = 2, del = 2, sub = 1)
33
33
  # ins, del, sub are weighted costs
34
34
  return nil if this.nil?
@@ -51,7 +51,7 @@ module Bundler
51
51
  dm[i][j] = [
52
52
  dm[i - 1][j - 1] + (this[j - 1] == that[i - 1] ? 0 : sub),
53
53
  dm[i][j - 1] + ins,
54
- dm[i - 1][j] + del
54
+ dm[i - 1][j] + del,
55
55
  ].min
56
56
  end
57
57
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Bundler
4
4
  class Source
5
- autoload :Gemspec, "bundler/source/gemspec"
6
- autoload :Git, "bundler/source/git"
7
- autoload :Metadata, "bundler/source/metadata"
8
- autoload :Path, "bundler/source/path"
9
- autoload :Rubygems, "bundler/source/rubygems"
5
+ autoload :Gemspec, File.expand_path("source/gemspec", __dir__)
6
+ autoload :Git, File.expand_path("source/git", __dir__)
7
+ autoload :Metadata, File.expand_path("source/metadata", __dir__)
8
+ autoload :Path, File.expand_path("source/path", __dir__)
9
+ autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
10
10
 
11
11
  attr_accessor :dependency_names
12
12
 
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/vendored_fileutils"
4
- require "uri"
3
+ require_relative "../vendored_fileutils"
5
4
 
6
5
  module Bundler
7
6
  class Source
8
7
  class Git < Path
9
- autoload :GitProxy, "bundler/source/git/git_proxy"
8
+ autoload :GitProxy, File.expand_path("git/git_proxy", __dir__)
10
9
 
11
- attr_reader :uri, :ref, :branch, :options, :submodules
10
+ attr_reader :uri, :ref, :branch, :options, :glob, :submodules
12
11
 
13
12
  def initialize(options)
14
13
  @options = options
@@ -48,13 +47,14 @@ module Bundler
48
47
  end
49
48
 
50
49
  def hash
51
- [self.class, uri, ref, branch, name, version, submodules].hash
50
+ [self.class, uri, ref, branch, name, version, glob, submodules].hash
52
51
  end
53
52
 
54
53
  def eql?(other)
55
54
  other.is_a?(Git) && uri == other.uri && ref == other.ref &&
56
55
  branch == other.branch && name == other.name &&
57
- version == other.version && submodules == other.submodules
56
+ version == other.version && glob == other.glob &&
57
+ submodules == other.submodules
58
58
  end
59
59
 
60
60
  alias_method :==, :eql?
@@ -118,18 +118,19 @@ module Bundler
118
118
  def local_override!(path)
119
119
  return false if local?
120
120
 
121
+ original_path = path
121
122
  path = Pathname.new(path)
122
123
  path = path.expand_path(Bundler.root) unless path.relative?
123
124
 
124
125
  unless options["branch"] || Bundler.settings[:disable_local_branch_check]
125
126
  raise GitError, "Cannot use local override for #{name} at #{path} because " \
126
- ":branch is not specified in Gemfile. Specify a branch or use " \
127
- "`bundle config --delete` to remove the local override"
127
+ ":branch is not specified in Gemfile. Specify a branch or run " \
128
+ "`bundle config unset local.#{override_for(original_path)}` to remove the local override"
128
129
  end
129
130
 
130
131
  unless path.exist?
131
132
  raise GitError, "Cannot use local override for #{name} because #{path} " \
132
- "does not exist. Check `bundle config --delete` to remove the local override"
133
+ "does not exist. Run `bundle config unset local.#{override_for(original_path)}` to remove the local override"
133
134
  end
134
135
 
135
136
  set_local!(path)
@@ -260,7 +261,11 @@ module Bundler
260
261
  end
261
262
 
262
263
  def requires_checkout?
263
- allow_git_ops? && !local?
264
+ allow_git_ops? && !local? && !cached_revision_checked_out?
265
+ end
266
+
267
+ def cached_revision_checked_out?
268
+ cached_revision && cached_revision == revision && install_path.exist?
264
269
  end
265
270
 
266
271
  def base_name
@@ -279,7 +284,7 @@ module Bundler
279
284
  if uri =~ %r{^\w+://(\w+@)?}
280
285
  # Downcase the domain component of the URI
281
286
  # and strip off a trailing slash, if one is present
282
- input = URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
287
+ input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
283
288
  else
284
289
  # If there is no URI scheme, assume it is an ssh/git URI
285
290
  input = uri
@@ -309,12 +314,10 @@ module Bundler
309
314
  # no-op, since we validate when re-serializing the gemspec
310
315
  def validate_spec(_spec); end
311
316
 
312
- if Bundler.rubygems.stubs_provide_full_functionality?
313
- def load_gemspec(file)
314
- stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
315
- stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.untaint
316
- StubSpecification.from_stub(stub)
317
- end
317
+ def load_gemspec(file)
318
+ stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
319
+ stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
320
+ StubSpecification.from_stub(stub)
318
321
  end
319
322
 
320
323
  def git_scope
@@ -324,6 +327,10 @@ module Bundler
324
327
  def extension_cache_slug(_)
325
328
  extension_dir_name
326
329
  end
330
+
331
+ def override_for(path)
332
+ Bundler.settings.local_overrides.key(path)
333
+ end
327
334
  end
328
335
  end
329
336
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "shellwords"
4
- require "tempfile"
4
+
5
5
  module Bundler
6
6
  class Source
7
7
  class Git
@@ -18,14 +18,18 @@ module Bundler
18
18
  def initialize(command)
19
19
  msg = String.new
20
20
  msg << "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, "
21
- msg << "this error message could probably be more useful. Please submit a ticket at http://github.com/bundler/bundler/issues "
21
+ msg << "this error message could probably be more useful. Please submit a ticket at https://github.com/bundler/bundler/issues "
22
22
  msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
23
23
  super msg
24
24
  end
25
25
  end
26
26
 
27
27
  class GitCommandError < GitError
28
+ attr_reader :command
29
+
28
30
  def initialize(command, path = nil, extra_info = nil)
31
+ @command = command
32
+
29
33
  msg = String.new
30
34
  msg << "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed."
31
35
  msg << "\n#{extra_info}" if extra_info
@@ -34,10 +38,10 @@ module Bundler
34
38
  end
35
39
  end
36
40
 
37
- class MissingGitRevisionError < GitError
38
- def initialize(ref, repo)
41
+ class MissingGitRevisionError < GitCommandError
42
+ def initialize(command, path, ref, repo)
39
43
  msg = "Revision #{ref} does not exist in the repository #{repo}. Maybe you misspelled it?"
40
- super msg
44
+ super command, path, msg
41
45
  end
42
46
  end
43
47
 
@@ -62,8 +66,8 @@ module Bundler
62
66
 
63
67
  begin
64
68
  @revision ||= find_local_revision
65
- rescue GitCommandError
66
- raise MissingGitRevisionError.new(ref, URICredentialsFilter.credential_filtered_uri(uri))
69
+ rescue GitCommandError => e
70
+ raise MissingGitRevisionError.new(e.command, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
67
71
  end
68
72
 
69
73
  @revision
@@ -77,8 +81,8 @@ module Bundler
77
81
 
78
82
  def contains?(commit)
79
83
  allowed_in_path do
80
- result = git_null("branch --contains #{commit}")
81
- $? == 0 && result =~ /^\* (.*)$/
84
+ result, status = git_null("branch --contains #{commit}")
85
+ status.success? && result =~ /^\* (.*)$/
82
86
  end
83
87
  end
84
88
 
@@ -134,8 +138,8 @@ module Bundler
134
138
 
135
139
  begin
136
140
  git "reset --hard #{@revision}"
137
- rescue GitCommandError
138
- raise MissingGitRevisionError.new(@revision, URICredentialsFilter.credential_filtered_uri(uri))
141
+ rescue GitCommandError => e
142
+ raise MissingGitRevisionError.new(e.command, path, @revision, URICredentialsFilter.credential_filtered_uri(uri))
139
143
  end
140
144
 
141
145
  if submodules
@@ -148,13 +152,15 @@ module Bundler
148
152
 
149
153
  private
150
154
 
151
- # TODO: Do not rely on /dev/null.
152
- # Given that open3 is not cross platform until Ruby 1.9.3,
153
- # the best solution is to pipe to /dev/null if it exists.
154
- # If it doesn't, everything will work fine, but the user
155
- # will get the $stderr messages as well.
156
155
  def git_null(command)
157
- git("#{command} 2>#{Bundler::NULL}", false)
156
+ command_with_no_credentials = URICredentialsFilter.credential_filtered_string(command, uri)
157
+ raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
158
+
159
+ out, status = SharedHelpers.with_clean_git_env do
160
+ capture_and_ignore_stderr("git #{command}")
161
+ end
162
+
163
+ [URICredentialsFilter.credential_filtered_string(out, uri), status]
158
164
  end
159
165
 
160
166
  def git_retry(command)
@@ -167,12 +173,12 @@ module Bundler
167
173
  command_with_no_credentials = URICredentialsFilter.credential_filtered_string(command, uri)
168
174
  raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
169
175
 
170
- out = SharedHelpers.with_clean_git_env do
171
- capture_and_filter_stderr(uri) { `git #{command}` }
176
+ out, status = SharedHelpers.with_clean_git_env do
177
+ capture_and_filter_stderr(uri, "git #{command}")
172
178
  end
173
179
 
174
180
  stdout_with_no_credentials = URICredentialsFilter.credential_filtered_string(out, uri)
175
- raise GitCommandError.new(command_with_no_credentials, path, error_msg) if check_errors && !$?.success?
181
+ raise GitCommandError.new(command_with_no_credentials, path, error_msg) if check_errors && !status.success?
176
182
  stdout_with_no_credentials
177
183
  end
178
184
 
@@ -211,7 +217,7 @@ module Bundler
211
217
  # Adds credentials to the URI as Fetcher#configured_uri_for does
212
218
  def configured_uri_for(uri)
213
219
  if /https?:/ =~ uri
214
- remote = URI(uri)
220
+ remote = Bundler::URI(uri)
215
221
  config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
216
222
  remote.userinfo ||= config_auth
217
223
  remote.to_s
@@ -235,26 +241,17 @@ module Bundler
235
241
  raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application"
236
242
  end
237
243
 
238
- # TODO: Replace this with Open3 when upgrading to bundler 2
239
- # Similar to #git_null, as Open3 is not cross-platform,
240
- # a temporary way is to use Tempfile to capture the stderr.
241
- # When replacing this using Open3, make sure git_null is
242
- # also replaced by Open3, so stdout and stderr all got handled properly.
243
- def capture_and_filter_stderr(uri)
244
- return_value, captured_err = ""
245
- backup_stderr = STDERR.dup
246
- begin
247
- Tempfile.open("captured_stderr") do |f|
248
- STDERR.reopen(f)
249
- return_value = yield
250
- f.rewind
251
- captured_err = f.read
252
- end
253
- ensure
254
- STDERR.reopen backup_stderr
255
- end
256
- $stderr.puts URICredentialsFilter.credential_filtered_string(captured_err, uri) if uri && !captured_err.empty?
257
- return_value
244
+ def capture_and_filter_stderr(uri, cmd)
245
+ require "open3"
246
+ return_value, captured_err, status = Open3.capture3(cmd)
247
+ Bundler.ui.warn URICredentialsFilter.credential_filtered_string(captured_err, uri) if uri && !captured_err.empty?
248
+ [return_value, status]
249
+ end
250
+
251
+ def capture_and_ignore_stderr(cmd)
252
+ require "open3"
253
+ return_value, _, status = Open3.capture3(cmd)
254
+ [return_value, status]
258
255
  end
259
256
  end
260
257
  end
@@ -5,16 +5,21 @@ module Bundler
5
5
  class Metadata < Source
6
6
  def specs
7
7
  @specs ||= Index.build do |idx|
8
- idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
9
- idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
8
+ idx << Gem::Specification.new("Ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
9
+ idx << Gem::Specification.new("RubyGems\0", Gem::VERSION) do |s|
10
+ s.required_rubygems_version = Gem::Requirement.default
11
+ end
10
12
 
11
13
  idx << Gem::Specification.new do |s|
12
14
  s.name = "bundler"
13
15
  s.version = VERSION
16
+ s.license = "MIT"
14
17
  s.platform = Gem::Platform::RUBY
15
18
  s.source = self
16
19
  s.authors = ["bundler team"]
17
20
  s.bindir = "exe"
21
+ s.homepage = "https://bundler.io"
22
+ s.summary = "The best way to manage your application's dependencies"
18
23
  s.executables = %w[bundle]
19
24
  # can't point to the actual gemspec or else the require paths will be wrong
20
25
  s.loaded_from = File.expand_path("..", __FILE__)
@@ -3,7 +3,7 @@
3
3
  module Bundler
4
4
  class Source
5
5
  class Path < Source
6
- autoload :Installer, "bundler/source/path/installer"
6
+ autoload :Installer, File.expand_path("path/installer", __dir__)
7
7
 
8
8
  attr_reader :path, :options, :root_path, :original_path
9
9
  attr_writer :name
@@ -20,11 +20,16 @@ module Bundler
20
20
  @allow_cached = false
21
21
  @allow_remote = false
22
22
 
23
- @root_path = options["root_path"] || Bundler.root
23
+ @root_path = options["root_path"] || root
24
24
 
25
25
  if options["path"]
26
26
  @path = Pathname.new(options["path"])
27
- @path = expand(@path) unless @path.relative?
27
+ expanded_path = expand(@path)
28
+ @path = if @path.relative?
29
+ expanded_path.relative_path_from(root_path.expand_path)
30
+ else
31
+ expanded_path
32
+ end
28
33
  end
29
34
 
30
35
  @name = options["name"]
@@ -136,7 +141,7 @@ module Bundler
136
141
 
137
142
  def lockfile_path
138
143
  return relative_path(original_path) if original_path.absolute?
139
- expand(original_path).relative_path_from(Bundler.root)
144
+ expand(original_path).relative_path_from(root)
140
145
  end
141
146
 
142
147
  def app_cache_path(custom_path = nil)
@@ -191,10 +196,10 @@ module Bundler
191
196
  else
192
197
  message = String.new("The path `#{expanded_path}` ")
193
198
  message << if File.exist?(expanded_path)
194
- "is not a directory."
195
- else
196
- "does not exist."
197
- end
199
+ "is not a directory."
200
+ else
201
+ "does not exist."
202
+ end
198
203
  raise PathError, message
199
204
  end
200
205
 
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "uri"
4
3
  require "rubygems/user_interaction"
5
4
 
6
5
  module Bundler
7
6
  class Source
8
7
  class Rubygems < Source
9
- autoload :Remote, "bundler/source/rubygems/remote"
8
+ autoload :Remote, File.expand_path("rubygems/remote", __dir__)
10
9
 
11
10
  # Use the API when installing less than X gems
12
11
  API_REQUEST_LIMIT = 500
@@ -51,7 +50,7 @@ module Bundler
51
50
  end
52
51
 
53
52
  def can_lock?(spec)
54
- return super if Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
53
+ return super if Bundler.feature_flag.disable_multisource?
55
54
  spec.source.is_a?(Rubygems)
56
55
  end
57
56
 
@@ -106,7 +105,7 @@ module Bundler
106
105
  end
107
106
  end
108
107
 
109
- if installed?(spec) && !force
108
+ if (installed?(spec) || Plugin.installed?(spec.name)) && !force
110
109
  print_using_message "Using #{version_message(spec)}"
111
110
  return nil # no post-install message
112
111
  end
@@ -120,8 +119,14 @@ module Bundler
120
119
  uris.uniq!
121
120
  Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
122
121
 
123
- s = Bundler.rubygems.spec_from_gem(fetch_gem(spec), Bundler.settings["trust-policy"])
124
- spec.__swap__(s)
122
+ path = fetch_gem(spec)
123
+ begin
124
+ s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
125
+ spec.__swap__(s)
126
+ rescue StandardError
127
+ Bundler.rm_rf(path)
128
+ raise
129
+ end
125
130
  end
126
131
 
127
132
  unless Bundler.settings[:no_install]
@@ -322,9 +327,10 @@ module Bundler
322
327
  def normalize_uri(uri)
323
328
  uri = uri.to_s
324
329
  uri = "#{uri}/" unless uri =~ %r{/$}
325
- uri = URI(uri)
330
+ require_relative "../vendored_uri"
331
+ uri = Bundler::URI(uri)
326
332
  raise ArgumentError, "The source must be an absolute URI. For example:\n" \
327
- "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(URI::HTTP) && uri.host.nil?)
333
+ "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(Bundler::URI::HTTP) && uri.host.nil?)
328
334
  uri
329
335
  end
330
336
 
@@ -25,8 +25,7 @@ module Bundler
25
25
 
26
26
  cache_uri = original_uri || uri
27
27
 
28
- # URI::File of Ruby 2.6 returns empty string when given "file://".
29
- host = defined?(URI::File) && cache_uri.is_a?(URI::File) ? nil : cache_uri.host
28
+ host = cache_uri.to_s.start_with?("file://") ? nil : cache_uri.host
30
29
 
31
30
  uri_parts = [host, cache_uri.user, cache_uri.port, cache_uri.path]
32
31
  uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join("."))
@@ -49,7 +48,7 @@ module Bundler
49
48
  end
50
49
 
51
50
  uri
52
- rescue URI::InvalidComponentError
51
+ rescue Bundler::URI::InvalidComponentError
53
52
  error_message = "Please CGI escape your usernames and passwords before " \
54
53
  "setting them for authentication."
55
54
  raise HTTPError.new(error_message)