bundler 2.1.4 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2017 -1430
  3. data/README.md +7 -9
  4. data/bundler.gemspec +5 -6
  5. data/exe/bundle +3 -0
  6. data/lib/bundler/build_metadata.rb +3 -11
  7. data/lib/bundler/cli/add.rb +1 -1
  8. data/lib/bundler/cli/binstubs.rb +6 -2
  9. data/lib/bundler/cli/cache.rb +3 -8
  10. data/lib/bundler/cli/check.rb +4 -2
  11. data/lib/bundler/cli/clean.rb +1 -1
  12. data/lib/bundler/cli/common.rb +29 -2
  13. data/lib/bundler/cli/console.rb +1 -1
  14. data/lib/bundler/cli/doctor.rb +16 -5
  15. data/lib/bundler/cli/exec.rb +5 -10
  16. data/lib/bundler/cli/fund.rb +36 -0
  17. data/lib/bundler/cli/gem.rb +209 -28
  18. data/lib/bundler/cli/info.rb +28 -5
  19. data/lib/bundler/cli/init.rb +2 -2
  20. data/lib/bundler/cli/inject.rb +1 -1
  21. data/lib/bundler/cli/install.rb +22 -34
  22. data/lib/bundler/cli/issue.rb +5 -4
  23. data/lib/bundler/cli/list.rb +19 -11
  24. data/lib/bundler/cli/lock.rb +5 -1
  25. data/lib/bundler/cli/open.rb +1 -2
  26. data/lib/bundler/cli/outdated.rb +95 -75
  27. data/lib/bundler/cli/plugin.rb +10 -0
  28. data/lib/bundler/cli/pristine.rb +5 -0
  29. data/lib/bundler/cli/remove.rb +1 -2
  30. data/lib/bundler/cli/show.rb +1 -1
  31. data/lib/bundler/cli/update.rb +14 -7
  32. data/lib/bundler/cli.rb +89 -66
  33. data/lib/bundler/compact_index_client/cache.rb +6 -14
  34. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  35. data/lib/bundler/compact_index_client/updater.rb +13 -22
  36. data/lib/bundler/compact_index_client.rb +3 -3
  37. data/lib/bundler/current_ruby.rb +5 -4
  38. data/lib/bundler/definition.rb +193 -363
  39. data/lib/bundler/dep_proxy.rb +16 -9
  40. data/lib/bundler/dependency.rb +3 -10
  41. data/lib/bundler/digest.rb +71 -0
  42. data/lib/bundler/dsl.rb +71 -47
  43. data/lib/bundler/endpoint_specification.rb +1 -1
  44. data/lib/bundler/env.rb +1 -1
  45. data/lib/bundler/environment_preserver.rb +29 -2
  46. data/lib/bundler/errors.rb +20 -3
  47. data/lib/bundler/feature_flag.rb +0 -8
  48. data/lib/bundler/fetcher/base.rb +1 -1
  49. data/lib/bundler/fetcher/compact_index.rb +2 -2
  50. data/lib/bundler/fetcher/downloader.rb +10 -7
  51. data/lib/bundler/fetcher/index.rb +3 -5
  52. data/lib/bundler/fetcher.rb +7 -5
  53. data/lib/bundler/friendly_errors.rb +25 -43
  54. data/lib/bundler/gem_helper.rb +53 -31
  55. data/lib/bundler/gem_helpers.rb +36 -25
  56. data/lib/bundler/gem_version_promoter.rb +4 -4
  57. data/lib/bundler/graph.rb +1 -1
  58. data/lib/bundler/index.rb +9 -9
  59. data/lib/bundler/injector.rb +23 -5
  60. data/lib/bundler/inline.rb +3 -2
  61. data/lib/bundler/installer/gem_installer.rb +6 -19
  62. data/lib/bundler/installer/parallel_installer.rb +46 -25
  63. data/lib/bundler/installer/standalone.rb +30 -10
  64. data/lib/bundler/installer.rb +36 -56
  65. data/lib/bundler/lazy_specification.rb +62 -26
  66. data/lib/bundler/lockfile_generator.rb +1 -1
  67. data/lib/bundler/lockfile_parser.rb +8 -34
  68. data/lib/bundler/man/.document +1 -0
  69. data/{man → lib/bundler/man}/bundle-add.1 +1 -1
  70. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +0 -0
  71. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  72. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  73. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  74. data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  75. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  76. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  77. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  78. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  79. data/{man → lib/bundler/man}/bundle-config.1 +40 -41
  80. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +50 -53
  81. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  82. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  83. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  84. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  85. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  86. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  87. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  88. data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  89. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  90. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  91. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  92. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  93. data/{man → lib/bundler/man}/bundle-install.1 +30 -3
  94. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +25 -3
  95. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  96. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  97. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  98. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  99. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  100. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  101. data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
  102. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
  103. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  104. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  105. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  106. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  107. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  108. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  109. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  110. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  111. data/{man → lib/bundler/man}/bundle-update.1 +4 -4
  112. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +3 -3
  113. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  114. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  115. data/{man → lib/bundler/man}/bundle.1 +1 -1
  116. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  117. data/{man → lib/bundler/man}/gemfile.5 +30 -4
  118. data/{man → lib/bundler/man}/gemfile.5.ronn +12 -4
  119. data/{man → lib/bundler/man}/index.txt +0 -0
  120. data/lib/bundler/mirror.rb +2 -2
  121. data/lib/bundler/plugin/api/source.rb +23 -1
  122. data/lib/bundler/plugin/dsl.rb +1 -1
  123. data/lib/bundler/plugin/index.rb +13 -1
  124. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  125. data/lib/bundler/plugin/installer.rb +11 -11
  126. data/lib/bundler/plugin/source_list.rb +5 -1
  127. data/lib/bundler/plugin.rb +56 -11
  128. data/lib/bundler/psyched_yaml.rb +0 -15
  129. data/lib/bundler/remote_specification.rb +5 -2
  130. data/lib/bundler/resolver/spec_group.rb +56 -53
  131. data/lib/bundler/resolver.rb +94 -128
  132. data/lib/bundler/retry.rb +2 -2
  133. data/lib/bundler/ruby_version.rb +1 -1
  134. data/lib/bundler/rubygems_ext.rb +96 -16
  135. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  136. data/lib/bundler/rubygems_integration.rb +57 -72
  137. data/lib/bundler/runtime.rb +22 -25
  138. data/lib/bundler/settings.rb +142 -64
  139. data/lib/bundler/setup.rb +2 -2
  140. data/lib/bundler/shared_helpers.rb +5 -13
  141. data/lib/bundler/similarity_detector.rb +1 -1
  142. data/lib/bundler/source/git/git_proxy.rb +88 -84
  143. data/lib/bundler/source/git.rb +43 -23
  144. data/lib/bundler/source/metadata.rb +0 -4
  145. data/lib/bundler/source/path/installer.rb +10 -10
  146. data/lib/bundler/source/path.rb +10 -4
  147. data/lib/bundler/source/rubygems/remote.rb +1 -1
  148. data/lib/bundler/source/rubygems.rb +126 -116
  149. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  150. data/lib/bundler/source.rb +22 -1
  151. data/lib/bundler/source_list.rb +101 -63
  152. data/lib/bundler/source_map.rb +58 -0
  153. data/lib/bundler/spec_set.rb +26 -41
  154. data/lib/bundler/stub_specification.rb +25 -7
  155. data/lib/bundler/templates/Executable.bundler +6 -6
  156. data/lib/bundler/templates/Gemfile +1 -1
  157. data/lib/bundler/templates/gems.rb +1 -1
  158. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  159. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  160. data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  161. data/lib/bundler/templates/newgem/README.md.tt +6 -5
  162. data/lib/bundler/templates/newgem/Rakefile.tt +23 -5
  163. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  164. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  165. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  166. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  167. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  168. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  169. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  170. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  171. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  172. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  173. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  174. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  175. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  176. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  177. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  178. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  179. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  180. data/lib/bundler/ui/shell.rb +5 -5
  181. data/lib/bundler/uri_credentials_filter.rb +3 -1
  182. data/lib/bundler/vendor/.document +1 -0
  183. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  184. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  185. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  186. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  187. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  188. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  189. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  190. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  191. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  192. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  193. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +36 -4
  194. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +3 -3
  195. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  196. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  197. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  198. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  199. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  200. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  201. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  202. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  203. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  204. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  205. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  206. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  207. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  208. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  209. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  210. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  211. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  212. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  213. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  214. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  215. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  216. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  217. data/lib/bundler/vendored_persistent.rb +0 -7
  218. data/lib/bundler/vendored_tmpdir.rb +4 -0
  219. data/lib/bundler/vendored_tsort.rb +4 -0
  220. data/lib/bundler/version.rb +1 -1
  221. data/lib/bundler/worker.rb +20 -5
  222. data/lib/bundler/yaml_serializer.rb +1 -1
  223. data/lib/bundler.rb +52 -37
  224. metadata +90 -89
  225. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  226. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  227. data/man/bundle-add.1.txt +0 -58
  228. data/man/bundle-binstubs.1.txt +0 -48
  229. data/man/bundle-cache.1.txt +0 -78
  230. data/man/bundle-check.1.txt +0 -33
  231. data/man/bundle-clean.1.txt +0 -26
  232. data/man/bundle-config.1.txt +0 -528
  233. data/man/bundle-doctor.1.txt +0 -44
  234. data/man/bundle-exec.1.txt +0 -178
  235. data/man/bundle-gem.1.txt +0 -91
  236. data/man/bundle-info.1.txt +0 -21
  237. data/man/bundle-init.1.txt +0 -34
  238. data/man/bundle-inject.1.txt +0 -32
  239. data/man/bundle-install.1.txt +0 -401
  240. data/man/bundle-list.1.txt +0 -43
  241. data/man/bundle-lock.1.txt +0 -93
  242. data/man/bundle-open.1.txt +0 -29
  243. data/man/bundle-outdated.1.txt +0 -131
  244. data/man/bundle-platform.1.txt +0 -57
  245. data/man/bundle-pristine.1.txt +0 -44
  246. data/man/bundle-remove.1.txt +0 -34
  247. data/man/bundle-show.1.txt +0 -27
  248. data/man/bundle-update.1.txt +0 -390
  249. data/man/bundle-viz.1.txt +0 -39
  250. data/man/bundle.1.txt +0 -116
  251. data/man/gemfile.5.txt +0 -649
@@ -120,8 +120,8 @@ Each _gem_ `MAY` have one or more version specifiers.
120
120
  ### REQUIRE AS
121
121
 
122
122
  Each _gem_ `MAY` specify files that should be used when autorequiring via
123
- `Bundler.require`. You may pass an array with multiple files or `true` if file
124
- you want `required` has same name as _gem_ or `false` to
123
+ `Bundler.require`. You may pass an array with multiple files or `true` if the file
124
+ you want `required` has the same name as _gem_ or `false` to
125
125
  prevent any file from being autorequired.
126
126
 
127
127
  gem "redis", :require => ["redis/connection/hiredis", "redis"]
@@ -163,8 +163,8 @@ not install with the `without` configuration.
163
163
 
164
164
  To specify multiple groups to ignore, specify a list of groups separated by spaces.
165
165
 
166
- bundle config set without test
167
- bundle config set without development test
166
+ bundle config set --local without test
167
+ bundle config set --local without development test
168
168
 
169
169
  Also, calling `Bundler.setup` with no parameters, or calling `require "bundler/setup"`
170
170
  will setup all groups except for the ones you excluded via `--without` (since they
@@ -372,6 +372,14 @@ Are both equivalent to
372
372
 
373
373
  Since the `github` method is a specialization of `git_source`, it accepts a `:branch` named argument.
374
374
 
375
+ You can also directly pass a pull request URL:
376
+
377
+ gem "rails", :github => "https://github.com/rails/rails/pull/43753"
378
+
379
+ Which is equivalent to:
380
+
381
+ gem "rails", :github => "rails/rails", branch: "refs/pull/43753/head"
382
+
375
383
  ### GIST
376
384
 
377
385
  If the git repository you want to use is hosted as a Github Gist and is public, you can use
File without changes
@@ -43,7 +43,7 @@ module Bundler
43
43
  config.update_mirror(mirror)
44
44
  end
45
45
 
46
- private
46
+ private
47
47
 
48
48
  def fetch_valid_mirror_for(uri)
49
49
  downcased = uri.to_s.downcase
@@ -158,7 +158,7 @@ module Bundler
158
158
  end
159
159
  end
160
160
 
161
- private
161
+ private
162
162
 
163
163
  def wait_for_writtable_socket(socket, address, timeout)
164
164
  if IO.select(nil, [socket], nil, timeout)
@@ -140,6 +140,13 @@ module Bundler
140
140
  end
141
141
  end
142
142
 
143
+ # Set internal representation to fetch the gems/specs locally.
144
+ #
145
+ # When this is called, the source should try to fetch the specs and
146
+ # install from the local system.
147
+ def local!
148
+ end
149
+
143
150
  # Set internal representation to fetch the gems/specs from remote.
144
151
  #
145
152
  # When this is called, the source should try to fetch the specs and
@@ -237,6 +244,20 @@ module Bundler
237
244
  specs.unmet_dependency_names
238
245
  end
239
246
 
247
+ # Used by definition.
248
+ #
249
+ # Note: Do not override if you don't know what you are doing.
250
+ def spec_names
251
+ specs.spec_names
252
+ end
253
+
254
+ # Used by definition.
255
+ #
256
+ # Note: Do not override if you don't know what you are doing.
257
+ def add_dependency_names(names)
258
+ @dependencies |= Array(names)
259
+ end
260
+
240
261
  # Note: Do not override if you don't know what you are doing.
241
262
  def can_lock?(spec)
242
263
  spec.source == self
@@ -260,8 +281,9 @@ module Bundler
260
281
  end
261
282
 
262
283
  def to_s
263
- "plugin source for #{options[:type]} with uri #{uri}"
284
+ "plugin source for #{@type} with uri #{@uri}"
264
285
  end
286
+ alias_method :identifier, :to_s
265
287
 
266
288
  # Note: Do not override if you don't know what you are doing.
267
289
  def include?(other)
@@ -10,7 +10,7 @@ module Bundler
10
10
  # So that we don't have to override all there methods to dummy ones
11
11
  # explicitly.
12
12
  # They will be handled by method_missing
13
- [:gemspec, :gem, :path, :install_if, :platforms, :env].each {|m| undef_method m }
13
+ [:gemspec, :gem, :install_if, :platforms, :env].each {|m| undef_method m }
14
14
 
15
15
  # This lists the plugins that was added automatically and not specified by
16
16
  # the user.
@@ -71,6 +71,18 @@ module Bundler
71
71
  raise
72
72
  end
73
73
 
74
+ def unregister_plugin(name)
75
+ @commands.delete_if {|_, v| v == name }
76
+ @sources.delete_if {|_, v| v == name }
77
+ @hooks.each do |hook, names|
78
+ names.delete(name)
79
+ @hooks.delete(hook) if names.empty?
80
+ end
81
+ @plugin_paths.delete(name)
82
+ @load_paths.delete(name)
83
+ save_index
84
+ end
85
+
74
86
  # Path of default index file
75
87
  def index_file
76
88
  Plugin.root.join("index")
@@ -124,7 +136,7 @@ module Bundler
124
136
  @hooks[event] || []
125
137
  end
126
138
 
127
- private
139
+ private
128
140
 
129
141
  # Reads the index file from the directory and initializes the instance
130
142
  # variables.
@@ -8,7 +8,7 @@ module Bundler
8
8
  "#{spec.name} #{spec.version}"
9
9
  end
10
10
 
11
- private
11
+ private
12
12
 
13
13
  def requires_sudo?
14
14
  false # Will change on implementation of project level plugins
@@ -16,15 +16,13 @@ module Bundler
16
16
 
17
17
  version = options[:version] || [">= 0"]
18
18
 
19
- Bundler.settings.temporary(:disable_multisource => false) do
20
- if options[:git]
21
- install_git(names, version, options)
22
- elsif options[:local_git]
23
- install_local_git(names, version, options)
24
- else
25
- sources = options[:source] || Bundler.rubygems.sources
26
- install_rubygems(names, version, sources)
27
- end
19
+ if options[:git]
20
+ install_git(names, version, options)
21
+ elsif options[:local_git]
22
+ install_local_git(names, version, options)
23
+ else
24
+ sources = options[:source] || Bundler.rubygems.sources
25
+ install_rubygems(names, version, sources)
28
26
  end
29
27
  end
30
28
 
@@ -41,7 +39,7 @@ module Bundler
41
39
  install_from_specs specs
42
40
  end
43
41
 
44
- private
42
+ private
45
43
 
46
44
  def check_sources_consistency!(options)
47
45
  if options.key?(:git) && options.key?(:local_git)
@@ -79,10 +77,12 @@ module Bundler
79
77
  source_list = SourceList.new
80
78
 
81
79
  source_list.add_git_source(git_source_options) if git_source_options
82
- source_list.add_rubygems_source("remotes" => rubygems_source) if rubygems_source
80
+ Array(rubygems_source).each {|remote| source_list.add_global_rubygems_remote(remote) } if rubygems_source
83
81
 
84
82
  deps = names.map {|name| Dependency.new name, version }
85
83
 
84
+ Bundler.configure_gem_home_and_path(Plugin.root)
85
+
86
86
  definition = Definition.new(nil, deps, source_list, true)
87
87
  install_definition(definition)
88
88
  end
@@ -17,7 +17,11 @@ module Bundler
17
17
  path_sources + git_sources + rubygems_sources + [metadata_source]
18
18
  end
19
19
 
20
- private
20
+ def default_source
21
+ git_sources.first || global_rubygems_source
22
+ end
23
+
24
+ private
21
25
 
22
26
  def rubygems_aggregate_class
23
27
  Plugin::Installer::Rubygems
@@ -13,10 +13,11 @@ module Bundler
13
13
  class MalformattedPlugin < PluginError; end
14
14
  class UndefinedCommandError < PluginError; end
15
15
  class UnknownSourceError < PluginError; end
16
+ class PluginInstallError < PluginError; end
16
17
 
17
18
  PLUGIN_FILE_NAME = "plugins.rb".freeze
18
19
 
19
- module_function
20
+ module_function
20
21
 
21
22
  def reset!
22
23
  instance_variables.each {|i| remove_instance_variable(i) }
@@ -38,13 +39,37 @@ module Bundler
38
39
  specs = Installer.new.install(names, options)
39
40
 
40
41
  save_plugins names, specs
41
- rescue PluginError => e
42
- if specs
43
- specs_to_delete = Hash[specs.select {|k, _v| names.include?(k) && !index.commands.values.include?(k) }]
44
- specs_to_delete.values.each {|spec| Bundler.rm_rf(spec.full_gem_path) }
42
+ rescue PluginError
43
+ specs_to_delete = specs.select {|k, _v| names.include?(k) && !index.commands.values.include?(k) }
44
+ specs_to_delete.each_value {|spec| Bundler.rm_rf(spec.full_gem_path) }
45
+
46
+ raise
47
+ end
48
+
49
+ # Uninstalls plugins by the given names
50
+ #
51
+ # @param [Array<String>] names the names of plugins to be uninstalled
52
+ def uninstall(names, options)
53
+ if names.empty? && !options[:all]
54
+ Bundler.ui.error "No plugins to uninstall. Specify at least 1 plugin to uninstall.\n"\
55
+ "Use --all option to uninstall all the installed plugins."
56
+ return
45
57
  end
46
58
 
47
- Bundler.ui.error "Failed to install plugin #{name}: #{e.message}\n #{e.backtrace.join("\n ")}"
59
+ names = index.installed_plugins if options[:all]
60
+ if names.any?
61
+ names.each do |name|
62
+ if index.installed?(name)
63
+ Bundler.rm_rf(index.plugin_path(name))
64
+ index.unregister_plugin(name)
65
+ Bundler.ui.info "Uninstalled plugin #{name}"
66
+ else
67
+ Bundler.ui.error "Plugin #{name} is not installed \n"
68
+ end
69
+ end
70
+ else
71
+ Bundler.ui.info "No plugins installed"
72
+ end
48
73
  end
49
74
 
50
75
  # List installed plugins and commands
@@ -80,6 +105,7 @@ module Bundler
80
105
  else
81
106
  builder.eval_gemfile(gemfile)
82
107
  end
108
+ builder.check_primary_source_safety
83
109
  definition = builder.to_definition(nil, true)
84
110
 
85
111
  return if definition.dependencies.empty?
@@ -138,7 +164,7 @@ module Bundler
138
164
  end
139
165
 
140
166
  # To be called from Cli class to pass the command and argument to
141
- # approriate plugin class
167
+ # appropriate plugin class
142
168
  def exec_command(command, args)
143
169
  raise UndefinedCommandError, "Command `#{command}` not found" unless command? command
144
170
 
@@ -157,7 +183,7 @@ module Bundler
157
183
  !index.source_plugin(name.to_s).nil?
158
184
  end
159
185
 
160
- # @return [Class] that handles the source. The calss includes API::Source
186
+ # @return [Class] that handles the source. The class includes API::Source
161
187
  def source(name)
162
188
  raise UnknownSourceError, "Source #{name} not found" unless source? name
163
189
 
@@ -219,10 +245,11 @@ module Bundler
219
245
  # @param [Array<String>] names of inferred source plugins that can be ignored
220
246
  def save_plugins(plugins, specs, optional_plugins = [])
221
247
  plugins.each do |name|
248
+ next if index.installed?(name)
249
+
222
250
  spec = specs[name]
223
- validate_plugin! Pathname.new(spec.full_gem_path)
224
- installed = register_plugin(name, spec, optional_plugins.include?(name))
225
- Bundler.ui.info "Installed plugin #{name}" if installed
251
+
252
+ save_plugin(name, spec, optional_plugins.include?(name))
226
253
  end
227
254
  end
228
255
 
@@ -237,6 +264,22 @@ module Bundler
237
264
  raise MalformattedPlugin, "#{PLUGIN_FILE_NAME} was not found in the plugin." unless plugin_file.file?
238
265
  end
239
266
 
267
+ # Validates and registers a plugin.
268
+ #
269
+ # @param [String] name the name of the plugin
270
+ # @param [Specification] spec of installed plugin
271
+ # @param [Boolean] optional_plugin, removed if there is conflict with any
272
+ # other plugin (used for default source plugins)
273
+ #
274
+ # @raise [PluginInstallError] if validation or registration raises any error
275
+ def save_plugin(name, spec, optional_plugin = false)
276
+ validate_plugin! Pathname.new(spec.full_gem_path)
277
+ installed = register_plugin(name, spec, optional_plugin)
278
+ Bundler.ui.info "Installed plugin #{name}" if installed
279
+ rescue PluginError => e
280
+ raise PluginInstallError, "Failed to install plugin `#{spec.name}`, due to #{e.class} (#{e.message})"
281
+ end
282
+
240
283
  # Runs the plugins.rb file in an isolated namespace, records the plugin
241
284
  # actions it registers for and then passes the data to index to be stored.
242
285
  #
@@ -283,6 +326,8 @@ module Bundler
283
326
  #
284
327
  # @param [String] name of the plugin
285
328
  def load_plugin(name)
329
+ return unless name && !name.empty?
330
+
286
331
  # Need to ensure before this that plugin root where the rest of gems
287
332
  # are installed to be on load path to support plugin deps. Currently not
288
333
  # done to avoid conflicts
@@ -1,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Psych could be a gem, so try to ask for it
4
- begin
5
- gem "psych"
6
- rescue LoadError
7
- end if defined?(gem)
8
-
9
3
  # Psych could be in the stdlib
10
4
  # but it's too late if Syck is already loaded
11
5
  begin
@@ -26,12 +20,3 @@ module Bundler
26
20
  YamlLibrarySyntaxError = ::ArgumentError
27
21
  end
28
22
  end
29
-
30
- require_relative "deprecate"
31
- begin
32
- Bundler::Deprecate.skip_during do
33
- require "rubygems/safe_yaml"
34
- end
35
- rescue LoadError
36
- # it's OK if the file isn't there
37
- end
@@ -50,6 +50,8 @@ module Bundler
50
50
  # once the remote gem is downloaded, the backend specification will
51
51
  # be swapped out.
52
52
  def __swap__(spec)
53
+ raise APIResponseInvalidDependenciesError unless spec.dependencies.all? {|d| d.is_a?(Gem::Dependency) }
54
+
53
55
  SharedHelpers.ensure_same_dependencies(self, dependencies, spec.dependencies)
54
56
  @_remote_specification = spec
55
57
  end
@@ -76,7 +78,8 @@ module Bundler
76
78
  deps = method_missing(:dependencies)
77
79
 
78
80
  # allow us to handle when the specs dependencies are an array of array of string
79
- # see https://github.com/bundler/bundler/issues/5797
81
+ # in order to delay the crash to `#__swap__` where it results in a friendlier error
82
+ # see https://github.com/rubygems/bundler/issues/5797
80
83
  deps = deps.map {|d| d.is_a?(Gem::Dependency) ? d : Gem::Dependency.new(*d) }
81
84
 
82
85
  deps
@@ -88,7 +91,7 @@ module Bundler
88
91
  " #{source.revision[0..6]}"
89
92
  end
90
93
 
91
- private
94
+ private
92
95
 
93
96
  def to_ary
94
97
  nil
@@ -3,61 +3,58 @@
3
3
  module Bundler
4
4
  class Resolver
5
5
  class SpecGroup
6
- include GemHelpers
7
-
8
6
  attr_accessor :name, :version, :source
9
- attr_accessor :ignores_bundler_dependencies
7
+ attr_accessor :activated_platforms
8
+
9
+ def self.create_for(specs, all_platforms, specific_platform)
10
+ specific_platform_specs = specs[specific_platform]
11
+ return unless specific_platform_specs.any?
12
+
13
+ platforms = all_platforms.select {|p| specs[p].any? }
14
+
15
+ new(specific_platform_specs.first, specs, platforms)
16
+ end
10
17
 
11
- def initialize(all_specs)
12
- raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
18
+ def initialize(exemplary_spec, specs, relevant_platforms)
19
+ @exemplary_spec = exemplary_spec
13
20
  @name = exemplary_spec.name
14
21
  @version = exemplary_spec.version
15
22
  @source = exemplary_spec.source
16
23
 
17
- @activated_platforms = []
18
- @dependencies = nil
19
- @specs = Hash.new do |specs, platform|
20
- specs[platform] = select_best_platform_match(all_specs, platform)
24
+ @activated_platforms = relevant_platforms
25
+ @dependencies = Hash.new do |dependencies, platforms|
26
+ dependencies[platforms] = dependencies_for(platforms)
21
27
  end
22
- @ignores_bundler_dependencies = true
28
+ @specs = specs
23
29
  end
24
30
 
25
31
  def to_specs
26
- @activated_platforms.map do |p|
27
- next unless s = @specs[p]
28
- lazy_spec = LazySpecification.new(name, version, s.platform, source)
29
- lazy_spec.dependencies.replace s.dependencies
30
- lazy_spec
31
- end.compact
32
- end
33
-
34
- def activate_platform!(platform)
35
- return unless for?(platform)
36
- return if @activated_platforms.include?(platform)
37
- @activated_platforms << platform
38
- end
32
+ activated_platforms.map do |p|
33
+ specs = @specs[p]
34
+ next unless specs.any?
39
35
 
40
- def for?(platform)
41
- spec = @specs[platform]
42
- !spec.nil?
36
+ specs.map do |s|
37
+ lazy_spec = LazySpecification.new(name, version, s.platform, source)
38
+ lazy_spec.dependencies.replace s.dependencies
39
+ lazy_spec
40
+ end
41
+ end.flatten.compact.uniq
43
42
  end
44
43
 
45
44
  def to_s
46
- @to_s ||= "#{name} (#{version})"
45
+ activated_platforms_string = sorted_activated_platforms.join(", ")
46
+ "#{name} (#{version}) (#{activated_platforms_string})"
47
47
  end
48
48
 
49
49
  def dependencies_for_activated_platforms
50
- dependencies = @activated_platforms.map {|p| __dependencies[p] }
51
- metadata_dependencies = @activated_platforms.map do |platform|
52
- metadata_dependencies(@specs[platform], platform)
53
- end
54
- dependencies.concat(metadata_dependencies).flatten
50
+ @dependencies[activated_platforms]
55
51
  end
56
52
 
57
53
  def ==(other)
58
54
  return unless other.is_a?(SpecGroup)
59
55
  name == other.name &&
60
56
  version == other.version &&
57
+ sorted_activated_platforms == other.sorted_activated_platforms &&
61
58
  source == other.source
62
59
  end
63
60
 
@@ -65,40 +62,46 @@ module Bundler
65
62
  return unless other.is_a?(SpecGroup)
66
63
  name.eql?(other.name) &&
67
64
  version.eql?(other.version) &&
65
+ sorted_activated_platforms.eql?(other.sorted_activated_platforms) &&
68
66
  source.eql?(other.source)
69
67
  end
70
68
 
71
69
  def hash
72
- to_s.hash ^ source.hash
70
+ name.hash ^ version.hash ^ sorted_activated_platforms.hash ^ source.hash
73
71
  end
74
72
 
75
- private
76
-
77
- def __dependencies
78
- @dependencies = Hash.new do |dependencies, platform|
79
- dependencies[platform] = []
80
- if spec = @specs[platform]
81
- spec.dependencies.each do |dep|
82
- next if dep.type == :development
83
- next if @ignores_bundler_dependencies && dep.name == "bundler".freeze
84
- dependencies[platform] << DepProxy.new(dep, platform)
85
- end
86
- end
87
- dependencies[platform]
73
+ protected
74
+
75
+ def sorted_activated_platforms
76
+ activated_platforms.sort_by(&:to_s)
77
+ end
78
+
79
+ private
80
+
81
+ def dependencies_for(platforms)
82
+ platforms.map do |platform|
83
+ __dependencies(platform) + metadata_dependencies(platform)
84
+ end.flatten
85
+ end
86
+
87
+ def __dependencies(platform)
88
+ dependencies = []
89
+ @specs[platform].first.dependencies.each do |dep|
90
+ next if dep.type == :development
91
+ dependencies << DepProxy.get_proxy(dep, platform)
88
92
  end
93
+ dependencies
89
94
  end
90
95
 
91
- def metadata_dependencies(spec, platform)
92
- return [] unless spec
93
- # Only allow endpoint specifications since they won't hit the network to
94
- # fetch the full gemspec when calling required_ruby_version
95
- return [] if !spec.is_a?(EndpointSpecification) && !spec.is_a?(Gem::Specification)
96
+ def metadata_dependencies(platform)
97
+ spec = @specs[platform].first
98
+ return [] unless spec.is_a?(Gem::Specification)
96
99
  dependencies = []
97
100
  if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
98
- dependencies << DepProxy.new(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
101
+ dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
99
102
  end
100
103
  if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
101
- dependencies << DepProxy.new(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
104
+ dependencies << DepProxy.get_proxy(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
102
105
  end
103
106
  dependencies
104
107
  end