bundler 1.15.2 → 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 (286) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +302 -0
  3. data/README.md +17 -8
  4. data/bundler.gemspec +25 -9
  5. data/exe/bundle +1 -1
  6. data/exe/bundle_ruby +4 -3
  7. data/lib/bundler/build_metadata.rb +53 -0
  8. data/lib/bundler/capistrano.rb +5 -0
  9. data/lib/bundler/cli/add.rb +15 -6
  10. data/lib/bundler/cli/binstubs.rb +17 -9
  11. data/lib/bundler/cli/cache.rb +5 -4
  12. data/lib/bundler/cli/check.rb +3 -5
  13. data/lib/bundler/cli/clean.rb +5 -6
  14. data/lib/bundler/cli/common.rb +11 -2
  15. data/lib/bundler/cli/config.rb +2 -1
  16. data/lib/bundler/cli/console.rb +2 -1
  17. data/lib/bundler/cli/doctor.rb +48 -1
  18. data/lib/bundler/cli/exec.rb +6 -5
  19. data/lib/bundler/cli/gem.rb +13 -8
  20. data/lib/bundler/cli/info.rb +0 -1
  21. data/lib/bundler/cli/init.rb +18 -6
  22. data/lib/bundler/cli/inject.rb +1 -0
  23. data/lib/bundler/cli/install.rb +64 -61
  24. data/lib/bundler/cli/issue.rb +1 -1
  25. data/lib/bundler/cli/list.rb +58 -0
  26. data/lib/bundler/cli/lock.rb +0 -1
  27. data/lib/bundler/cli/open.rb +2 -2
  28. data/lib/bundler/cli/outdated.rb +20 -9
  29. data/lib/bundler/cli/package.rb +9 -6
  30. data/lib/bundler/cli/platform.rb +1 -0
  31. data/lib/bundler/cli/plugin.rb +1 -0
  32. data/lib/bundler/cli/pristine.rb +20 -6
  33. data/lib/bundler/cli/remove.rb +18 -0
  34. data/lib/bundler/cli/show.rb +0 -1
  35. data/lib/bundler/cli/update.rb +35 -7
  36. data/lib/bundler/cli/viz.rb +1 -0
  37. data/lib/bundler/cli.rb +227 -89
  38. data/lib/bundler/compact_index_client/cache.rb +1 -2
  39. data/lib/bundler/compact_index_client/updater.rb +14 -4
  40. data/lib/bundler/compact_index_client.rb +1 -0
  41. data/lib/bundler/compatibility_guard.rb +14 -0
  42. data/lib/bundler/constants.rb +1 -0
  43. data/lib/bundler/current_ruby.rb +13 -5
  44. data/lib/bundler/definition.rb +192 -139
  45. data/lib/bundler/dep_proxy.rb +3 -1
  46. data/lib/bundler/dependency.rb +9 -9
  47. data/lib/bundler/deployment.rb +1 -1
  48. data/lib/bundler/deprecate.rb +15 -3
  49. data/lib/bundler/dsl.rb +115 -64
  50. data/lib/bundler/endpoint_specification.rb +10 -1
  51. data/lib/bundler/env.rb +90 -29
  52. data/lib/bundler/environment_preserver.rb +27 -6
  53. data/lib/bundler/errors.rb +1 -0
  54. data/lib/bundler/feature_flag.rb +46 -4
  55. data/lib/bundler/fetcher/base.rb +1 -0
  56. data/lib/bundler/fetcher/compact_index.rb +2 -11
  57. data/lib/bundler/fetcher/dependency.rb +2 -1
  58. data/lib/bundler/fetcher/downloader.rb +11 -5
  59. data/lib/bundler/fetcher/index.rb +3 -2
  60. data/lib/bundler/fetcher.rb +18 -11
  61. data/lib/bundler/friendly_errors.rb +6 -1
  62. data/lib/bundler/gem_helper.rb +19 -10
  63. data/lib/bundler/gem_helpers.rb +1 -0
  64. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  65. data/lib/bundler/gem_tasks.rb +1 -0
  66. data/lib/bundler/gem_version_promoter.rb +17 -2
  67. data/lib/bundler/gemdeps.rb +1 -0
  68. data/lib/bundler/graph.rb +1 -0
  69. data/lib/bundler/index.rb +8 -8
  70. data/lib/bundler/injector.rb +192 -30
  71. data/lib/bundler/inline.rb +5 -7
  72. data/lib/bundler/installer/gem_installer.rb +11 -2
  73. data/lib/bundler/installer/parallel_installer.rb +78 -42
  74. data/lib/bundler/installer/standalone.rb +1 -0
  75. data/lib/bundler/installer.rb +138 -53
  76. data/lib/bundler/lazy_specification.rb +3 -2
  77. data/lib/bundler/lockfile_generator.rb +95 -0
  78. data/lib/bundler/lockfile_parser.rb +10 -4
  79. data/lib/bundler/match_platform.rb +1 -0
  80. data/lib/bundler/mirror.rb +8 -5
  81. data/lib/bundler/plugin/api/source.rb +9 -2
  82. data/lib/bundler/plugin/events.rb +61 -0
  83. data/lib/bundler/plugin/index.rb +7 -2
  84. data/lib/bundler/plugin/installer.rb +7 -6
  85. data/lib/bundler/plugin/source_list.rb +7 -8
  86. data/lib/bundler/plugin.rb +13 -5
  87. data/lib/bundler/process_lock.rb +24 -0
  88. data/lib/bundler/psyched_yaml.rb +10 -0
  89. data/lib/bundler/remote_specification.rb +1 -0
  90. data/lib/bundler/resolver/spec_group.rb +106 -0
  91. data/lib/bundler/resolver.rb +158 -195
  92. data/lib/bundler/retry.rb +1 -0
  93. data/lib/bundler/ruby_dsl.rb +1 -0
  94. data/lib/bundler/ruby_version.rb +2 -1
  95. data/lib/bundler/rubygems_ext.rb +5 -4
  96. data/lib/bundler/rubygems_gem_installer.rb +31 -1
  97. data/lib/bundler/rubygems_integration.rb +71 -32
  98. data/lib/bundler/runtime.rb +11 -9
  99. data/lib/bundler/settings/validator.rb +102 -0
  100. data/lib/bundler/settings.rb +200 -77
  101. data/lib/bundler/setup.rb +1 -0
  102. data/lib/bundler/shared_helpers.rb +131 -26
  103. data/lib/bundler/similarity_detector.rb +1 -0
  104. data/lib/bundler/source/gemspec.rb +1 -0
  105. data/lib/bundler/source/git/git_proxy.rb +21 -11
  106. data/lib/bundler/source/git.rb +24 -19
  107. data/lib/bundler/source/metadata.rb +62 -0
  108. data/lib/bundler/source/path/installer.rb +2 -0
  109. data/lib/bundler/source/path.rb +8 -8
  110. data/lib/bundler/source/rubygems/remote.rb +8 -2
  111. data/lib/bundler/source/rubygems.rb +161 -84
  112. data/lib/bundler/source.rb +36 -0
  113. data/lib/bundler/source_list.rb +75 -15
  114. data/lib/bundler/spec_set.rb +10 -5
  115. data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  116. data/lib/bundler/stub_specification.rb +1 -0
  117. data/lib/bundler/templates/.document +1 -0
  118. data/lib/bundler/templates/Executable +12 -0
  119. data/lib/bundler/templates/Executable.bundler +105 -0
  120. data/lib/bundler/templates/Gemfile +1 -0
  121. data/lib/bundler/templates/gems.rb +8 -0
  122. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  123. data/lib/bundler/templates/newgem/gitignore.tt +0 -1
  124. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  125. data/lib/bundler/templates/newgem/newgem.gemspec.tt +12 -3
  126. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  127. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  128. data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
  129. data/lib/bundler/ui/rg_proxy.rb +1 -0
  130. data/lib/bundler/ui/shell.rb +17 -4
  131. data/lib/bundler/ui/silent.rb +1 -0
  132. data/lib/bundler/ui.rb +1 -0
  133. data/lib/bundler/uri_credentials_filter.rb +1 -0
  134. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  135. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  136. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  137. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  138. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  139. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -0
  140. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  141. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  142. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  143. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  144. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  145. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  146. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +15 -4
  147. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -2
  148. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
  149. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  150. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  151. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  152. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +491 -148
  153. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  154. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  155. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  156. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  157. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -0
  158. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -0
  159. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +9 -1
  160. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +45 -8
  161. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +9 -3
  162. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -3
  163. data/lib/bundler/vendor/thor/lib/thor/base.rb +27 -4
  164. data/lib/bundler/vendor/thor/lib/thor/command.rb +9 -7
  165. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +12 -0
  166. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  167. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  168. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +5 -5
  169. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +6 -5
  170. data/lib/bundler/vendor/thor/lib/thor/runner.rb +6 -4
  171. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -9
  172. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  173. data/lib/bundler/vendor/thor/lib/thor.rb +25 -8
  174. data/lib/bundler/vendored_fileutils.rb +9 -0
  175. data/lib/bundler/vendored_molinillo.rb +1 -0
  176. data/lib/bundler/vendored_persistent.rb +35 -0
  177. data/lib/bundler/vendored_thor.rb +1 -0
  178. data/lib/bundler/version.rb +6 -2
  179. data/lib/bundler/version_ranges.rb +1 -0
  180. data/lib/bundler/vlad.rb +5 -0
  181. data/lib/bundler/worker.rb +1 -0
  182. data/lib/bundler/yaml_serializer.rb +3 -3
  183. data/lib/bundler.rb +86 -52
  184. data/man/bundle-add.1 +18 -3
  185. data/man/bundle-add.1.txt +26 -14
  186. data/man/bundle-add.ronn +13 -2
  187. data/man/bundle-binstubs.1 +11 -1
  188. data/man/bundle-binstubs.1.txt +33 -18
  189. data/man/bundle-binstubs.ronn +15 -1
  190. data/man/bundle-check.1 +4 -4
  191. data/man/bundle-check.1.txt +15 -14
  192. data/man/bundle-check.ronn +3 -3
  193. data/man/bundle-clean.1 +1 -1
  194. data/man/bundle-clean.1.txt +10 -10
  195. data/man/bundle-config.1 +129 -29
  196. data/man/bundle-config.1.txt +285 -174
  197. data/man/bundle-config.ronn +167 -88
  198. data/man/bundle-doctor.1 +44 -0
  199. data/man/bundle-doctor.1.txt +44 -0
  200. data/man/bundle-doctor.ronn +33 -0
  201. data/man/bundle-exec.1 +6 -3
  202. data/man/bundle-exec.1.txt +78 -71
  203. data/man/bundle-exec.ronn +10 -3
  204. data/man/bundle-gem.1 +3 -3
  205. data/man/bundle-gem.1.txt +40 -39
  206. data/man/bundle-gem.ronn +2 -1
  207. data/man/bundle-info.1 +1 -1
  208. data/man/bundle-info.1.txt +8 -8
  209. data/man/bundle-init.1 +9 -4
  210. data/man/bundle-init.1.txt +23 -13
  211. data/man/bundle-init.ronn +15 -4
  212. data/man/bundle-inject.1 +4 -4
  213. data/man/bundle-inject.1.txt +10 -10
  214. data/man/bundle-inject.ronn +3 -3
  215. data/man/bundle-install.1 +31 -28
  216. data/man/bundle-install.1.txt +205 -194
  217. data/man/bundle-install.ronn +44 -35
  218. data/man/bundle-list.1 +50 -0
  219. data/man/bundle-list.1.txt +43 -0
  220. data/man/bundle-list.ronn +33 -0
  221. data/man/bundle-lock.1 +1 -1
  222. data/man/bundle-lock.1.txt +47 -47
  223. data/man/bundle-lock.ronn +1 -1
  224. data/man/bundle-open.1 +1 -1
  225. data/man/bundle-open.1.txt +7 -7
  226. data/man/bundle-outdated.1 +7 -3
  227. data/man/bundle-outdated.1.txt +40 -36
  228. data/man/bundle-outdated.ronn +6 -2
  229. data/man/bundle-package.1 +6 -3
  230. data/man/bundle-package.1.txt +44 -39
  231. data/man/bundle-package.ronn +7 -2
  232. data/man/bundle-platform.1 +1 -1
  233. data/man/bundle-platform.1.txt +13 -13
  234. data/man/bundle-pristine.1 +21 -3
  235. data/man/bundle-pristine.1.txt +33 -10
  236. data/man/bundle-pristine.ronn +24 -3
  237. data/man/bundle-remove.1 +31 -0
  238. data/man/bundle-remove.1.txt +34 -0
  239. data/man/bundle-remove.ronn +23 -0
  240. data/man/bundle-show.1 +3 -3
  241. data/man/bundle-show.1.txt +14 -12
  242. data/man/bundle-show.ronn +3 -2
  243. data/man/bundle-update.1 +13 -9
  244. data/man/bundle-update.1.txt +133 -130
  245. data/man/bundle-update.ronn +21 -17
  246. data/man/bundle-viz.1 +7 -7
  247. data/man/bundle-viz.1.txt +17 -15
  248. data/man/bundle-viz.ronn +6 -6
  249. data/man/bundle.1 +31 -23
  250. data/man/bundle.1.txt +63 -57
  251. data/man/bundle.ronn +35 -29
  252. data/man/gemfile.5 +44 -8
  253. data/man/gemfile.5.ronn +54 -8
  254. data/man/gemfile.5.txt +218 -165
  255. data/man/index.txt +25 -15
  256. metadata +36 -36
  257. data/.codeclimate.yml +0 -25
  258. data/.gitignore +0 -18
  259. data/.rspec +0 -3
  260. data/.rubocop.yml +0 -131
  261. data/.rubocop_todo.yml +0 -418
  262. data/.travis.yml +0 -122
  263. data/CODE_OF_CONDUCT.md +0 -42
  264. data/CONTRIBUTING.md +0 -17
  265. data/Rakefile +0 -338
  266. data/bin/rake +0 -19
  267. data/bin/rspec +0 -15
  268. data/bin/rubocop +0 -17
  269. data/bin/with_rubygems +0 -39
  270. data/doc/README.md +0 -30
  271. data/doc/TROUBLESHOOTING.md +0 -64
  272. data/doc/contributing/BUG_TRIAGE.md +0 -36
  273. data/doc/contributing/COMMUNITY.md +0 -13
  274. data/doc/contributing/GETTING_HELP.md +0 -11
  275. data/doc/contributing/HOW_YOU_CAN_HELP.md +0 -27
  276. data/doc/contributing/ISSUES.md +0 -51
  277. data/doc/contributing/README.md +0 -38
  278. data/doc/development/NEW_FEATURES.md +0 -10
  279. data/doc/development/PULL_REQUESTS.md +0 -40
  280. data/doc/development/README.md +0 -19
  281. data/doc/development/RELEASING.md +0 -9
  282. data/doc/development/SETUP.md +0 -27
  283. data/doc/documentation/README.md +0 -29
  284. data/doc/documentation/VISION.md +0 -26
  285. data/doc/documentation/WRITING.md +0 -54
  286. data/task/release.rake +0 -116
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "erb"
3
4
  require "rubygems/dependency_installer"
4
5
  require "bundler/worker"
@@ -20,8 +21,9 @@ module Bundler
20
21
  # For more information see the #run method on this class.
21
22
  def self.install(root, definition, options = {})
22
23
  installer = new(root, definition)
23
- Plugin.hook("before-install-all", definition.dependencies)
24
+ Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL_ALL, definition.dependencies)
24
25
  installer.run(options)
26
+ Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL_ALL, definition.dependencies)
25
27
  installer
26
28
  end
27
29
 
@@ -33,25 +35,26 @@ module Bundler
33
35
 
34
36
  # Runs the install procedures for a specific Gemfile.
35
37
  #
36
- # Firstly, this method will check to see if Bundler.bundle_path exists
37
- # and if not then will create it. This is usually the location of gems
38
- # on the system, be it RVM or at a system path.
38
+ # Firstly, this method will check to see if `Bundler.bundle_path` exists
39
+ # and if not then Bundler will create the directory. This is usually the same
40
+ # location as RubyGems which typically is the `~/.gem` directory
41
+ # unless other specified.
39
42
  #
40
- # Secondly, it checks if Bundler has been configured to be "frozen"
43
+ # Secondly, it checks if Bundler has been configured to be "frozen".
41
44
  # Frozen ensures that the Gemfile and the Gemfile.lock file are matching.
42
45
  # This stops a situation where a developer may update the Gemfile but may not run
43
46
  # `bundle install`, which leads to the Gemfile.lock file not being correctly updated.
44
47
  # If this file is not correctly updated then any other developer running
45
48
  # `bundle install` will potentially not install the correct gems.
46
49
  #
47
- # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile using
48
- # Bundler::Environment#dependencies. If there are no dependencies specified then
49
- # Bundler returns a warning message stating so and this method returns.
50
+ # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile.
51
+ # If there are no dependencies specified then Bundler returns a warning message stating
52
+ # so and this method returns.
50
53
  #
51
- # Fourthly, Bundler checks if the default lockfile (Gemfile.lock) exists, and if so
52
- # then proceeds to set up a definition based on the default gemfile (Gemfile) and the
53
- # default lock file (Gemfile.lock). However, this is not the case if the platform is different
54
- # to that which is specified in Gemfile.lock, or if there are any missing specs for the gems.
54
+ # Fourthly, Bundler checks if the Gemfile.lock exists, and if so
55
+ # then proceeds to set up a definition based on the Gemfile and the Gemfile.lock.
56
+ # During this step Bundler will also download information about any new gems
57
+ # that are not in the Gemfile.lock and resolve any dependencies if needed.
55
58
  #
56
59
  # Fifthly, Bundler resolves the dependencies either through a cache of gems or by remote.
57
60
  # This then leads into the gems being installed, along with stubs for their executables,
@@ -61,26 +64,36 @@ module Bundler
61
64
  # Sixthly, a new Gemfile.lock is created from the installed gems to ensure that the next time
62
65
  # that a user runs `bundle install` they will receive any updates from this process.
63
66
  #
64
- # Finally: TODO add documentation for how the standalone process works.
67
+ # Finally, if the user has specified the standalone flag, Bundler will generate the needed
68
+ # require paths and save them in a `setup.rb` file. See `bundle standalone --help` for more
69
+ # information.
65
70
  def run(options)
66
71
  create_bundle_path
67
72
 
68
- if Bundler.settings[:frozen]
69
- @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
70
- end
73
+ ProcessLock.lock do
74
+ if Bundler.frozen_bundle?
75
+ @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
76
+ end
71
77
 
72
- if @definition.dependencies.empty?
73
- Bundler.ui.warn "The Gemfile specifies no dependencies"
74
- lock
75
- return
76
- end
78
+ if @definition.dependencies.empty?
79
+ Bundler.ui.warn "The Gemfile specifies no dependencies"
80
+ lock
81
+ return
82
+ end
77
83
 
78
- resolve_if_need(options)
79
- ensure_specs_are_compatible!
80
- install(options)
84
+ if resolve_if_needed(options)
85
+ ensure_specs_are_compatible!
86
+ warn_on_incompatible_bundler_deps
87
+ load_plugins
88
+ options.delete(:jobs)
89
+ else
90
+ options[:jobs] = 1 # to avoid the overhead of Bundler::Worker
91
+ end
92
+ install(options)
81
93
 
82
- lock unless Bundler.settings[:frozen]
83
- Standalone.new(options[:standalone], @definition).generate if options[:standalone]
94
+ lock unless Bundler.frozen_bundle?
95
+ Standalone.new(options[:standalone], @definition).generate if options[:standalone]
96
+ end
84
97
  end
85
98
 
86
99
  def generate_bundler_executable_stubs(spec, options = {})
@@ -101,15 +114,21 @@ module Bundler
101
114
  end
102
115
 
103
116
  # double-assignment to avoid warnings about variables that will be used by ERB
104
- bin_path = bin_path = Bundler.bin_path
105
- template = template = File.read(File.expand_path("../templates/Executable", __FILE__))
106
- relative_gemfile_path = relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
107
- ruby_command = ruby_command = Thor::Util.ruby_command
117
+ bin_path = Bundler.bin_path
118
+ bin_path = bin_path
119
+ relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
120
+ relative_gemfile_path = relative_gemfile_path
121
+ ruby_command = Thor::Util.ruby_command
122
+ ruby_command = ruby_command
123
+ template_path = File.expand_path("../templates/Executable", __FILE__)
124
+ if spec.name == "bundler"
125
+ template_path += ".bundler"
126
+ spec.executables = %(bundle)
127
+ end
128
+ template = File.read(template_path)
108
129
 
109
130
  exists = []
110
131
  spec.executables.each do |executable|
111
- next if executable == "bundle"
112
-
113
132
  binstub_path = "#{bin_path}/#{executable}"
114
133
  if File.exist?(binstub_path) && !options[:force]
115
134
  exists << executable
@@ -117,7 +136,11 @@ module Bundler
117
136
  end
118
137
 
119
138
  File.open(binstub_path, "w", 0o777 & ~File.umask) do |f|
120
- f.puts ERB.new(template, nil, "-").result(binding)
139
+ if RUBY_VERSION >= "2.6"
140
+ f.puts ERB.new(template, :trim_mode => "-").result(binding)
141
+ else
142
+ f.puts ERB.new(template, nil, "-").result(binding)
143
+ end
121
144
  end
122
145
  end
123
146
 
@@ -139,15 +162,25 @@ module Bundler
139
162
  def generate_standalone_bundler_executable_stubs(spec)
140
163
  # double-assignment to avoid warnings about variables that will be used by ERB
141
164
  bin_path = Bundler.bin_path
142
- standalone_path = standalone_path = Bundler.root.join(Bundler.settings[:path]).relative_path_from(bin_path)
165
+ unless path = Bundler.settings[:path]
166
+ raise "Can't standalone without an explicit path set"
167
+ end
168
+ standalone_path = Bundler.root.join(path).relative_path_from(bin_path)
169
+ standalone_path = standalone_path
143
170
  template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__))
144
- ruby_command = ruby_command = Thor::Util.ruby_command
171
+ ruby_command = Thor::Util.ruby_command
172
+ ruby_command = ruby_command
145
173
 
146
174
  spec.executables.each do |executable|
147
175
  next if executable == "bundle"
148
- executable_path = executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
176
+ executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
177
+ executable_path = executable_path
149
178
  File.open "#{bin_path}/#{executable}", "w", 0o755 do |f|
150
- f.puts ERB.new(template, nil, "-").result(binding)
179
+ if RUBY_VERSION >= "2.6"
180
+ f.puts ERB.new(template, :trim_mode => "-").result(binding)
181
+ else
182
+ f.puts ERB.new(template, nil, "-").result(binding)
183
+ end
151
184
  end
152
185
  end
153
186
  end
@@ -159,13 +192,54 @@ module Bundler
159
192
  # that said, it's a rare situation (other than rake), and parallel
160
193
  # installation is SO MUCH FASTER. so we let people opt in.
161
194
  def install(options)
162
- Bundler.rubygems.load_plugins
163
195
  force = options["force"]
164
- jobs = 1
165
- jobs = [Bundler.settings[:jobs].to_i - 1, 1].max if can_install_in_parallel?
196
+ jobs = installation_parallelization(options)
166
197
  install_in_parallel jobs, options[:standalone], force
167
198
  end
168
199
 
200
+ def installation_parallelization(options)
201
+ if jobs = options.delete(:jobs)
202
+ return jobs
203
+ end
204
+
205
+ return 1 unless can_install_in_parallel?
206
+
207
+ auto_config_jobs = Bundler.feature_flag.auto_config_jobs?
208
+ if jobs = Bundler.settings[:jobs]
209
+ if auto_config_jobs
210
+ jobs
211
+ else
212
+ [jobs.pred, 1].max
213
+ end
214
+ elsif auto_config_jobs
215
+ processor_count
216
+ else
217
+ 1
218
+ end
219
+ end
220
+
221
+ def processor_count
222
+ require "etc"
223
+ Etc.nprocessors
224
+ rescue
225
+ 1
226
+ end
227
+
228
+ def load_plugins
229
+ Bundler.rubygems.load_plugins
230
+
231
+ requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
232
+ path_plugin_files = requested_path_gems.map do |spec|
233
+ begin
234
+ Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
235
+ rescue TypeError
236
+ error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
237
+ raise Gem::InvalidSpecificationException, error_message
238
+ end
239
+ end.flatten
240
+ Bundler.rubygems.load_plugin_files(path_plugin_files)
241
+ end
242
+
169
243
  def ensure_specs_are_compatible!
170
244
  system_ruby = Bundler::RubyVersion.system
171
245
  rubygems_version = Gem::Version.create(Gem::VERSION)
@@ -184,12 +258,28 @@ module Bundler
184
258
  end
185
259
  end
186
260
 
261
+ def warn_on_incompatible_bundler_deps
262
+ bundler_version = Gem::Version.create(Bundler::VERSION)
263
+ @definition.specs.each do |spec|
264
+ spec.dependencies.each do |dep|
265
+ next if dep.type == :development
266
+ next unless dep.name == "bundler".freeze
267
+ next if dep.requirement.satisfied_by?(bundler_version)
268
+
269
+ Bundler.ui.warn "#{spec.name} (#{spec.version}) has dependency" \
270
+ " #{SharedHelpers.pretty_dependency(dep)}" \
271
+ ", which is unsatisfied by the current bundler version #{VERSION}" \
272
+ ", so the dependency is being ignored"
273
+ end
274
+ end
275
+ end
276
+
187
277
  def can_install_in_parallel?
188
278
  if Bundler.rubygems.provides?(">= 2.1.0")
189
279
  true
190
280
  else
191
- Bundler.ui.warn "Rubygems #{Gem::VERSION} is not threadsafe, so your "\
192
- "gems will be installed one at a time. Upgrade to Rubygems 2.1.0 " \
281
+ Bundler.ui.warn "RubyGems #{Gem::VERSION} is not threadsafe, so your "\
282
+ "gems will be installed one at a time. Upgrade to RubyGems 2.1.0 " \
193
283
  "or higher to enable parallel gem installation."
194
284
  false
195
285
  end
@@ -207,23 +297,18 @@ module Bundler
207
297
  Bundler.mkdir_p(p)
208
298
  end unless Bundler.bundle_path.exist?
209
299
  rescue Errno::EEXIST
210
- raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " \
300
+ raise PathError, "Could not install to path `#{Bundler.bundle_path}` " \
211
301
  "because a file already exists at that path. Either remove or rename the file so the directory can be created."
212
302
  end
213
303
 
214
- def resolve_if_need(options)
215
- if !options["update"] && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
216
- local = Bundler.ui.silence do
217
- begin
218
- tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
219
- true unless tmpdef.new_platform? || tmpdef.missing_dependencies.any?
220
- rescue BundlerError
221
- end
222
- end
304
+ # returns whether or not a re-resolve was needed
305
+ def resolve_if_needed(options)
306
+ if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
307
+ return false if @definition.nothing_changed? && !@definition.missing_specs?
223
308
  end
224
309
 
225
- return if local
226
310
  options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
311
+ true
227
312
  end
228
313
 
229
314
  def lock(opts = {})
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "uri"
3
4
  require "bundler/match_platform"
4
5
 
@@ -68,7 +69,7 @@ module Bundler
68
69
  end
69
70
 
70
71
  def __materialize__
71
- search_object = Bundler.settings[:specific_platform] || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
72
+ search_object = Bundler.feature_flag.specific_platform? || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
72
73
  @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
73
74
  source.gemspec.tap {|s| s.source = source }
74
75
  else
@@ -79,7 +80,7 @@ module Bundler
79
80
  "To use the platform-specific version of the gem, run `bundle config specific_platform true` and install again."
80
81
  search = source.specs.search(self).last
81
82
  end
82
- search.dependencies = dependencies if search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification)
83
+ search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
83
84
  search
84
85
  end
85
86
  end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class LockfileGenerator
5
+ attr_reader :definition
6
+ attr_reader :out
7
+
8
+ # @private
9
+ def initialize(definition)
10
+ @definition = definition
11
+ @out = String.new
12
+ end
13
+
14
+ def self.generate(definition)
15
+ new(definition).generate!
16
+ end
17
+
18
+ def generate!
19
+ add_sources
20
+ add_platforms
21
+ add_dependencies
22
+ add_locked_ruby_version
23
+ add_bundled_with
24
+
25
+ out
26
+ end
27
+
28
+ private
29
+
30
+ def add_sources
31
+ definition.send(:sources).lock_sources.each_with_index do |source, idx|
32
+ out << "\n" unless idx.zero?
33
+
34
+ # Add the source header
35
+ out << source.to_lock
36
+
37
+ # Find all specs for this source
38
+ specs = definition.resolve.select {|s| source.can_lock?(s) }
39
+ add_specs(specs)
40
+ end
41
+ end
42
+
43
+ def add_specs(specs)
44
+ # This needs to be sorted by full name so that
45
+ # gems with the same name, but different platform
46
+ # are ordered consistently
47
+ specs.sort_by(&:full_name).each do |spec|
48
+ next if spec.name == "bundler".freeze
49
+ out << spec.to_lock
50
+ end
51
+ end
52
+
53
+ def add_platforms
54
+ add_section("PLATFORMS", definition.platforms)
55
+ end
56
+
57
+ def add_dependencies
58
+ out << "\nDEPENDENCIES\n"
59
+
60
+ handled = []
61
+ definition.dependencies.sort_by(&:to_s).each do |dep|
62
+ next if handled.include?(dep.name)
63
+ out << dep.to_lock
64
+ handled << dep.name
65
+ end
66
+ end
67
+
68
+ def add_locked_ruby_version
69
+ return unless locked_ruby_version = definition.locked_ruby_version
70
+ add_section("RUBY VERSION", locked_ruby_version.to_s)
71
+ end
72
+
73
+ def add_bundled_with
74
+ add_section("BUNDLED WITH", definition.locked_bundler_version.to_s)
75
+ end
76
+
77
+ def add_section(name, value)
78
+ out << "\n#{name}\n"
79
+ case value
80
+ when Array
81
+ value.map(&:to_s).sort.each do |val|
82
+ out << " #{val}\n"
83
+ end
84
+ when Hash
85
+ value.to_a.sort_by {|k, _| k.to_s }.each do |key, val|
86
+ out << " #{key}: #{val}\n"
87
+ end
88
+ when String
89
+ out << " #{value}\n"
90
+ else
91
+ raise ArgumentError, "#{value.inspect} can't be serialized in a lockfile"
92
+ end
93
+ end
94
+ end
95
+ end
@@ -90,7 +90,7 @@ module Bundler
90
90
  send("parse_#{@state}", line)
91
91
  end
92
92
  end
93
- @sources << @rubygems_aggregate
93
+ @sources << @rubygems_aggregate unless Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
94
94
  @specs = @specs.values.sort_by(&:identifier)
95
95
  warn_for_outdated_bundler_version
96
96
  rescue ArgumentError => e
@@ -141,10 +141,16 @@ module Bundler
141
141
  @sources << @current_source
142
142
  end
143
143
  when GEM
144
- Array(@opts["remote"]).each do |url|
145
- @rubygems_aggregate.add_remote(url)
144
+ if Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
145
+ @opts["remotes"] = @opts.delete("remote")
146
+ @current_source = TYPES[@type].from_lock(@opts)
147
+ @sources << @current_source
148
+ else
149
+ Array(@opts["remote"]).each do |url|
150
+ @rubygems_aggregate.add_remote(url)
151
+ end
152
+ @current_source = @rubygems_aggregate
146
153
  end
147
- @current_source = @rubygems_aggregate
148
154
  when PLUGIN
149
155
  @current_source = Plugin.source_from_lock(@opts)
150
156
  @sources << @current_source
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler/gem_helpers"
3
4
 
4
5
  module Bundler
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "socket"
3
4
 
4
5
  module Bundler
@@ -37,7 +38,7 @@ module Bundler
37
38
  mirror = if config.all?
38
39
  @all
39
40
  else
40
- (@mirrors[config.uri] = @mirrors[config.uri] || Mirror.new)
41
+ @mirrors[config.uri] ||= Mirror.new
41
42
  end
42
43
  config.update_mirror(mirror)
43
44
  end
@@ -45,7 +46,9 @@ module Bundler
45
46
  private
46
47
 
47
48
  def fetch_valid_mirror_for(uri)
48
- mirror = (@mirrors[URI(uri.to_s.downcase)] || @mirrors[URI(uri.to_s).host] || Mirror.new(uri)).validate!(@prober)
49
+ downcased = uri.to_s.downcase
50
+ mirror = @mirrors[downcased] || @mirrors[URI(downcased).host] || Mirror.new(uri)
51
+ mirror.validate!(@prober)
49
52
  mirror = Mirror.new(uri) unless mirror.valid?
50
53
  mirror
51
54
  end
@@ -117,7 +120,7 @@ module Bundler
117
120
 
118
121
  def initialize(config_line, value)
119
122
  uri, fallback =
120
- config_line.match(%r{^mirror\.(all|.+?)(\.fallback_timeout)?\/?$}).captures
123
+ config_line.match(%r{\Amirror\.(all|.+?)(\.fallback_timeout)?\/?\z}).captures
121
124
  @fallback = !fallback.nil?
122
125
  @all = false
123
126
  if uri == "all"
@@ -149,7 +152,7 @@ module Bundler
149
152
  socket.connect_nonblock(address)
150
153
  rescue Errno::EINPROGRESS
151
154
  wait_for_writtable_socket(socket, address, timeout)
152
- rescue # Connection failed somehow, again
155
+ rescue RuntimeError # Connection failed somehow, again
153
156
  false
154
157
  end
155
158
  end
@@ -169,7 +172,7 @@ module Bundler
169
172
  socket.connect_nonblock(address)
170
173
  rescue Errno::EISCONN
171
174
  true
172
- rescue # Connection failed
175
+ rescue StandardError # Connection failed
173
176
  false
174
177
  end
175
178
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "uri"
3
- require "digest/sha1"
4
4
 
5
5
  module Bundler
6
6
  module Plugin
@@ -271,7 +271,7 @@ module Bundler
271
271
  end
272
272
 
273
273
  def uri_hash
274
- Digest::SHA1.hexdigest(uri)
274
+ SharedHelpers.digest(:SHA1).hexdigest(uri)
275
275
  end
276
276
 
277
277
  # Note: Do not override if you don't know what you are doing.
@@ -293,6 +293,13 @@ module Bundler
293
293
  def bundler_plugin_api_source?
294
294
  true
295
295
  end
296
+
297
+ # @private
298
+ # This API on source might not be stable, and for now we expect plugins
299
+ # to download all specs in `#specs`, so we implement the method for
300
+ # compatibility purposes and leave it undocumented (and don't support)
301
+ # overriding it)
302
+ def double_check_for(*); end
296
303
  end
297
304
  end
298
305
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module Plugin
5
+ module Events
6
+ def self.define(const, event)
7
+ const = const.to_sym.freeze
8
+ if const_defined?(const) && const_get(const) != event
9
+ raise ArgumentError, "Attempting to reassign #{const} to a different value"
10
+ end
11
+ const_set(const, event) unless const_defined?(const)
12
+ @events ||= {}
13
+ @events[event] = const
14
+ end
15
+ private_class_method :define
16
+
17
+ def self.reset
18
+ @events.each_value do |const|
19
+ remove_const(const)
20
+ end
21
+ @events = nil
22
+ end
23
+ private_class_method :reset
24
+
25
+ # Check if an event has been defined
26
+ # @param event [String] An event to check
27
+ # @return [Boolean] A boolean indicating if the event has been defined
28
+ def self.defined_event?(event)
29
+ @events ||= {}
30
+ @events.key?(event)
31
+ end
32
+
33
+ # @!parse
34
+ # A hook called before each individual gem is installed
35
+ # Includes a Bundler::ParallelInstaller::SpecInstallation.
36
+ # No state, error, post_install_message will be present as nothing has installed yet
37
+ # GEM_BEFORE_INSTALL = "before-install"
38
+ define :GEM_BEFORE_INSTALL, "before-install"
39
+
40
+ # @!parse
41
+ # A hook called after each individual gem is installed
42
+ # Includes a Bundler::ParallelInstaller::SpecInstallation.
43
+ # - If state is failed, an error will be present.
44
+ # - If state is success, a post_install_message may be present.
45
+ # GEM_AFTER_INSTALL = "after-install"
46
+ define :GEM_AFTER_INSTALL, "after-install"
47
+
48
+ # @!parse
49
+ # A hook called before any gems install
50
+ # Includes an Array of Bundler::Dependency objects
51
+ # GEM_BEFORE_INSTALL_ALL = "before-install-all"
52
+ define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
53
+
54
+ # @!parse
55
+ # A hook called after any gems install
56
+ # Includes an Array of Bundler::Dependency objects
57
+ # GEM_AFTER_INSTALL_ALL = "after-install-all"
58
+ define :GEM_AFTER_INSTALL_ALL, "after-install-all"
59
+ end
60
+ end
61
+ end
@@ -29,7 +29,12 @@ module Bundler
29
29
  @hooks = {}
30
30
  @load_paths = {}
31
31
 
32
- load_index(global_index_file, true)
32
+ begin
33
+ load_index(global_index_file, true)
34
+ rescue GenericSystemCallError
35
+ # no need to fail when on a read-only FS, for example
36
+ nil
37
+ end
33
38
  load_index(local_index_file) if SharedHelpers.in_bundle?
34
39
  end
35
40
 
@@ -58,7 +63,7 @@ module Bundler
58
63
  @plugin_paths[name] = path
59
64
  @load_paths[name] = load_paths
60
65
  save_index
61
- rescue
66
+ rescue StandardError
62
67
  @commands = old_commands
63
68
  raise
64
69
  end
@@ -13,12 +13,13 @@ module Bundler
13
13
 
14
14
  def install(names, options)
15
15
  version = options[:version] || [">= 0"]
16
-
17
- if options[:git]
18
- install_git(names, version, options)
19
- else
20
- sources = options[:source] || Bundler.rubygems.sources
21
- install_rubygems(names, version, sources)
16
+ Bundler.settings.temporary(:lockfile_uses_separate_rubygems_sources => false, :disable_multisource => false) do
17
+ if options[:git]
18
+ install_git(names, version, options)
19
+ else
20
+ sources = options[:source] || Bundler.rubygems.sources
21
+ install_rubygems(names, version, sources)
22
+ end
22
23
  end
23
24
  end
24
25
 
@@ -5,13 +5,6 @@ module Bundler
5
5
  # approptiate options to be used with Source classes for plugin installation
6
6
  module Plugin
7
7
  class SourceList < Bundler::SourceList
8
- def initialize
9
- @path_sources = []
10
- @git_sources = []
11
- @rubygems_aggregate = Plugin::Installer::Rubygems.new
12
- @rubygems_sources = []
13
- end
14
-
15
8
  def add_git_source(options = {})
16
9
  add_source_to_list Plugin::Installer::Git.new(options), git_sources
17
10
  end
@@ -21,7 +14,13 @@ module Bundler
21
14
  end
22
15
 
23
16
  def all_sources
24
- path_sources + git_sources + rubygems_sources
17
+ path_sources + git_sources + rubygems_sources + [metadata_source]
18
+ end
19
+
20
+ private
21
+
22
+ def rubygems_aggregate_class
23
+ Plugin::Installer::Rubygems
25
24
  end
26
25
  end
27
26
  end