bundler 1.13.6 → 1.17.3

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 (323) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +554 -9
  3. data/README.md +28 -5
  4. data/bundler.gemspec +40 -11
  5. data/exe/bundle +4 -8
  6. data/exe/bundle_ruby +4 -3
  7. data/lib/bundler.rb +162 -68
  8. data/lib/bundler/build_metadata.rb +53 -0
  9. data/lib/bundler/capistrano.rb +5 -0
  10. data/lib/bundler/cli.rb +360 -118
  11. data/lib/bundler/cli/add.rb +35 -0
  12. data/lib/bundler/cli/binstubs.rb +18 -10
  13. data/lib/bundler/cli/cache.rb +6 -5
  14. data/lib/bundler/cli/check.rb +4 -6
  15. data/lib/bundler/cli/clean.rb +6 -7
  16. data/lib/bundler/cli/common.rb +47 -1
  17. data/lib/bundler/cli/config.rb +26 -7
  18. data/lib/bundler/cli/console.rb +2 -1
  19. data/lib/bundler/cli/doctor.rb +63 -18
  20. data/lib/bundler/cli/exec.rb +12 -5
  21. data/lib/bundler/cli/gem.rb +59 -21
  22. data/lib/bundler/cli/info.rb +50 -0
  23. data/lib/bundler/cli/init.rb +21 -7
  24. data/lib/bundler/cli/inject.rb +13 -4
  25. data/lib/bundler/cli/install.rb +72 -101
  26. data/lib/bundler/cli/issue.rb +40 -0
  27. data/lib/bundler/cli/list.rb +58 -0
  28. data/lib/bundler/cli/lock.rb +9 -6
  29. data/lib/bundler/cli/open.rb +4 -3
  30. data/lib/bundler/cli/outdated.rb +175 -60
  31. data/lib/bundler/cli/package.rb +9 -6
  32. data/lib/bundler/cli/platform.rb +2 -1
  33. data/lib/bundler/cli/plugin.rb +1 -0
  34. data/lib/bundler/cli/pristine.rb +47 -0
  35. data/lib/bundler/cli/remove.rb +18 -0
  36. data/lib/bundler/cli/show.rb +2 -2
  37. data/lib/bundler/cli/update.rb +44 -34
  38. data/lib/bundler/cli/viz.rb +5 -1
  39. data/lib/bundler/compact_index_client.rb +109 -0
  40. data/lib/bundler/compact_index_client/cache.rb +118 -0
  41. data/lib/bundler/compact_index_client/updater.rb +116 -0
  42. data/lib/bundler/compatibility_guard.rb +14 -0
  43. data/lib/bundler/constants.rb +1 -0
  44. data/lib/bundler/current_ruby.rb +17 -8
  45. data/lib/bundler/definition.rb +353 -182
  46. data/lib/bundler/dep_proxy.rb +3 -1
  47. data/lib/bundler/dependency.rb +22 -10
  48. data/lib/bundler/deployment.rb +1 -1
  49. data/lib/bundler/deprecate.rb +15 -3
  50. data/lib/bundler/dsl.rb +122 -64
  51. data/lib/bundler/endpoint_specification.rb +13 -3
  52. data/lib/bundler/env.rb +110 -38
  53. data/lib/bundler/environment_preserver.rb +27 -6
  54. data/lib/bundler/errors.rb +24 -0
  55. data/lib/bundler/feature_flag.rb +74 -0
  56. data/lib/bundler/fetcher.rb +18 -11
  57. data/lib/bundler/fetcher/base.rb +1 -0
  58. data/lib/bundler/fetcher/compact_index.rb +7 -5
  59. data/lib/bundler/fetcher/dependency.rb +3 -2
  60. data/lib/bundler/fetcher/downloader.rb +25 -7
  61. data/lib/bundler/fetcher/index.rb +3 -2
  62. data/lib/bundler/friendly_errors.rb +33 -7
  63. data/lib/bundler/gem_helper.rb +25 -11
  64. data/lib/bundler/gem_helpers.rb +70 -1
  65. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  66. data/lib/bundler/gem_tasks.rb +1 -0
  67. data/lib/bundler/gem_version_promoter.rb +17 -2
  68. data/lib/bundler/gemdeps.rb +29 -0
  69. data/lib/bundler/graph.rb +1 -0
  70. data/lib/bundler/index.rb +28 -15
  71. data/lib/bundler/injector.rb +216 -33
  72. data/lib/bundler/inline.rb +12 -12
  73. data/lib/bundler/installer.rb +139 -53
  74. data/lib/bundler/installer/gem_installer.rb +15 -5
  75. data/lib/bundler/installer/parallel_installer.rb +113 -28
  76. data/lib/bundler/installer/standalone.rb +1 -0
  77. data/lib/bundler/lazy_specification.rb +31 -3
  78. data/lib/bundler/lockfile_generator.rb +95 -0
  79. data/lib/bundler/lockfile_parser.rb +50 -37
  80. data/lib/bundler/match_platform.rb +13 -3
  81. data/lib/bundler/mirror.rb +10 -5
  82. data/lib/bundler/plugin.rb +22 -8
  83. data/lib/bundler/plugin/api.rb +2 -1
  84. data/lib/bundler/plugin/api/source.rb +17 -4
  85. data/lib/bundler/plugin/events.rb +61 -0
  86. data/lib/bundler/plugin/index.rb +9 -2
  87. data/lib/bundler/plugin/installer.rb +7 -6
  88. data/lib/bundler/plugin/source_list.rb +7 -8
  89. data/lib/bundler/process_lock.rb +24 -0
  90. data/lib/bundler/psyched_yaml.rb +10 -0
  91. data/lib/bundler/remote_specification.rb +30 -1
  92. data/lib/bundler/resolver.rb +187 -194
  93. data/lib/bundler/resolver/spec_group.rb +106 -0
  94. data/lib/bundler/retry.rb +5 -1
  95. data/lib/bundler/ruby_dsl.rb +1 -0
  96. data/lib/bundler/ruby_version.rb +12 -2
  97. data/lib/bundler/rubygems_ext.rb +23 -8
  98. data/lib/bundler/rubygems_gem_installer.rb +90 -0
  99. data/lib/bundler/rubygems_integration.rb +193 -70
  100. data/lib/bundler/runtime.rb +39 -22
  101. data/lib/bundler/settings.rb +245 -85
  102. data/lib/bundler/settings/validator.rb +102 -0
  103. data/lib/bundler/setup.rb +4 -7
  104. data/lib/bundler/shared_helpers.rb +183 -40
  105. data/lib/bundler/similarity_detector.rb +1 -0
  106. data/lib/bundler/source.rb +58 -1
  107. data/lib/bundler/source/gemspec.rb +1 -0
  108. data/lib/bundler/source/git.rb +52 -23
  109. data/lib/bundler/source/git/git_proxy.rb +30 -14
  110. data/lib/bundler/source/metadata.rb +62 -0
  111. data/lib/bundler/source/path.rb +42 -16
  112. data/lib/bundler/source/path/installer.rb +4 -2
  113. data/lib/bundler/source/rubygems.rb +171 -82
  114. data/lib/bundler/source/rubygems/remote.rb +12 -2
  115. data/lib/bundler/source_list.rb +75 -15
  116. data/lib/bundler/spec_set.rb +67 -32
  117. data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  118. data/lib/bundler/stub_specification.rb +86 -2
  119. data/lib/bundler/templates/.document +1 -0
  120. data/lib/bundler/templates/Executable +13 -1
  121. data/lib/bundler/templates/Executable.bundler +105 -0
  122. data/lib/bundler/templates/Executable.standalone +5 -5
  123. data/lib/bundler/templates/Gemfile +3 -0
  124. data/lib/bundler/templates/gems.rb +8 -0
  125. data/lib/bundler/templates/newgem/Gemfile.tt +4 -2
  126. data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
  127. data/lib/bundler/templates/newgem/README.md.tt +14 -8
  128. data/lib/bundler/templates/newgem/Rakefile.tt +5 -5
  129. data/lib/bundler/templates/newgem/bin/console.tt +1 -1
  130. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
  131. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
  132. data/lib/bundler/templates/newgem/gitignore.tt +5 -1
  133. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -6
  134. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
  135. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -12
  136. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  137. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -3
  138. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +13 -1
  139. data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +1 -1
  140. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +3 -3
  141. data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
  142. data/lib/bundler/ui.rb +1 -0
  143. data/lib/bundler/ui/rg_proxy.rb +1 -0
  144. data/lib/bundler/ui/shell.rb +30 -10
  145. data/lib/bundler/ui/silent.rb +21 -1
  146. data/lib/bundler/uri_credentials_filter.rb +1 -0
  147. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  148. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  149. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  150. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  151. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  152. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +26 -6
  153. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +2 -1
  154. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +12 -4
  155. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +3 -2
  156. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
  157. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +11 -3
  158. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +13 -1
  159. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +3 -2
  160. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +3 -2
  161. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +18 -5
  162. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
  163. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  164. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  165. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  166. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +499 -128
  167. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  168. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  169. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/faster.rb +1 -0
  170. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +27 -24
  171. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent/ssl_reuse.rb +2 -1
  172. data/lib/bundler/vendor/thor/lib/thor.rb +46 -21
  173. data/lib/bundler/vendor/thor/lib/thor/actions.rb +24 -22
  174. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +2 -1
  175. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  176. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +2 -2
  177. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
  178. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +66 -18
  179. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +17 -15
  180. data/lib/bundler/vendor/thor/lib/thor/base.rb +55 -32
  181. data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -11
  182. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
  183. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +7 -5
  184. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +94 -63
  185. data/lib/bundler/vendor/thor/lib/thor/error.rb +3 -3
  186. data/lib/bundler/vendor/thor/lib/thor/group.rb +13 -13
  187. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +4 -5
  188. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  189. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
  190. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +16 -16
  191. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +42 -21
  192. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -10
  193. data/lib/bundler/vendor/thor/lib/thor/runner.rb +31 -29
  194. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  195. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +49 -33
  196. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
  197. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -4
  198. data/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  199. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  200. data/lib/bundler/vendored_fileutils.rb +9 -0
  201. data/lib/bundler/vendored_molinillo.rb +1 -0
  202. data/lib/bundler/vendored_persistent.rb +43 -3
  203. data/lib/bundler/vendored_thor.rb +6 -2
  204. data/lib/bundler/version.rb +19 -2
  205. data/lib/bundler/version_ranges.rb +76 -0
  206. data/lib/bundler/vlad.rb +5 -0
  207. data/lib/bundler/worker.rb +30 -6
  208. data/lib/bundler/yaml_serializer.rb +4 -4
  209. data/man/bundle-add.1 +58 -0
  210. data/man/bundle-add.1.txt +52 -0
  211. data/man/bundle-add.ronn +40 -0
  212. data/{lib/bundler/man/bundle-binstubs → man/bundle-binstubs.1} +11 -1
  213. data/man/bundle-binstubs.1.txt +48 -0
  214. data/man/bundle-binstubs.ronn +15 -1
  215. data/man/bundle-check.1 +31 -0
  216. data/man/bundle-check.1.txt +33 -0
  217. data/man/bundle-check.ronn +26 -0
  218. data/man/bundle-clean.1 +24 -0
  219. data/man/bundle-clean.1.txt +26 -0
  220. data/man/bundle-clean.ronn +18 -0
  221. data/man/bundle-config.1 +497 -0
  222. data/man/bundle-config.1.txt +529 -0
  223. data/man/bundle-config.ronn +233 -61
  224. data/man/bundle-doctor.1 +44 -0
  225. data/man/bundle-doctor.1.txt +44 -0
  226. data/man/bundle-doctor.ronn +33 -0
  227. data/{lib/bundler/man/bundle-exec → man/bundle-exec.1} +6 -3
  228. data/man/bundle-exec.1.txt +178 -0
  229. data/man/bundle-exec.ronn +10 -3
  230. data/{lib/bundler/man/bundle-gem → man/bundle-gem.1} +4 -4
  231. data/man/bundle-gem.1.txt +91 -0
  232. data/man/bundle-gem.ronn +3 -2
  233. data/man/bundle-info.1 +20 -0
  234. data/man/bundle-info.1.txt +21 -0
  235. data/man/bundle-info.ronn +17 -0
  236. data/man/bundle-init.1 +25 -0
  237. data/man/bundle-init.1.txt +34 -0
  238. data/man/bundle-init.ronn +29 -0
  239. data/man/bundle-inject.1 +33 -0
  240. data/man/bundle-inject.1.txt +32 -0
  241. data/man/bundle-inject.ronn +22 -0
  242. data/{lib/bundler/man/bundle-install → man/bundle-install.1} +32 -29
  243. data/man/bundle-install.1.txt +396 -0
  244. data/man/bundle-install.ronn +45 -36
  245. data/man/bundle-list.1 +50 -0
  246. data/man/bundle-list.1.txt +43 -0
  247. data/man/bundle-list.ronn +33 -0
  248. data/{lib/bundler/man/bundle-lock → man/bundle-lock.1} +43 -2
  249. data/man/bundle-lock.1.txt +93 -0
  250. data/man/bundle-lock.ronn +47 -0
  251. data/man/bundle-open.1 +32 -0
  252. data/man/bundle-open.1.txt +29 -0
  253. data/man/bundle-open.ronn +19 -0
  254. data/man/bundle-outdated.1 +155 -0
  255. data/man/bundle-outdated.1.txt +131 -0
  256. data/man/bundle-outdated.ronn +111 -0
  257. data/{lib/bundler/man/bundle-package → man/bundle-package.1} +6 -3
  258. data/man/bundle-package.1.txt +79 -0
  259. data/man/bundle-package.ronn +7 -2
  260. data/{lib/bundler/man/bundle-platform → man/bundle-platform.1} +1 -1
  261. data/man/bundle-platform.1.txt +57 -0
  262. data/man/bundle-pristine.1 +34 -0
  263. data/man/bundle-pristine.1.txt +44 -0
  264. data/man/bundle-pristine.ronn +34 -0
  265. data/man/bundle-remove.1 +31 -0
  266. data/man/bundle-remove.1.txt +34 -0
  267. data/man/bundle-remove.ronn +23 -0
  268. data/man/bundle-show.1 +23 -0
  269. data/man/bundle-show.1.txt +27 -0
  270. data/man/bundle-show.ronn +21 -0
  271. data/man/bundle-update.1 +394 -0
  272. data/man/bundle-update.1.txt +391 -0
  273. data/man/bundle-update.ronn +172 -16
  274. data/man/bundle-viz.1 +39 -0
  275. data/man/bundle-viz.1.txt +39 -0
  276. data/man/bundle-viz.ronn +30 -0
  277. data/{lib/bundler/man/bundle → man/bundle.1} +44 -28
  278. data/man/bundle.1.txt +116 -0
  279. data/man/bundle.ronn +39 -27
  280. data/{lib/bundler/man → man}/gemfile.5 +67 -84
  281. data/man/gemfile.5.ronn +77 -55
  282. data/man/gemfile.5.txt +653 -0
  283. data/man/index.txt +25 -8
  284. metadata +118 -58
  285. data/.codeclimate.yml +0 -25
  286. data/.gitignore +0 -16
  287. data/.rspec +0 -3
  288. data/.rubocop.yml +0 -128
  289. data/.rubocop_todo.yml +0 -248
  290. data/.travis.yml +0 -108
  291. data/CODE_OF_CONDUCT.md +0 -42
  292. data/CONTRIBUTING.md +0 -36
  293. data/DEVELOPMENT.md +0 -148
  294. data/ISSUES.md +0 -100
  295. data/Rakefile +0 -333
  296. data/bin/rake +0 -19
  297. data/bin/rspec +0 -15
  298. data/bin/rubocop +0 -17
  299. data/bin/with_rubygems +0 -39
  300. data/lib/bundler/man/bundle-binstubs.txt +0 -33
  301. data/lib/bundler/man/bundle-config +0 -254
  302. data/lib/bundler/man/bundle-config.txt +0 -282
  303. data/lib/bundler/man/bundle-exec.txt +0 -171
  304. data/lib/bundler/man/bundle-gem.txt +0 -90
  305. data/lib/bundler/man/bundle-install.txt +0 -385
  306. data/lib/bundler/man/bundle-lock.txt +0 -52
  307. data/lib/bundler/man/bundle-package.txt +0 -74
  308. data/lib/bundler/man/bundle-platform.txt +0 -57
  309. data/lib/bundler/man/bundle-update +0 -221
  310. data/lib/bundler/man/bundle-update.txt +0 -227
  311. data/lib/bundler/man/bundle.txt +0 -104
  312. data/lib/bundler/man/gemfile.5.txt +0 -636
  313. data/lib/bundler/postit_trampoline.rb +0 -68
  314. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +0 -79
  315. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +0 -112
  316. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +0 -80
  317. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +0 -4
  318. data/lib/bundler/vendor/postit/lib/postit.rb +0 -15
  319. data/lib/bundler/vendor/postit/lib/postit/environment.rb +0 -44
  320. data/lib/bundler/vendor/postit/lib/postit/installer.rb +0 -28
  321. data/lib/bundler/vendor/postit/lib/postit/parser.rb +0 -21
  322. data/lib/bundler/vendor/postit/lib/postit/setup.rb +0 -12
  323. data/lib/bundler/vendor/postit/lib/postit/version.rb +0 -3
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Resolver
5
+ class SpecGroup
6
+ include GemHelpers
7
+
8
+ attr_accessor :name, :version, :source
9
+ attr_accessor :ignores_bundler_dependencies
10
+
11
+ def initialize(all_specs)
12
+ raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
13
+ @name = exemplary_spec.name
14
+ @version = exemplary_spec.version
15
+ @source = exemplary_spec.source
16
+
17
+ @activated_platforms = []
18
+ @dependencies = nil
19
+ @specs = Hash.new do |specs, platform|
20
+ specs[platform] = select_best_platform_match(all_specs, platform)
21
+ end
22
+ @ignores_bundler_dependencies = true
23
+ end
24
+
25
+ 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
39
+
40
+ def for?(platform)
41
+ spec = @specs[platform]
42
+ !spec.nil?
43
+ end
44
+
45
+ def to_s
46
+ @to_s ||= "#{name} (#{version})"
47
+ end
48
+
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
55
+ end
56
+
57
+ def ==(other)
58
+ return unless other.is_a?(SpecGroup)
59
+ name == other.name &&
60
+ version == other.version &&
61
+ source == other.source
62
+ end
63
+
64
+ def eql?(other)
65
+ name.eql?(other.name) &&
66
+ version.eql?(other.version) &&
67
+ source.eql?(other.source)
68
+ end
69
+
70
+ def hash
71
+ to_s.hash ^ source.hash
72
+ end
73
+
74
+ private
75
+
76
+ def __dependencies
77
+ @dependencies = Hash.new do |dependencies, platform|
78
+ dependencies[platform] = []
79
+ if spec = @specs[platform]
80
+ spec.dependencies.each do |dep|
81
+ next if dep.type == :development
82
+ next if @ignores_bundler_dependencies && dep.name == "bundler".freeze
83
+ dependencies[platform] << DepProxy.new(dep, platform)
84
+ end
85
+ end
86
+ dependencies[platform]
87
+ end
88
+ end
89
+
90
+ def metadata_dependencies(spec, platform)
91
+ return [] unless spec
92
+ # Only allow endpoint specifications since they won't hit the network to
93
+ # fetch the full gemspec when calling required_ruby_version
94
+ return [] if !spec.is_a?(EndpointSpecification) && !spec.is_a?(Gem::Specification)
95
+ dependencies = []
96
+ if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
97
+ dependencies << DepProxy.new(Gem::Dependency.new("ruby\0", spec.required_ruby_version), platform)
98
+ end
99
+ if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
100
+ dependencies << DepProxy.new(Gem::Dependency.new("rubygems\0", spec.required_rubygems_version), platform)
101
+ end
102
+ dependencies
103
+ end
104
+ end
105
+ end
106
+ end
data/lib/bundler/retry.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  # General purpose class for retrying code that may fail
4
5
  class Retry
@@ -43,7 +44,10 @@ module Bundler
43
44
 
44
45
  def fail_attempt(e)
45
46
  @failed = true
46
- raise e if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
47
+ if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
48
+ Bundler.ui.info "" unless Bundler.ui.debug?
49
+ raise e
50
+ end
47
51
  return true unless name
48
52
  Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this
49
53
  Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  module RubyDsl
4
5
  def ruby(*ruby_version)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class RubyVersion
4
5
  attr_reader :versions,
@@ -21,7 +22,11 @@ module Bundler
21
22
  # must not be specified, or the engine version
22
23
  # specified must match the version.
23
24
 
24
- @versions = Array(versions)
25
+ @versions = Array(versions).map do |v|
26
+ op, v = Gem::Requirement.parse(v)
27
+ op == "=" ? v.to_s : "#{op} #{v}"
28
+ end
29
+
25
30
  @gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
26
31
  @input_engine = engine && engine.to_s
27
32
  @engine = engine && engine.to_s || "ruby"
@@ -113,7 +118,7 @@ module Bundler
113
118
  when "jruby"
114
119
  JRUBY_VERSION.dup
115
120
  else
116
- raise BundlerError, "RUBY_ENGINE value #{RUBY_ENGINE} is not recognized"
121
+ RUBY_ENGINE_VERSION.dup
117
122
  end
118
123
  patchlevel = RUBY_PATCHLEVEL.to_s
119
124
 
@@ -128,6 +133,11 @@ module Bundler
128
133
  end
129
134
  end
130
135
 
136
+ def exact?
137
+ return @exact if defined?(@exact)
138
+ @exact = versions.all? {|v| Gem::Requirement.create(v).exact? }
139
+ end
140
+
131
141
  private
132
142
 
133
143
  def matches?(requirements, version)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "pathname"
3
4
 
4
5
  if defined?(Gem::QuickLoader)
@@ -14,7 +15,7 @@ begin
14
15
  # shouldn't be deferred.
15
16
  require "rubygems/source"
16
17
  rescue LoadError
17
- # Not available before Rubygems 2.0.0, ignore
18
+ # Not available before RubyGems 2.0.0, ignore
18
19
  nil
19
20
  end
20
21
 
@@ -42,7 +43,11 @@ module Gem
42
43
  attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
43
44
 
44
45
  def full_gem_path
45
- if source.respond_to?(:path) || source.is_a?(Bundler::Plugin::API::Source)
46
+ # this cannot check source.is_a?(Bundler::Plugin::API::Source)
47
+ # because that _could_ trip the autoload, and if there are unresolved
48
+ # gems at that time, this method could be called inside another require,
49
+ # thus raising with that constant being undefined. Better to check a method
50
+ if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?)
46
51
  Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.untaint
47
52
  else
48
53
  rg_full_gem_path
@@ -131,7 +136,7 @@ module Gem
131
136
  end
132
137
 
133
138
  class Dependency
134
- attr_accessor :source, :groups
139
+ attr_accessor :source, :groups, :all_sources
135
140
 
136
141
  alias_method :eql?, :==
137
142
 
@@ -142,19 +147,19 @@ module Gem
142
147
  end
143
148
 
144
149
  def to_yaml_properties
145
- instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
150
+ instance_variables.reject {|p| ["@source", "@groups", "@all_sources"].include?(p.to_s) }
146
151
  end
147
152
 
148
153
  def to_lock
149
154
  out = String.new(" #{name}")
150
- unless requirement == Gem::Requirement.default
155
+ unless requirement.none?
151
156
  reqs = requirement.requirements.map {|o, v| "#{o} #{v}" }.sort.reverse
152
157
  out << " (#{reqs.join(", ")})"
153
158
  end
154
159
  out
155
160
  end
156
161
 
157
- # Backport of performance enhancement added to Rubygems 1.4
162
+ # Backport of performance enhancement added to RubyGems 1.4
158
163
  def matches_spec?(spec)
159
164
  # name can be a Regexp, so use ===
160
165
  return false unless name === spec.name
@@ -165,10 +170,20 @@ module Gem
165
170
  end
166
171
 
167
172
  class Requirement
168
- # Backport of performance enhancement added to Rubygems 1.4
173
+ # Backport of performance enhancement added to RubyGems 1.4
169
174
  def none?
170
- @none ||= (to_s == ">= 0")
175
+ # note that it might be tempting to replace with with RubyGems 2.0's
176
+ # improved implementation. Don't. It requires `DefaultRequirement` to be
177
+ # defined, and more importantantly, these overrides are not used when the
178
+ # running RubyGems defines these methods
179
+ to_s == ">= 0"
171
180
  end unless allocate.respond_to?(:none?)
181
+
182
+ # Backport of performance enhancement added to RubyGems 2.2
183
+ def exact?
184
+ return false unless @requirements.size == 1
185
+ @requirements[0][0] == "="
186
+ end unless allocate.respond_to?(:exact?)
172
187
  end
173
188
 
174
189
  class Platform
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "rubygems/installer"
3
4
 
4
5
  module Bundler
@@ -9,8 +10,97 @@ module Bundler
9
10
  end
10
11
  end
11
12
 
13
+ attr_reader :options
14
+
15
+ def initialize(gem, options = {})
16
+ @options = {}
17
+ super
18
+ end
19
+
12
20
  def check_executable_overwrite(filename)
13
21
  # Bundler needs to install gems regardless of binstub overwriting
14
22
  end
23
+
24
+ def pre_install_checks
25
+ super && validate_bundler_checksum(options[:bundler_expected_checksum])
26
+ end
27
+
28
+ def build_extensions
29
+ extension_cache_path = options[:bundler_extension_cache_path]
30
+ return super unless extension_cache_path && extension_dir = Bundler.rubygems.spec_extension_dir(spec)
31
+
32
+ extension_dir = Pathname.new(extension_dir)
33
+ build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
34
+ if build_complete && !options[:force]
35
+ SharedHelpers.filesystem_access(extension_dir.parent, &:mkpath)
36
+ SharedHelpers.filesystem_access(extension_cache_path) do
37
+ FileUtils.cp_r extension_cache_path, spec.extension_dir
38
+ end
39
+ else
40
+ super
41
+ if extension_dir.directory? # not made for gems without extensions
42
+ SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
43
+ SharedHelpers.filesystem_access(extension_cache_path) do
44
+ FileUtils.cp_r extension_dir, extension_cache_path
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ def validate_bundler_checksum(checksum)
53
+ return true if Bundler.settings[:disable_checksum_validation]
54
+ return true unless checksum
55
+ return true unless source = @package.instance_variable_get(:@gem)
56
+ return true unless source.respond_to?(:with_read_io)
57
+ digest = source.with_read_io do |io|
58
+ digest = SharedHelpers.digest(:SHA256).new
59
+ digest << io.read(16_384) until io.eof?
60
+ io.rewind
61
+ send(checksum_type(checksum), digest)
62
+ end
63
+ unless digest == checksum
64
+ raise SecurityError, <<-MESSAGE
65
+ Bundler cannot continue installing #{spec.name} (#{spec.version}).
66
+ The checksum for the downloaded `#{spec.full_name}.gem` does not match \
67
+ the checksum given by the server. This means the contents of the downloaded \
68
+ gem is different from what was uploaded to the server, and could be a potential security issue.
69
+
70
+ To resolve this issue:
71
+ 1. delete the downloaded gem located at: `#{spec.gem_dir}/#{spec.full_name}.gem`
72
+ 2. run `bundle install`
73
+
74
+ If you wish to continue installing the downloaded gem, and are certain it does not pose a \
75
+ security issue despite the mismatching checksum, do the following:
76
+ 1. run `bundle config disable_checksum_validation true` to turn off checksum verification
77
+ 2. run `bundle install`
78
+
79
+ (More info: The expected SHA256 checksum was #{checksum.inspect}, but the \
80
+ checksum for the downloaded gem was #{digest.inspect}.)
81
+ MESSAGE
82
+ end
83
+ true
84
+ end
85
+
86
+ def checksum_type(checksum)
87
+ case checksum.length
88
+ when 64 then :hexdigest!
89
+ when 44 then :base64digest!
90
+ else raise InstallError, "The given checksum for #{spec.full_name} (#{checksum.inspect}) is not a valid SHA256 hexdigest nor base64digest"
91
+ end
92
+ end
93
+
94
+ def hexdigest!(digest)
95
+ digest.hexdigest!
96
+ end
97
+
98
+ def base64digest!(digest)
99
+ if digest.respond_to?(:base64digest!)
100
+ digest.base64digest!
101
+ else
102
+ [digest.digest!].pack("m0")
103
+ end
104
+ end
15
105
  end
16
106
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "monitor"
3
4
  require "rubygems"
4
5
  require "rubygems/config_file"
@@ -71,8 +72,34 @@ module Bundler
71
72
  spec.installed_by_version = Gem::Version.create(installed_by_version)
72
73
  end
73
74
 
74
- def spec_missing_extensions?(spec)
75
- !spec.respond_to?(:missing_extensions?) || spec.missing_extensions?
75
+ def spec_missing_extensions?(spec, default = true)
76
+ return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
77
+
78
+ return false if spec_default_gem?(spec)
79
+ return false if spec.extensions.empty?
80
+
81
+ default
82
+ end
83
+
84
+ def spec_default_gem?(spec)
85
+ spec.respond_to?(:default_gem?) && spec.default_gem?
86
+ end
87
+
88
+ def spec_matches_for_glob(spec, glob)
89
+ return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
90
+
91
+ spec.load_paths.map do |lp|
92
+ Dir["#{lp}/#{glob}#{suffix_pattern}"]
93
+ end.flatten(1)
94
+ end
95
+
96
+ def spec_extension_dir(spec)
97
+ return unless spec.respond_to?(:extension_dir)
98
+ spec.extension_dir
99
+ end
100
+
101
+ def stub_set_spec(stub, spec)
102
+ stub.instance_variable_set(:@spec, spec)
76
103
  end
77
104
 
78
105
  def path(obj)
@@ -80,6 +107,7 @@ module Bundler
80
107
  end
81
108
 
82
109
  def platforms
110
+ return [Gem::Platform::RUBY] if Bundler.settings[:force_ruby_platform]
83
111
  Gem.platforms
84
112
  end
85
113
 
@@ -104,7 +132,11 @@ module Bundler
104
132
  end
105
133
 
106
134
  def inflate(obj)
107
- Gem.inflate(obj)
135
+ if defined?(Gem::Util)
136
+ Gem::Util.inflate(obj)
137
+ else
138
+ Gem.inflate(obj)
139
+ end
108
140
  end
109
141
 
110
142
  def sources=(val)
@@ -144,6 +176,10 @@ module Bundler
144
176
  Gem.post_reset_hooks
145
177
  end
146
178
 
179
+ def suffix_pattern
180
+ Gem.suffix_pattern
181
+ end
182
+
147
183
  def gem_cache
148
184
  gem_path.map {|p| File.expand_path("cache", p) }
149
185
  end
@@ -151,7 +187,7 @@ module Bundler
151
187
  def spec_cache_dirs
152
188
  @spec_cache_dirs ||= begin
153
189
  dirs = gem_path.map {|dir| File.join(dir, "specifications") }
154
- dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in Rubygems 2.0.3 or earlier
190
+ dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier
155
191
  dirs.uniq.select {|dir| File.directory? dir }
156
192
  end
157
193
  end
@@ -165,7 +201,7 @@ module Bundler
165
201
  end
166
202
 
167
203
  def repository_subdirectories
168
- %w(cache doc gems specifications)
204
+ %w[cache doc gems specifications]
169
205
  end
170
206
 
171
207
  def clear_paths
@@ -176,8 +212,12 @@ module Bundler
176
212
  Gem.bin_path(gem, bin, ver)
177
213
  end
178
214
 
215
+ def path_separator
216
+ File::PATH_SEPARATOR
217
+ end
218
+
179
219
  def preserve_paths
180
- # this is a no-op outside of Rubygems 1.8
220
+ # this is a no-op outside of RubyGems 1.8
181
221
  yield
182
222
  end
183
223
 
@@ -194,6 +234,14 @@ module Bundler
194
234
  end
195
235
  end
196
236
 
237
+ def load_plugins
238
+ Gem.load_plugins if Gem.respond_to?(:load_plugins)
239
+ end
240
+
241
+ def load_plugin_files(files)
242
+ Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
243
+ end
244
+
197
245
  def ui=(obj)
198
246
  Gem::DefaultUserInteraction.ui = obj
199
247
  end
@@ -203,6 +251,7 @@ module Bundler
203
251
  end
204
252
 
205
253
  def fetch_specs(all, pre, &blk)
254
+ require "rubygems/spec_fetcher"
206
255
  specs = Gem::SpecFetcher.new.list(all, pre)
207
256
  specs.each { yield } if block_given?
208
257
  specs
@@ -214,9 +263,9 @@ module Bundler
214
263
  {} # if we can't download them, there aren't any
215
264
  end
216
265
 
217
- # TODO: This is for older versions of Rubygems... should we support the
266
+ # TODO: This is for older versions of RubyGems... should we support the
218
267
  # X-Gemfile-Source header on these old versions?
219
- # Maybe the newer implementation will work on older Rubygems?
268
+ # Maybe the newer implementation will work on older RubyGems?
220
269
  # It seems difficult to keep this implementation and still send the header.
221
270
  def fetch_all_remote_specs(remote)
222
271
  old_sources = Bundler.rubygems.sources
@@ -243,6 +292,10 @@ module Bundler
243
292
  end
244
293
  end
245
294
 
295
+ def install_with_build_args(args)
296
+ with_build_args(args) { yield }
297
+ end
298
+
246
299
  def gem_from_path(path, policy = nil)
247
300
  require "rubygems/format"
248
301
  Gem::Format.from_file_by_path(path, policy)
@@ -250,6 +303,7 @@ module Bundler
250
303
 
251
304
  def spec_from_gem(path, policy = nil)
252
305
  require "rubygems/security"
306
+ require "bundler/psyched_yaml"
253
307
  gem_from_path(path, security_policies[policy]).spec
254
308
  rescue Gem::Package::FormatError
255
309
  raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
@@ -277,13 +331,13 @@ module Bundler
277
331
  def download_gem(spec, uri, path)
278
332
  uri = Bundler.settings.mirror_for(uri)
279
333
  fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
280
- Bundler::Retry.new("download gem #{uri}", Gem::RemoteFetcher::FetchError).attempts do
334
+ Bundler::Retry.new("download gem from #{uri}").attempts do
281
335
  fetcher.download(spec, uri, path)
282
336
  end
283
337
  end
284
338
 
285
339
  def security_policy_keys
286
- %w(High Medium Low AlmostNo No).map {|level| "#{level}Security" }
340
+ %w[High Medium Low AlmostNo No].map {|level| "#{level}Security" }
287
341
  end
288
342
 
289
343
  def security_policies
@@ -305,53 +359,57 @@ module Bundler
305
359
  end
306
360
  end
307
361
 
308
- def replace_gem(specs)
362
+ def binstubs_call_gem?
363
+ true
364
+ end
365
+
366
+ def stubs_provide_full_functionality?
367
+ false
368
+ end
369
+
370
+ def replace_gem(specs, specs_by_name)
309
371
  reverse_rubygems_kernel_mixin
310
372
 
311
- executables = specs.map(&:executables).flatten
373
+ executables = nil
312
374
 
313
375
  kernel = (class << ::Kernel; self; end)
314
376
  [kernel, ::Kernel].each do |kernel_class|
315
377
  redefine_method(kernel_class, :gem) do |dep, *reqs|
316
- if executables.include? File.basename(caller.first.split(":").first)
378
+ executables ||= specs.map(&:executables).flatten if ::Bundler.rubygems.binstubs_call_gem?
379
+ if executables && executables.include?(File.basename(caller.first.split(":").first))
317
380
  break
318
381
  end
382
+
319
383
  reqs.pop if reqs.last.is_a?(Hash)
320
384
 
321
385
  unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
322
386
  dep = Gem::Dependency.new(dep, reqs)
323
387
  end
324
388
 
325
- spec = specs.find {|s| s.name == dep.name }
326
-
327
- if spec.nil?
328
-
329
- e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
330
- e.name = dep.name
331
- if e.respond_to?(:requirement=)
332
- e.requirement = dep.requirement
333
- else
334
- e.version_requirement = dep.requirement
335
- end
336
- raise e
337
- elsif dep !~ spec
338
- e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
339
- "Make sure all dependencies are added to Gemfile."
340
- e.name = dep.name
341
- if e.respond_to?(:requirement=)
342
- e.requirement = dep.requirement
343
- else
344
- e.version_requirement = dep.requirement
345
- end
346
- raise e
389
+ if spec = specs_by_name[dep.name]
390
+ return true if dep.matches_spec?(spec)
347
391
  end
348
392
 
349
- true
393
+ message = if spec.nil?
394
+ "#{dep.name} is not part of the bundle." \
395
+ " Add it to your #{Bundler.default_gemfile.basename}."
396
+ else
397
+ "can't activate #{dep}, already activated #{spec.full_name}. " \
398
+ "Make sure all dependencies are added to Gemfile."
399
+ end
400
+
401
+ e = Gem::LoadError.new(message)
402
+ e.name = dep.name
403
+ if e.respond_to?(:requirement=)
404
+ e.requirement = dep.requirement
405
+ elsif e.respond_to?(:version_requirement=)
406
+ e.version_requirement = dep.requirement
407
+ end
408
+ raise e
350
409
  end
351
410
 
352
- # TODO: delete this in 2.0, it's a backwards compatibility shim
353
- # see https://github.com/bundler/bundler/issues/5102
354
- kernel_class.send(:public, :gem)
411
+ # backwards compatibility shim, see https://github.com/bundler/bundler/issues/5102
412
+ kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public?
355
413
  end
356
414
  end
357
415
 
@@ -378,23 +436,37 @@ module Bundler
378
436
  # Used to make bin stubs that are not created by bundler work
379
437
  # under bundler. The new Gem.bin_path only considers gems in
380
438
  # +specs+
381
- def replace_bin_path(specs)
439
+ def replace_bin_path(specs, specs_by_name)
382
440
  gem_class = (class << Gem; self; end)
383
441
 
384
442
  redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
385
443
  exec_name = args.first
386
444
 
445
+ spec_with_name = specs_by_name[gem_name]
387
446
  spec = if exec_name
388
- specs.find {|s| s.name == gem_name && s.executables.include?(exec_name) } ||
447
+ if spec_with_name && spec_with_name.executables.include?(exec_name)
448
+ spec_with_name
449
+ else
389
450
  specs.find {|s| s.executables.include?(exec_name) }
451
+ end
390
452
  else
391
- specs.find {|s| s.name == gem_name }
453
+ spec_with_name
454
+ end
455
+
456
+ unless spec
457
+ message = "can't find executable #{exec_name} for gem #{gem_name}"
458
+ if !exec_name || spec_with_name.nil?
459
+ message += ". #{gem_name} is not currently included in the bundle, " \
460
+ "perhaps you meant to add it to your #{Bundler.default_gemfile.basename}?"
461
+ end
462
+ raise Gem::Exception, message
392
463
  end
393
- raise(Gem::Exception, "can't find executable #{exec_name}") unless spec
464
+
394
465
  raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable
395
- unless spec.name == name
396
- Bundler::SharedHelpers.major_deprecation \
397
- "Bundler is using a binstub that was created for a different gem.\n" \
466
+
467
+ unless spec.name == gem_name
468
+ Bundler::SharedHelpers.major_deprecation 2,
469
+ "Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \
398
470
  "You should run `bundle binstub #{gem_name}` " \
399
471
  "to work around a system/bundle conflict."
400
472
  end
@@ -408,8 +480,10 @@ module Bundler
408
480
  # Copy of Rubygems activate_bin_path impl
409
481
  requirement = args.last
410
482
  spec = find_spec_for_exe name, exec_name, [requirement]
411
- Gem::LOADED_SPECS_MUTEX.synchronize { spec.activate }
412
- spec.bin_file exec_name
483
+
484
+ gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
485
+ gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
486
+ File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
413
487
  end
414
488
 
415
489
  redefine_method(gem_class, :bin_path) do |name, *args|
@@ -432,21 +506,24 @@ module Bundler
432
506
  redefine_method(gem_class, :refresh) {}
433
507
  end
434
508
 
435
- # Replace or hook into Rubygems to provide a bundlerized view
509
+ # Replace or hook into RubyGems to provide a bundlerized view
436
510
  # of the world.
437
511
  def replace_entrypoints(specs)
438
- replace_gem(specs)
512
+ specs_by_name = specs.reduce({}) do |h, s|
513
+ h[s.name] = s
514
+ h
515
+ end
439
516
 
517
+ replace_gem(specs, specs_by_name)
440
518
  stub_rubygems(specs)
441
-
442
- replace_bin_path(specs)
519
+ replace_bin_path(specs, specs_by_name)
443
520
  replace_refresh
444
521
 
445
522
  Gem.clear_paths
446
523
  end
447
524
 
448
- # This backports the correct segment generation code from Rubygems 1.4+
449
- # by monkeypatching it into the method in Rubygems 1.3.6 and 1.3.7.
525
+ # This backports the correct segment generation code from RubyGems 1.4+
526
+ # by monkeypatching it into the method in RubyGems 1.3.6 and 1.3.7.
450
527
  def backport_segment_generation
451
528
  redefine_method(Gem::Version, :segments) do
452
529
  @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
@@ -465,7 +542,7 @@ module Bundler
465
542
  end
466
543
 
467
544
  # This backports base_dir which replaces installation path
468
- # Rubygems 1.8+
545
+ # RubyGems 1.8+
469
546
  def backport_base_dir
470
547
  redefine_method(Gem::Specification, :base_dir) do
471
548
  return Gem.dir unless loaded_from
@@ -497,8 +574,10 @@ module Bundler
497
574
  @replaced_methods.each do |(sym, klass), method|
498
575
  redefine_method(klass, sym, method)
499
576
  end
500
- post_reset_hooks.reject! do |proc|
501
- proc.binding.eval("__FILE__") == __FILE__
577
+ if Binding.public_method_defined?(:source_location)
578
+ post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
579
+ else
580
+ post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
502
581
  end
503
582
  @replaced_methods.clear
504
583
  end
@@ -534,7 +613,7 @@ module Bundler
534
613
  end
535
614
  end
536
615
 
537
- # Rubygems 1.4 through 1.6
616
+ # RubyGems 1.4 through 1.6
538
617
  class Legacy < RubygemsIntegration
539
618
  def initialize
540
619
  super
@@ -545,7 +624,7 @@ module Bundler
545
624
  end
546
625
 
547
626
  def stub_rubygems(specs)
548
- # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
627
+ # RubyGems versions lower than 1.7 use SourceIndex#from_gems_in
549
628
  source_index_class = (class << Gem::SourceIndex; self; end)
550
629
  redefine_method(source_index_class, :from_gems_in) do |*args|
551
630
  Gem::SourceIndex.new.tap do |source_index|
@@ -577,7 +656,7 @@ module Bundler
577
656
  end
578
657
  end
579
658
 
580
- # Rubygems versions 1.3.6 and 1.3.7
659
+ # RubyGems versions 1.3.6 and 1.3.7
581
660
  class Ancient < Legacy
582
661
  def initialize
583
662
  super
@@ -585,7 +664,7 @@ module Bundler
585
664
  end
586
665
  end
587
666
 
588
- # Rubygems 1.7
667
+ # RubyGems 1.7
589
668
  class Transitional < Legacy
590
669
  def stub_rubygems(specs)
591
670
  stub_source_index(specs)
@@ -599,7 +678,7 @@ module Bundler
599
678
  end
600
679
  end
601
680
 
602
- # Rubygems 1.8.5-1.8.19
681
+ # RubyGems 1.8.5-1.8.19
603
682
  class Modern < RubygemsIntegration
604
683
  def stub_rubygems(specs)
605
684
  Gem::Specification.all = specs
@@ -620,9 +699,9 @@ module Bundler
620
699
  end
621
700
  end
622
701
 
623
- # Rubygems 1.8.0 to 1.8.4
702
+ # RubyGems 1.8.0 to 1.8.4
624
703
  class AlmostModern < Modern
625
- # Rubygems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
704
+ # RubyGems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
626
705
  # you call Gem::Installer#install with an :install_dir set. We have to
627
706
  # change it back for our sudo mode to work.
628
707
  def preserve_paths
@@ -633,9 +712,9 @@ module Bundler
633
712
  end
634
713
  end
635
714
 
636
- # Rubygems 1.8.20+
715
+ # RubyGems 1.8.20+
637
716
  class MoreModern < Modern
638
- # Rubygems 1.8.20 and adds the skip_validation parameter, so that's
717
+ # RubyGems 1.8.20 and adds the skip_validation parameter, so that's
639
718
  # when we start passing it through.
640
719
  def build(spec, skip_validation = false)
641
720
  require "rubygems/builder"
@@ -643,7 +722,7 @@ module Bundler
643
722
  end
644
723
  end
645
724
 
646
- # Rubygems 2.0
725
+ # RubyGems 2.0
647
726
  class Future < RubygemsIntegration
648
727
  def stub_rubygems(specs)
649
728
  Gem::Specification.all = specs
@@ -651,6 +730,10 @@ module Bundler
651
730
  Gem.post_reset do
652
731
  Gem::Specification.all = specs
653
732
  end
733
+
734
+ redefine_method((class << Gem; self; end), :finish_resolve) do |*|
735
+ []
736
+ end
654
737
  end
655
738
 
656
739
  def all_specs
@@ -685,7 +768,9 @@ module Bundler
685
768
  uri = Bundler.settings.mirror_for(uri)
686
769
  fetcher = gem_remote_fetcher
687
770
  fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
688
- fetcher.download(spec, uri, path)
771
+ Bundler::Retry.new("download gem from #{uri}").attempts do
772
+ fetcher.download(spec, uri, path)
773
+ end
689
774
  end
690
775
 
691
776
  def gem_remote_fetcher
@@ -710,6 +795,14 @@ module Bundler
710
795
  def repository_subdirectories
711
796
  Gem::REPOSITORY_SUBDIRECTORIES
712
797
  end
798
+
799
+ def install_with_build_args(args)
800
+ yield
801
+ end
802
+
803
+ def path_separator
804
+ Gem.path_separator
805
+ end
713
806
  end
714
807
 
715
808
  # RubyGems 2.1.0
@@ -727,7 +820,13 @@ module Bundler
727
820
  end
728
821
 
729
822
  def backport_ext_builder_monitor
730
- require "rubygems/ext"
823
+ # So we can avoid requiring "rubygems/ext" in its entirety
824
+ Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
825
+ module Ext
826
+ end
827
+ RB
828
+
829
+ require "rubygems/ext/builder"
731
830
 
732
831
  Gem::Ext::Builder.class_eval do
733
832
  unless const_defined?(:CHDIR_MONITOR)
@@ -750,6 +849,30 @@ module Bundler
750
849
  end.map(&:to_spec)
751
850
  end
752
851
  end
852
+
853
+ def use_gemdeps(gemfile)
854
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
855
+ require "bundler/gemdeps"
856
+ runtime = Bundler.setup
857
+ Bundler.ui = nil
858
+ activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
859
+ [Gemdeps.new(runtime), activated_spec_names]
860
+ end
861
+
862
+ if provides?(">= 2.5.2")
863
+ # RubyGems-generated binstubs call Kernel#gem
864
+ def binstubs_call_gem?
865
+ false
866
+ end
867
+
868
+ # only 2.5.2+ has all of the stub methods we want to use, and since this
869
+ # is a performance optimization _only_,
870
+ # we'll restrict ourselves to the most
871
+ # recent RG versions instead of all versions that have stubs
872
+ def stubs_provide_full_functionality?
873
+ true
874
+ end
875
+ end
753
876
  end
754
877
  end
755
878
 
@@ -768,7 +891,7 @@ module Bundler
768
891
  RubygemsIntegration::Transitional.new
769
892
  elsif RubygemsIntegration.provides?(">= 1.4.0")
770
893
  RubygemsIntegration::Legacy.new
771
- else # Rubygems 1.3.6 and 1.3.7
894
+ else # RubyGems 1.3.6 and 1.3.7
772
895
  RubygemsIntegration::Ancient.new
773
896
  end
774
897
  end