bundler 1.15.4 → 1.16.0.pre.1

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

Potentially problematic release.


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

Files changed (251) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +43 -0
  3. data/README.md +12 -7
  4. data/exe/bundle +1 -1
  5. data/exe/bundle_ruby +4 -3
  6. data/lib/bundler.rb +47 -37
  7. data/lib/bundler/build_metadata.rb +38 -0
  8. data/lib/bundler/capistrano.rb +5 -0
  9. data/lib/bundler/cli.rb +155 -67
  10. data/lib/bundler/cli/add.rb +0 -1
  11. data/lib/bundler/cli/binstubs.rb +9 -7
  12. data/lib/bundler/cli/cache.rb +5 -4
  13. data/lib/bundler/cli/check.rb +3 -5
  14. data/lib/bundler/cli/clean.rb +5 -6
  15. data/lib/bundler/cli/common.rb +11 -2
  16. data/lib/bundler/cli/config.rb +2 -1
  17. data/lib/bundler/cli/console.rb +2 -1
  18. data/lib/bundler/cli/doctor.rb +1 -0
  19. data/lib/bundler/cli/exec.rb +2 -1
  20. data/lib/bundler/cli/gem.rb +3 -2
  21. data/lib/bundler/cli/info.rb +0 -1
  22. data/lib/bundler/cli/init.rb +17 -6
  23. data/lib/bundler/cli/inject.rb +1 -0
  24. data/lib/bundler/cli/install.rb +61 -61
  25. data/lib/bundler/cli/issue.rb +1 -1
  26. data/lib/bundler/cli/list.rb +22 -0
  27. data/lib/bundler/cli/lock.rb +0 -1
  28. data/lib/bundler/cli/open.rb +2 -2
  29. data/lib/bundler/cli/outdated.rb +13 -8
  30. data/lib/bundler/cli/package.rb +9 -6
  31. data/lib/bundler/cli/platform.rb +1 -0
  32. data/lib/bundler/cli/plugin.rb +1 -0
  33. data/lib/bundler/cli/pristine.rb +9 -2
  34. data/lib/bundler/cli/show.rb +0 -1
  35. data/lib/bundler/cli/update.rb +31 -5
  36. data/lib/bundler/cli/viz.rb +1 -0
  37. data/lib/bundler/compact_index_client.rb +1 -0
  38. data/lib/bundler/compact_index_client/cache.rb +1 -0
  39. data/lib/bundler/compact_index_client/updater.rb +3 -2
  40. data/lib/bundler/compatibility_guard.rb +14 -0
  41. data/lib/bundler/constants.rb +1 -0
  42. data/lib/bundler/current_ruby.rb +5 -4
  43. data/lib/bundler/definition.rb +140 -95
  44. data/lib/bundler/dep_proxy.rb +2 -0
  45. data/lib/bundler/dependency.rb +6 -7
  46. data/lib/bundler/deployment.rb +1 -1
  47. data/lib/bundler/deprecate.rb +1 -0
  48. data/lib/bundler/dsl.rb +97 -62
  49. data/lib/bundler/endpoint_specification.rb +9 -0
  50. data/lib/bundler/env.rb +63 -27
  51. data/lib/bundler/environment_preserver.rb +26 -6
  52. data/lib/bundler/errors.rb +1 -0
  53. data/lib/bundler/feature_flag.rb +39 -4
  54. data/lib/bundler/fetcher.rb +15 -8
  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 +1 -0
  58. data/lib/bundler/fetcher/downloader.rb +1 -0
  59. data/lib/bundler/fetcher/index.rb +1 -0
  60. data/lib/bundler/friendly_errors.rb +2 -1
  61. data/lib/bundler/gem_helper.rb +14 -9
  62. data/lib/bundler/gem_helpers.rb +1 -0
  63. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  64. data/lib/bundler/gem_tasks.rb +1 -0
  65. data/lib/bundler/gem_version_promoter.rb +1 -0
  66. data/lib/bundler/gemdeps.rb +1 -0
  67. data/lib/bundler/graph.rb +1 -0
  68. data/lib/bundler/index.rb +15 -8
  69. data/lib/bundler/injector.rb +25 -22
  70. data/lib/bundler/inline.rb +5 -7
  71. data/lib/bundler/installer.rb +93 -45
  72. data/lib/bundler/installer/gem_installer.rb +2 -0
  73. data/lib/bundler/installer/parallel_installer.rb +73 -42
  74. data/lib/bundler/installer/standalone.rb +1 -0
  75. data/lib/bundler/lazy_specification.rb +2 -1
  76. data/lib/bundler/lockfile_generator.rb +95 -0
  77. data/lib/bundler/lockfile_parser.rb +10 -4
  78. data/lib/bundler/match_platform.rb +1 -0
  79. data/lib/bundler/mirror.rb +6 -3
  80. data/lib/bundler/plugin.rb +1 -0
  81. data/lib/bundler/plugin/api/source.rb +8 -0
  82. data/lib/bundler/plugin/installer.rb +7 -6
  83. data/lib/bundler/plugin/source_list.rb +7 -8
  84. data/lib/bundler/process_lock.rb +24 -0
  85. data/lib/bundler/psyched_yaml.rb +1 -0
  86. data/lib/bundler/remote_specification.rb +1 -0
  87. data/lib/bundler/resolver.rb +138 -191
  88. data/lib/bundler/resolver/spec_group.rb +111 -0
  89. data/lib/bundler/retry.rb +1 -0
  90. data/lib/bundler/ruby_dsl.rb +1 -0
  91. data/lib/bundler/ruby_version.rb +1 -0
  92. data/lib/bundler/rubygems_ext.rb +5 -4
  93. data/lib/bundler/rubygems_gem_installer.rb +23 -0
  94. data/lib/bundler/rubygems_integration.rb +56 -27
  95. data/lib/bundler/runtime.rb +3 -5
  96. data/lib/bundler/settings.rb +177 -76
  97. data/lib/bundler/settings/validator.rb +79 -0
  98. data/lib/bundler/setup.rb +1 -0
  99. data/lib/bundler/shared_helpers.rb +86 -26
  100. data/lib/bundler/similarity_detector.rb +1 -0
  101. data/lib/bundler/source.rb +32 -0
  102. data/lib/bundler/source/gemspec.rb +1 -0
  103. data/lib/bundler/source/git.rb +21 -16
  104. data/lib/bundler/source/git/git_proxy.rb +14 -10
  105. data/lib/bundler/source/metadata.rb +63 -0
  106. data/lib/bundler/source/path.rb +8 -8
  107. data/lib/bundler/source/path/installer.rb +2 -0
  108. data/lib/bundler/source/rubygems.rb +131 -84
  109. data/lib/bundler/source/rubygems/remote.rb +3 -0
  110. data/lib/bundler/source_list.rb +75 -15
  111. data/lib/bundler/spec_set.rb +2 -1
  112. data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  113. data/lib/bundler/stub_specification.rb +1 -0
  114. data/lib/bundler/templates/Executable +4 -0
  115. data/lib/bundler/templates/Executable.bundler +105 -0
  116. data/lib/bundler/templates/Gemfile +1 -0
  117. data/lib/bundler/templates/gems.rb +8 -0
  118. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  119. data/lib/bundler/templates/newgem/gitignore.tt +0 -1
  120. data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -1
  121. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  122. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  123. data/lib/bundler/ui.rb +1 -0
  124. data/lib/bundler/ui/rg_proxy.rb +1 -0
  125. data/lib/bundler/ui/shell.rb +15 -4
  126. data/lib/bundler/ui/silent.rb +1 -0
  127. data/lib/bundler/uri_credentials_filter.rb +1 -0
  128. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  129. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  130. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  131. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  132. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  133. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -2
  134. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  135. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -0
  136. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  137. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  138. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  139. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  140. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  141. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  142. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +3 -2
  143. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +69 -6
  144. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  145. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  146. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  147. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +487 -148
  148. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  149. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  150. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  151. data/lib/bundler/vendored_fileutils.rb +9 -0
  152. data/lib/bundler/vendored_molinillo.rb +1 -0
  153. data/lib/bundler/vendored_persistent.rb +34 -0
  154. data/lib/bundler/vendored_thor.rb +1 -0
  155. data/lib/bundler/version.rb +6 -2
  156. data/lib/bundler/version_ranges.rb +1 -0
  157. data/lib/bundler/vlad.rb +5 -0
  158. data/lib/bundler/worker.rb +1 -0
  159. data/lib/bundler/yaml_serializer.rb +3 -3
  160. data/man/bundle-add.1 +43 -0
  161. data/man/bundle-add.1.txt +40 -0
  162. data/man/bundle-binstubs.1 +40 -0
  163. data/man/bundle-binstubs.1.txt +48 -0
  164. data/man/bundle-binstubs.ronn +14 -0
  165. data/man/bundle-check.1 +31 -0
  166. data/man/bundle-check.1.txt +32 -0
  167. data/man/bundle-clean.1 +24 -0
  168. data/man/bundle-clean.1.txt +26 -0
  169. data/man/bundle-config.1 +455 -0
  170. data/man/bundle-config.1.txt +491 -0
  171. data/man/bundle-config.ronn +133 -79
  172. data/man/bundle-exec.1 +165 -0
  173. data/man/bundle-exec.1.txt +178 -0
  174. data/man/bundle-exec.ronn +7 -0
  175. data/man/bundle-gem.1 +80 -0
  176. data/man/bundle-gem.1.txt +91 -0
  177. data/man/bundle-gem.ronn +2 -1
  178. data/man/bundle-info.1 +20 -0
  179. data/man/bundle-info.1.txt +21 -0
  180. data/man/bundle-init.1 +20 -0
  181. data/man/bundle-init.1.txt +24 -0
  182. data/man/bundle-inject.1 +33 -0
  183. data/man/bundle-inject.1.txt +32 -0
  184. data/man/bundle-install.1 +305 -0
  185. data/man/bundle-install.1.txt +385 -0
  186. data/man/bundle-install.ronn +32 -32
  187. data/man/bundle-list.1 +20 -0
  188. data/man/bundle-list.1.txt +21 -0
  189. data/man/bundle-list.ronn +15 -0
  190. data/man/bundle-lock.1 +84 -0
  191. data/man/bundle-lock.1.txt +93 -0
  192. data/man/bundle-open.1 +32 -0
  193. data/man/bundle-open.1.txt +29 -0
  194. data/man/bundle-outdated.1 +151 -0
  195. data/man/bundle-outdated.1.txt +127 -0
  196. data/man/bundle-outdated.ronn +1 -1
  197. data/man/bundle-package.1 +55 -0
  198. data/man/bundle-package.1.txt +79 -0
  199. data/man/bundle-package.ronn +5 -0
  200. data/man/bundle-platform.1 +61 -0
  201. data/man/bundle-platform.1.txt +57 -0
  202. data/man/bundle-pristine.1 +34 -0
  203. data/man/bundle-pristine.1.txt +44 -0
  204. data/man/bundle-pristine.ronn +24 -3
  205. data/man/bundle-show.1 +23 -0
  206. data/man/bundle-show.1.txt +25 -0
  207. data/man/bundle-update.1 +390 -0
  208. data/man/bundle-update.1.txt +386 -0
  209. data/man/bundle-update.ronn +2 -2
  210. data/man/bundle-viz.1 +39 -0
  211. data/man/bundle-viz.1.txt +38 -0
  212. data/man/bundle-viz.ronn +5 -5
  213. data/man/bundle.1 +132 -0
  214. data/man/bundle.1.txt +113 -0
  215. data/man/bundle.ronn +5 -2
  216. data/man/gemfile.5 +679 -0
  217. data/man/gemfile.5.ronn +31 -0
  218. data/man/gemfile.5.txt +636 -0
  219. data/man/index.txt +23 -0
  220. metadata +21 -36
  221. data/.codeclimate.yml +0 -25
  222. data/.gitignore +0 -18
  223. data/.rspec +0 -3
  224. data/.rubocop.yml +0 -131
  225. data/.rubocop_todo.yml +0 -418
  226. data/.travis.yml +0 -122
  227. data/CODE_OF_CONDUCT.md +0 -42
  228. data/CONTRIBUTING.md +0 -17
  229. data/Rakefile +0 -338
  230. data/bin/rake +0 -19
  231. data/bin/rspec +0 -15
  232. data/bin/rubocop +0 -17
  233. data/bin/with_rubygems +0 -39
  234. data/bundler.gemspec +0 -48
  235. data/doc/README.md +0 -30
  236. data/doc/TROUBLESHOOTING.md +0 -64
  237. data/doc/contributing/BUG_TRIAGE.md +0 -36
  238. data/doc/contributing/COMMUNITY.md +0 -13
  239. data/doc/contributing/GETTING_HELP.md +0 -11
  240. data/doc/contributing/HOW_YOU_CAN_HELP.md +0 -27
  241. data/doc/contributing/ISSUES.md +0 -51
  242. data/doc/contributing/README.md +0 -38
  243. data/doc/development/NEW_FEATURES.md +0 -10
  244. data/doc/development/PULL_REQUESTS.md +0 -40
  245. data/doc/development/README.md +0 -19
  246. data/doc/development/RELEASING.md +0 -9
  247. data/doc/development/SETUP.md +0 -27
  248. data/doc/documentation/README.md +0 -29
  249. data/doc/documentation/VISION.md +0 -26
  250. data/doc/documentation/WRITING.md +0 -54
  251. data/task/release.rake +0 -116
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require "bundler/compatibility_guard"
4
+
2
5
  # Allows for declaring a Gemfile inline in a ruby script, optionally installing
3
6
  # any gems that aren't already installed on the user's system.
4
7
  #
@@ -39,7 +42,7 @@ def gemfile(install = false, options = {}, &gemfile)
39
42
  def Bundler.root
40
43
  Bundler::SharedHelpers.pwd.expand_path
41
44
  end
42
- ENV["BUNDLE_GEMFILE"] = "Gemfile"
45
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", "Gemfile"
43
46
 
44
47
  Bundler::Plugin.gemfile_install(&gemfile) if Bundler.feature_flag.plugins?
45
48
  builder = Bundler::Dsl.new
@@ -50,12 +53,7 @@ def gemfile(install = false, options = {}, &gemfile)
50
53
  definition.validate_runtime!
51
54
 
52
55
  missing_specs = proc do
53
- begin
54
- !definition.missing_specs.empty?
55
- rescue Bundler::GemNotFound, Bundler::GitError
56
- definition.instance_variable_set(:@index, nil)
57
- true
58
- end
56
+ definition.missing_specs?
59
57
  end
60
58
 
61
59
  Bundler.ui = ui if install
@@ -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"
@@ -33,25 +34,26 @@ module Bundler
33
34
 
34
35
  # Runs the install procedures for a specific Gemfile.
35
36
  #
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.
37
+ # Firstly, this method will check to see if `Bundler.bundle_path` exists
38
+ # and if not then Bundler will create the directory. This is usually the same
39
+ # location as RubyGems which typically is the `~/.gem` directory
40
+ # unless other specified.
39
41
  #
40
- # Secondly, it checks if Bundler has been configured to be "frozen"
42
+ # Secondly, it checks if Bundler has been configured to be "frozen".
41
43
  # Frozen ensures that the Gemfile and the Gemfile.lock file are matching.
42
44
  # This stops a situation where a developer may update the Gemfile but may not run
43
45
  # `bundle install`, which leads to the Gemfile.lock file not being correctly updated.
44
46
  # If this file is not correctly updated then any other developer running
45
47
  # `bundle install` will potentially not install the correct gems.
46
48
  #
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.
49
+ # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile.
50
+ # If there are no dependencies specified then Bundler returns a warning message stating
51
+ # so and this method returns.
50
52
  #
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.
53
+ # Fourthly, Bundler checks if the Gemfile.lock exists, and if so
54
+ # then proceeds to set up a definition based on the Gemfile and the Gemfile.lock.
55
+ # During this step Bundler will also download infomrmation about any new gems
56
+ # that are not in the Gemfile.lock and resolve any dependencies if needed.
55
57
  #
56
58
  # Fifthly, Bundler resolves the dependencies either through a cache of gems or by remote.
57
59
  # This then leads into the gems being installed, along with stubs for their executables,
@@ -61,26 +63,36 @@ module Bundler
61
63
  # Sixthly, a new Gemfile.lock is created from the installed gems to ensure that the next time
62
64
  # that a user runs `bundle install` they will receive any updates from this process.
63
65
  #
64
- # Finally: TODO add documentation for how the standalone process works.
66
+ # Finally, if the user has specified the standalone flag, Bundler will generate the needed
67
+ # require paths and save them in a `setup.rb` file. See `bundle standalone --help` for more
68
+ # information.
65
69
  def run(options)
66
70
  create_bundle_path
67
71
 
68
- if Bundler.settings[:frozen]
69
- @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
70
- end
72
+ ProcessLock.lock do
73
+ if Bundler.frozen?
74
+ @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
75
+ end
71
76
 
72
- if @definition.dependencies.empty?
73
- Bundler.ui.warn "The Gemfile specifies no dependencies"
74
- lock
75
- return
76
- end
77
+ if @definition.dependencies.empty?
78
+ Bundler.ui.warn "The Gemfile specifies no dependencies"
79
+ lock
80
+ return
81
+ end
77
82
 
78
- resolve_if_need(options)
79
- ensure_specs_are_compatible!
80
- install(options)
83
+ if resolve_if_needed(options)
84
+ ensure_specs_are_compatible!
85
+ warn_on_incompatible_bundler_deps
86
+ load_plugins
87
+ options.delete(:jobs)
88
+ else
89
+ options[:jobs] = 1 # to avoid the overhead of Bundler::Worker
90
+ end
91
+ install(options)
81
92
 
82
- lock unless Bundler.settings[:frozen]
83
- Standalone.new(options[:standalone], @definition).generate if options[:standalone]
93
+ lock unless Bundler.frozen?
94
+ Standalone.new(options[:standalone], @definition).generate if options[:standalone]
95
+ end
84
96
  end
85
97
 
86
98
  def generate_bundler_executable_stubs(spec, options = {})
@@ -102,14 +114,17 @@ module Bundler
102
114
 
103
115
  # double-assignment to avoid warnings about variables that will be used by ERB
104
116
  bin_path = bin_path = Bundler.bin_path
105
- template = template = File.read(File.expand_path("../templates/Executable", __FILE__))
106
117
  relative_gemfile_path = relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
107
118
  ruby_command = ruby_command = Thor::Util.ruby_command
119
+ template_path = File.expand_path("../templates/Executable", __FILE__)
120
+ if spec.name == "bundler"
121
+ template_path += ".bundler"
122
+ spec.executables = %(bundle)
123
+ end
124
+ template = File.read(template_path)
108
125
 
109
126
  exists = []
110
127
  spec.executables.each do |executable|
111
- next if executable == "bundle"
112
-
113
128
  binstub_path = "#{bin_path}/#{executable}"
114
129
  if File.exist?(binstub_path) && !options[:force]
115
130
  exists << executable
@@ -139,7 +154,10 @@ module Bundler
139
154
  def generate_standalone_bundler_executable_stubs(spec)
140
155
  # double-assignment to avoid warnings about variables that will be used by ERB
141
156
  bin_path = Bundler.bin_path
142
- standalone_path = standalone_path = Bundler.root.join(Bundler.settings[:path]).relative_path_from(bin_path)
157
+ unless path = Bundler.settings[:path]
158
+ raise "Can't standalone without an explicit path set"
159
+ end
160
+ standalone_path = standalone_path = Bundler.root.join(path).relative_path_from(bin_path)
143
161
  template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__))
144
162
  ruby_command = ruby_command = Thor::Util.ruby_command
145
163
 
@@ -159,13 +177,32 @@ module Bundler
159
177
  # that said, it's a rare situation (other than rake), and parallel
160
178
  # installation is SO MUCH FASTER. so we let people opt in.
161
179
  def install(options)
162
- Bundler.rubygems.load_plugins
163
180
  force = options["force"]
164
- jobs = 1
165
- jobs = [Bundler.settings[:jobs].to_i - 1, 1].max if can_install_in_parallel?
181
+ jobs = options.delete(:jobs) do
182
+ if can_install_in_parallel?
183
+ [Bundler.settings[:jobs].to_i - 1, 1].max
184
+ else
185
+ 1
186
+ end
187
+ end
166
188
  install_in_parallel jobs, options[:standalone], force
167
189
  end
168
190
 
191
+ def load_plugins
192
+ Bundler.rubygems.load_plugins
193
+
194
+ requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
195
+ path_plugin_files = requested_path_gems.map do |spec|
196
+ begin
197
+ Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
198
+ rescue TypeError
199
+ error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
200
+ raise Gem::InvalidSpecificationException, error_message
201
+ end
202
+ end.flatten
203
+ Bundler.rubygems.load_plugin_files(path_plugin_files)
204
+ end
205
+
169
206
  def ensure_specs_are_compatible!
170
207
  system_ruby = Bundler::RubyVersion.system
171
208
  rubygems_version = Gem::Version.create(Gem::VERSION)
@@ -184,12 +221,28 @@ module Bundler
184
221
  end
185
222
  end
186
223
 
224
+ def warn_on_incompatible_bundler_deps
225
+ bundler_version = Gem::Version.create(Bundler::VERSION)
226
+ @definition.specs.each do |spec|
227
+ spec.dependencies.each do |dep|
228
+ next if dep.type == :development
229
+ next unless dep.name == "bundler".freeze
230
+ next if dep.requirement.satisfied_by?(bundler_version)
231
+
232
+ Bundler.ui.warn "#{spec.name} (#{spec.version}) has dependency" \
233
+ " #{SharedHelpers.pretty_dependency(dep)}" \
234
+ ", which is unsatisfied by the current bundler version #{VERSION}" \
235
+ ", so the dependency is being ignored"
236
+ end
237
+ end
238
+ end
239
+
187
240
  def can_install_in_parallel?
188
241
  if Bundler.rubygems.provides?(">= 2.1.0")
189
242
  true
190
243
  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 " \
244
+ Bundler.ui.warn "RubyGems #{Gem::VERSION} is not threadsafe, so your "\
245
+ "gems will be installed one at a time. Upgrade to RubyGems 2.1.0 " \
193
246
  "or higher to enable parallel gem installation."
194
247
  false
195
248
  end
@@ -207,23 +260,18 @@ module Bundler
207
260
  Bundler.mkdir_p(p)
208
261
  end unless Bundler.bundle_path.exist?
209
262
  rescue Errno::EEXIST
210
- raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " \
263
+ raise PathError, "Could not install to path `#{Bundler.bundle_path}` " \
211
264
  "because a file already exists at that path. Either remove or rename the file so the directory can be created."
212
265
  end
213
266
 
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
267
+ # returns whether or not a re-resolve was needed
268
+ def resolve_if_needed(options)
269
+ if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
270
+ return false if @definition.nothing_changed? && !@definition.missing_specs?
223
271
  end
224
272
 
225
- return if local
226
273
  options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
274
+ true
227
275
  end
228
276
 
229
277
  def lock(opts = {})
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class GemInstaller
4
5
  attr_reader :spec, :standalone, :worker, :force, :installer
@@ -65,6 +66,7 @@ module Bundler
65
66
  end
66
67
 
67
68
  def generate_executable_stubs
69
+ return if Bundler.feature_flag.forget_cli_options?
68
70
  return if Bundler.settings[:inline]
69
71
  if Bundler.settings[:bin] && standalone
70
72
  installer.generate_standalone_bundler_executable_stubs(spec)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler/worker"
3
4
  require "bundler/installer/gem_installer"
4
5
 
@@ -77,11 +78,6 @@ module Bundler
77
78
  new(*args).call
78
79
  end
79
80
 
80
- # Returns max number of threads machine can handle with a min of 1
81
- def self.max_threads
82
- [Bundler.settings[:jobs].to_i - 1, 1].max
83
- end
84
-
85
81
  attr_reader :size
86
82
 
87
83
  def initialize(installer, all_specs, size, standalone, force)
@@ -99,49 +95,19 @@ module Bundler
99
95
  require "bundler/gem_remote_fetcher" if RUBY_VERSION < "1.9"
100
96
 
101
97
  check_for_corrupt_lockfile
102
- enqueue_specs
103
- process_specs until @specs.all?(&:installed?) || @specs.any?(&:failed?)
98
+
99
+ if @size > 1
100
+ install_with_worker
101
+ else
102
+ install_serially
103
+ end
104
+
104
105
  handle_error if @specs.any?(&:failed?)
105
106
  @specs
106
107
  ensure
107
108
  worker_pool && worker_pool.stop
108
109
  end
109
110
 
110
- def worker_pool
111
- @worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda { |spec_install, worker_num|
112
- gem_installer = Bundler::GemInstaller.new(
113
- spec_install.spec, @installer, @standalone, worker_num, @force
114
- )
115
- success, message = gem_installer.install_from_spec
116
- if success && !message.nil?
117
- spec_install.post_install_message = message
118
- elsif !success
119
- spec_install.state = :failed
120
- spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
121
- end
122
- spec_install
123
- }
124
- end
125
-
126
- # Dequeue a spec and save its post-install message and then enqueue the
127
- # remaining specs.
128
- # Some specs might've had to wait til this spec was installed to be
129
- # processed so the call to `enqueue_specs` is important after every
130
- # dequeue.
131
- def process_specs
132
- spec = worker_pool.deq
133
- spec.state = :installed unless spec.failed?
134
- enqueue_specs
135
- end
136
-
137
- def handle_error
138
- errors = @specs.select(&:failed?).map(&:error)
139
- if exception = errors.find {|e| e.is_a?(Bundler::BundlerError) }
140
- raise exception
141
- end
142
- raise Bundler::InstallError, errors.map(&:to_s).join("\n\n")
143
- end
144
-
145
111
  def check_for_corrupt_lockfile
146
112
  missing_dependencies = @specs.map do |s|
147
113
  [
@@ -167,6 +133,71 @@ module Bundler
167
133
  Bundler.ui.warn(warning.join("\n"))
168
134
  end
169
135
 
136
+ private
137
+
138
+ def install_with_worker
139
+ enqueue_specs
140
+ process_specs until finished_installing?
141
+ end
142
+
143
+ def install_serially
144
+ until finished_installing?
145
+ raise "failed to find a spec to enqueue while installing serially" unless spec_install = @specs.find(&:ready_to_enqueue?)
146
+ spec_install.state = :enqueued
147
+ do_install(spec_install, 0)
148
+ end
149
+ end
150
+
151
+ def worker_pool
152
+ @worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda { |spec_install, worker_num|
153
+ do_install(spec_install, worker_num)
154
+ }
155
+ end
156
+
157
+ def do_install(spec_install, worker_num)
158
+ gem_installer = Bundler::GemInstaller.new(
159
+ spec_install.spec, @installer, @standalone, worker_num, @force
160
+ )
161
+ success, message = begin
162
+ gem_installer.install_from_spec
163
+ rescue => e
164
+ raise e, "#{e}\n\n#{require_tree_for_spec(spec_install.spec)}"
165
+ end
166
+ if success
167
+ spec_install.state = :installed
168
+ spec_install.post_install_message = message unless message.nil?
169
+ else
170
+ spec_install.state = :failed
171
+ spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
172
+ end
173
+ spec_install
174
+ end
175
+
176
+ # Dequeue a spec and save its post-install message and then enqueue the
177
+ # remaining specs.
178
+ # Some specs might've had to wait til this spec was installed to be
179
+ # processed so the call to `enqueue_specs` is important after every
180
+ # dequeue.
181
+ def process_specs
182
+ worker_pool.deq
183
+ enqueue_specs
184
+ end
185
+
186
+ def finished_installing?
187
+ @specs.all? do |spec|
188
+ return true if spec.failed?
189
+ spec.installed?
190
+ end
191
+ end
192
+
193
+ def handle_error
194
+ errors = @specs.select(&:failed?).map(&:error)
195
+ if exception = errors.find {|e| e.is_a?(Bundler::BundlerError) }
196
+ raise exception
197
+ end
198
+ raise Bundler::InstallError, errors.map(&:to_s).join("\n\n")
199
+ end
200
+
170
201
  def require_tree_for_spec(spec)
171
202
  tree = @spec_set.what_required(spec)
172
203
  t = String.new("In #{File.basename(SharedHelpers.default_gemfile)}:\n")
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Standalone
4
5
  def initialize(groups, definition)
@@ -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
@@ -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