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
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require "digest/sha1"
3
2
 
4
3
  module Bundler
5
4
  class Runtime
@@ -11,6 +10,8 @@ module Bundler
11
10
  end
12
11
 
13
12
  def setup(*groups)
13
+ @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
14
+
14
15
  groups.map!(&:to_sym)
15
16
 
16
17
  # Has to happen first
@@ -24,21 +25,10 @@ module Bundler
24
25
  # Activate the specs
25
26
  load_paths = specs.map do |spec|
26
27
  unless spec.loaded_from
27
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
28
+ raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
28
29
  end
29
30
 
30
- if (activated_spec = Bundler.rubygems.loaded_specs(spec.name)) && activated_spec.version != spec.version
31
- e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
32
- "but your Gemfile requires #{spec.name} #{spec.version}. Prepending " \
33
- "`bundle exec` to your command may solve this."
34
- e.name = spec.name
35
- if e.respond_to?(:requirement=)
36
- e.requirement = Gem::Requirement.new(spec.version.to_s)
37
- else
38
- e.version_requirement = Gem::Requirement.new(spec.version.to_s)
39
- end
40
- raise e
41
- end
31
+ check_for_activated_spec!(spec)
42
32
 
43
33
  Bundler.rubygems.mark_loaded(spec)
44
34
  spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
@@ -89,7 +79,7 @@ module Bundler
89
79
  required_file = file
90
80
  begin
91
81
  Kernel.require file
92
- rescue => e
82
+ rescue RuntimeError => e
93
83
  raise e if e.is_a?(LoadError) # we handle this a little later
94
84
  raise Bundler::GemRequireError.new e,
95
85
  "There was an error while trying to load the gem '#{file}'."
@@ -127,6 +117,7 @@ module Bundler
127
117
  definition_method :requires
128
118
 
129
119
  def lock(opts = {})
120
+ return if @definition.nothing_changed? && !@definition.unlocking?
130
121
  @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
131
122
  end
132
123
 
@@ -140,7 +131,8 @@ module Bundler
140
131
 
141
132
  Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
142
133
 
143
- specs.each do |spec|
134
+ specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
135
+ specs_to_cache.each do |spec|
144
136
  next if spec.name == "bundler"
145
137
  next if spec.source.is_a?(Source::Gemspec)
146
138
  spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
@@ -171,6 +163,7 @@ module Bundler
171
163
  gem_dirs = Dir["#{Gem.dir}/gems/*"]
172
164
  gem_files = Dir["#{Gem.dir}/cache/*.gem"]
173
165
  gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
166
+ extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"]
174
167
  spec_gem_paths = []
175
168
  # need to keep git sources around
176
169
  spec_git_paths = @definition.spec_git_paths
@@ -178,6 +171,7 @@ module Bundler
178
171
  spec_gem_executables = []
179
172
  spec_cache_paths = []
180
173
  spec_gemspec_paths = []
174
+ spec_extension_paths = []
181
175
  specs.each do |spec|
182
176
  spec_gem_paths << spec.full_gem_path
183
177
  # need to check here in case gems are nested like for the rails git repo
@@ -189,6 +183,7 @@ module Bundler
189
183
  end
190
184
  spec_cache_paths << spec.cache_file
191
185
  spec_gemspec_paths << spec.spec_file
186
+ spec_extension_paths << spec.extension_dir if spec.respond_to?(:extension_dir)
192
187
  spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
193
188
  end
194
189
  spec_gem_paths.uniq!
@@ -200,6 +195,7 @@ module Bundler
200
195
  stale_gem_dirs = gem_dirs - spec_gem_paths
201
196
  stale_gem_files = gem_files - spec_cache_paths
202
197
  stale_gemspec_files = gemspec_files - spec_gemspec_paths
198
+ stale_extension_dirs = extension_dirs - spec_extension_paths
203
199
 
204
200
  removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
205
201
  removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
@@ -212,8 +208,10 @@ module Bundler
212
208
  FileUtils.rm(file) if File.exist?(file)
213
209
  end
214
210
  end
215
- stale_git_cache_dirs.each do |cache_dir|
216
- SharedHelpers.filesystem_access(cache_dir) do |dir|
211
+
212
+ stale_dirs = stale_git_cache_dirs + stale_extension_dirs
213
+ stale_dirs.each do |stale_dir|
214
+ SharedHelpers.filesystem_access(stale_dir) do |dir|
217
215
  FileUtils.rm_rf(dir) if File.exist?(dir)
218
216
  end
219
217
  end
@@ -269,9 +267,6 @@ module Bundler
269
267
  end
270
268
 
271
269
  def setup_manpath
272
- # Store original MANPATH for restoration later in with_clean_env()
273
- ENV["BUNDLER_ORIG_MANPATH"] = ENV["MANPATH"]
274
-
275
270
  # Add man/ subdirectories from activated bundles to MANPATH for man(1)
276
271
  manuals = $LOAD_PATH.map do |path|
277
272
  man_subdir = path.sub(/lib$/, "man")
@@ -279,7 +274,7 @@ module Bundler
279
274
  end.compact
280
275
 
281
276
  return if manuals.empty?
282
- ENV["MANPATH"] = manuals.concat(
277
+ Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
283
278
  ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
284
279
  ).uniq.join(File::PATH_SEPARATOR)
285
280
  end
@@ -301,5 +296,27 @@ module Bundler
301
296
 
302
297
  output
303
298
  end
299
+
300
+ def check_for_activated_spec!(spec)
301
+ return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
302
+ return if activated_spec.version == spec.version
303
+
304
+ suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
305
+ "Since #{spec.name} is a default gem, you can either remove your dependency on it" \
306
+ " or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
307
+ else
308
+ "Prepending `bundle exec` to your command may solve this."
309
+ end
310
+
311
+ e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
312
+ "but your Gemfile requires #{spec.name} #{spec.version}. #{suggestion}"
313
+ e.name = spec.name
314
+ if e.respond_to?(:requirement=)
315
+ e.requirement = Gem::Requirement.new(spec.version.to_s)
316
+ else
317
+ e.version_requirement = Gem::Requirement.new(spec.version.to_s)
318
+ end
319
+ raise e
320
+ end
304
321
  end
305
322
  end
@@ -1,86 +1,149 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "uri"
3
4
 
4
5
  module Bundler
5
6
  class Settings
6
- BOOL_KEYS = %w(
7
+ autoload :Mirror, "bundler/mirror"
8
+ autoload :Mirrors, "bundler/mirror"
9
+ autoload :Validator, "bundler/settings/validator"
10
+
11
+ BOOL_KEYS = %w[
12
+ allow_bundler_dependency_conflicts
13
+ allow_deployment_source_credential_changes
7
14
  allow_offline_install
15
+ auto_clean_without_path
8
16
  auto_install
17
+ auto_config_jobs
9
18
  cache_all
19
+ cache_all_platforms
20
+ cache_command_is_package
21
+ console_command
22
+ default_install_uses_path
23
+ deployment
24
+ deployment_means_frozen
25
+ disable_checksum_validation
10
26
  disable_exec_load
11
27
  disable_local_branch_check
28
+ disable_multisource
29
+ disable_platform_warnings
12
30
  disable_shared_gems
31
+ disable_version_check
32
+ error_on_stderr
33
+ force_ruby_platform
34
+ forget_cli_options
13
35
  frozen
14
36
  gem.coc
15
37
  gem.mit
38
+ global_path_appends_ruby_scope
39
+ global_gem_cache
16
40
  ignore_messages
41
+ init_gems_rb
42
+ list_command
43
+ lockfile_uses_separate_rubygems_sources
17
44
  major_deprecations
18
45
  no_install
19
46
  no_prune
20
47
  only_update_to_newer_versions
48
+ path_relative_to_cwd
49
+ path.system
21
50
  plugins
51
+ prefer_gems_rb
52
+ print_only_version_number
53
+ setup_makes_kernel_gem_public
22
54
  silence_root_warning
23
- ).freeze
24
-
25
- NUMBER_KEYS = %w(
55
+ skip_default_git_sources
56
+ specific_platform
57
+ suppress_install_using_messages
58
+ unlock_source_unlocks_spec
59
+ update_requires_all_flag
60
+ use_gem_version_promoter_for_major_updates
61
+ viz_command
62
+ ].freeze
63
+
64
+ NUMBER_KEYS = %w[
65
+ jobs
26
66
  redirect
27
67
  retry
28
68
  ssl_verify_mode
29
69
  timeout
30
- ).freeze
70
+ ].freeze
71
+
72
+ ARRAY_KEYS = %w[
73
+ with
74
+ without
75
+ ].freeze
31
76
 
32
77
  DEFAULT_CONFIG = {
78
+ :disable_version_check => true,
33
79
  :redirect => 5,
34
80
  :retry => 3,
35
81
  :timeout => 10,
36
82
  }.freeze
37
83
 
38
- attr_accessor :cli_flags_given
39
-
40
84
  def initialize(root = nil)
41
85
  @root = root
42
86
  @local_config = load_config(local_config_file)
43
87
  @global_config = load_config(global_config_file)
44
- @cli_flags_given = false
88
+ @temporary = {}
45
89
  end
46
90
 
47
91
  def [](name)
48
92
  key = key_for(name)
49
- value = (@local_config[key] || ENV[key] || @global_config[key] || DEFAULT_CONFIG[name])
93
+ value = @temporary.fetch(key) do
94
+ @local_config.fetch(key) do
95
+ ENV.fetch(key) do
96
+ @global_config.fetch(key) do
97
+ DEFAULT_CONFIG.fetch(name) do
98
+ nil
99
+ end end end end end
50
100
 
51
- if value.nil?
52
- nil
53
- elsif is_bool(name) || value == "false"
54
- to_bool(value)
55
- elsif is_num(name)
56
- value.to_i
57
- else
58
- value
59
- end
101
+ converted_value(value, name)
60
102
  end
61
103
 
62
- def []=(key, value)
63
- if cli_flags_given
104
+ def set_command_option(key, value)
105
+ if Bundler.feature_flag.forget_cli_options?
106
+ temporary(key => value)
107
+ value
108
+ else
64
109
  command = if value.nil?
65
110
  "bundle config --delete #{key}"
66
111
  else
67
112
  "bundle config #{key} #{Array(value).join(":")}"
68
113
  end
69
114
 
70
- Bundler::SharedHelpers.major_deprecation \
115
+ Bundler::SharedHelpers.major_deprecation 2,\
71
116
  "flags passed to commands " \
72
117
  "will no longer be automatically remembered. Instead please set flags " \
73
118
  "you want remembered between commands using `bundle config " \
74
119
  "<setting name> <setting value>`, i.e. `#{command}`"
120
+
121
+ set_local(key, value)
75
122
  end
123
+ end
124
+
125
+ def set_command_option_if_given(key, value)
126
+ return if value.nil?
127
+ set_command_option(key, value)
128
+ end
129
+
130
+ def set_local(key, value)
76
131
  local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")
132
+
77
133
  set_key(key, value, @local_config, local_config_file)
78
134
  end
79
135
 
80
- alias_method :set_local, :[]=
81
-
82
- def delete(key)
83
- @local_config.delete(key_for(key))
136
+ def temporary(update)
137
+ existing = Hash[update.map {|k, _| [k, @temporary[key_for(k)]] }]
138
+ update.each do |k, v|
139
+ set_key(k, v, @temporary, nil)
140
+ end
141
+ return unless block_given?
142
+ begin
143
+ yield
144
+ ensure
145
+ existing.each {|k, v| set_key(k, v, @temporary, nil) }
146
+ end
84
147
  end
85
148
 
86
149
  def set_global(key, value)
@@ -88,9 +151,9 @@ module Bundler
88
151
  end
89
152
 
90
153
  def all
91
- env_keys = ENV.keys.select {|k| k =~ /BUNDLE_.*/ }
154
+ env_keys = ENV.keys.grep(/\ABUNDLE_.+/)
92
155
 
93
- keys = @global_config.keys | @local_config.keys | env_keys
156
+ keys = @temporary.keys | @global_config.keys | @local_config.keys | env_keys
94
157
 
95
158
  keys.map do |key|
96
159
  key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
@@ -116,7 +179,7 @@ module Bundler
116
179
 
117
180
  def gem_mirrors
118
181
  all.inject(Mirrors.new) do |mirrors, k|
119
- mirrors.parse(k, self[k]) if k =~ /^mirror\./
182
+ mirrors.parse(k, self[k]) if k.start_with?("mirror.")
120
183
  mirrors
121
184
  end
122
185
  end
@@ -124,6 +187,7 @@ module Bundler
124
187
  def locations(key)
125
188
  key = key_for(key)
126
189
  locations = {}
190
+ locations[:temporary] = @temporary[key] if @temporary.key?(key)
127
191
  locations[:local] = @local_config[key] if @local_config.key?(key)
128
192
  locations[:env] = ENV[key] if ENV[key]
129
193
  locations[:global] = @global_config[key] if @global_config.key?(key)
@@ -135,53 +199,91 @@ module Bundler
135
199
  key = key_for(exposed_key)
136
200
 
137
201
  locations = []
202
+
203
+ if @temporary.key?(key)
204
+ locations << "Set for the current command: #{converted_value(@temporary[key], exposed_key).inspect}"
205
+ end
206
+
138
207
  if @local_config.key?(key)
139
- locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
208
+ locations << "Set for your local app (#{local_config_file}): #{converted_value(@local_config[key], exposed_key).inspect}"
140
209
  end
141
210
 
142
211
  if value = ENV[key]
143
- locations << "Set via #{key}: #{value.inspect}"
212
+ locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}"
144
213
  end
145
214
 
146
215
  if @global_config.key?(key)
147
- locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
216
+ locations << "Set for the current user (#{global_config_file}): #{converted_value(@global_config[key], exposed_key).inspect}"
148
217
  end
149
218
 
150
219
  return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
151
220
  locations
152
221
  end
153
222
 
154
- def without=(array)
155
- set_array(:without, array)
156
- end
223
+ # for legacy reasons, in Bundler 1, the ruby scope isnt appended when the setting comes from ENV or the global config,
224
+ # nor do we respect :disable_shared_gems
225
+ def path
226
+ key = key_for(:path)
227
+ path = ENV[key] || @global_config[key]
228
+ if path && !@temporary.key?(key) && !@local_config.key?(key)
229
+ return Path.new(path, Bundler.feature_flag.global_path_appends_ruby_scope?, false, false)
230
+ end
157
231
 
158
- def with=(array)
159
- set_array(:with, array)
232
+ system_path = self["path.system"] || (self[:disable_shared_gems] == false)
233
+ Path.new(self[:path], true, system_path, Bundler.feature_flag.default_install_uses_path?)
160
234
  end
161
235
 
162
- def without
163
- get_array(:without)
164
- end
236
+ Path = Struct.new(:explicit_path, :append_ruby_scope, :system_path, :default_install_uses_path) do
237
+ def path
238
+ path = base_path
239
+ path = File.join(path, Bundler.ruby_scope) if append_ruby_scope && !use_system_gems?
240
+ path
241
+ end
165
242
 
166
- def with
167
- get_array(:with)
168
- end
243
+ def use_system_gems?
244
+ return true if system_path
245
+ return false if explicit_path
246
+ !default_install_uses_path
247
+ end
169
248
 
170
- # @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
171
- def path
172
- key = key_for(:path)
173
- path = ENV[key] || @global_config[key]
174
- return path if path && !@local_config.key?(key)
249
+ def base_path
250
+ path = explicit_path
251
+ path ||= ".bundle" unless use_system_gems?
252
+ path ||= Bundler.rubygems.gem_dir
253
+ path
254
+ end
175
255
 
176
- if path = self[:path]
177
- "#{path}/#{Bundler.ruby_scope}"
178
- else
179
- Bundler.rubygems.gem_dir
256
+ def base_path_relative_to_pwd
257
+ base_path = Pathname.new(self.base_path)
258
+ expanded_base_path = base_path.expand_path(Bundler.root)
259
+ relative_path = expanded_base_path.relative_path_from(Pathname.pwd)
260
+ if relative_path.to_s.start_with?("..")
261
+ relative_path = base_path if base_path.absolute?
262
+ else
263
+ relative_path = Pathname.new(File.join(".", relative_path))
264
+ end
265
+ relative_path
266
+ rescue ArgumentError
267
+ expanded_base_path
268
+ end
269
+
270
+ def validate!
271
+ return unless explicit_path && system_path
272
+ path = Bundler.settings.pretty_values_for(:path)
273
+ path.unshift(nil, "path:") unless path.empty?
274
+ system_path = Bundler.settings.pretty_values_for("path.system")
275
+ system_path.unshift(nil, "path.system:") unless system_path.empty?
276
+ disable_shared_gems = Bundler.settings.pretty_values_for(:disable_shared_gems)
277
+ disable_shared_gems.unshift(nil, "disable_shared_gems:") unless disable_shared_gems.empty?
278
+ raise InvalidOption,
279
+ "Using a custom path while using system gems is unsupported.\n#{path.join("\n")}\n#{system_path.join("\n")}\n#{disable_shared_gems.join("\n")}"
180
280
  end
181
281
  end
182
282
 
183
283
  def allow_sudo?
184
- !@local_config.key?(key_for(:path))
284
+ key = key_for(:path)
285
+ path_configured = @temporary.key?(key) || @local_config.key?(key)
286
+ !path_configured
185
287
  end
186
288
 
187
289
  def ignore_config?
@@ -189,14 +291,17 @@ module Bundler
189
291
  end
190
292
 
191
293
  def app_cache_path
192
- @app_cache_path ||= begin
193
- path = self[:cache_path] || "vendor/cache"
194
- raise InvalidOption, "Cache path must be relative to the bundle path" if path.start_with?("/")
195
- path
196
- end
294
+ @app_cache_path ||= self[:cache_path] || "vendor/cache"
197
295
  end
198
296
 
199
- private
297
+ def validate!
298
+ all.each do |raw_key|
299
+ [@local_config, ENV, @global_config].each do |settings|
300
+ value = converted_value(settings[key_for(raw_key)], raw_key)
301
+ Validator.validate!(raw_key, value, settings.to_hash.dup)
302
+ end
303
+ end
304
+ end
200
305
 
201
306
  def key_for(key)
202
307
  key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
@@ -204,15 +309,17 @@ module Bundler
204
309
  "BUNDLE_#{key}"
205
310
  end
206
311
 
312
+ private
313
+
207
314
  def parent_setting_for(name)
208
- split_specfic_setting_for(name)[0]
315
+ split_specific_setting_for(name)[0]
209
316
  end
210
317
 
211
- def specfic_gem_for(name)
212
- split_specfic_setting_for(name)[1]
318
+ def specific_gem_for(name)
319
+ split_specific_setting_for(name)[1]
213
320
  end
214
321
 
215
- def split_specfic_setting_for(name)
322
+ def split_specific_setting_for(name)
216
323
  name.split(".")
217
324
  end
218
325
 
@@ -221,42 +328,77 @@ module Bundler
221
328
  end
222
329
 
223
330
  def to_bool(value)
224
- !(value.nil? || value == "" || value =~ /^(false|f|no|n|0)$/i || value == false)
331
+ case value
332
+ when nil, /\A(false|f|no|n|0|)\z/i, false
333
+ false
334
+ else
335
+ true
336
+ end
225
337
  end
226
338
 
227
- def is_num(value)
228
- NUMBER_KEYS.include?(value.to_s)
339
+ def is_num(key)
340
+ NUMBER_KEYS.include?(key.to_s)
229
341
  end
230
342
 
231
- def get_array(key)
232
- self[key] ? self[key].split(":").map(&:to_sym) : []
343
+ def is_array(key)
344
+ ARRAY_KEYS.include?(key.to_s)
233
345
  end
234
346
 
235
- def set_array(key, array)
236
- self[key] = (array.empty? ? nil : array.join(":")) if array
347
+ def to_array(value)
348
+ return [] unless value
349
+ value.split(":").map(&:to_sym)
237
350
  end
238
351
 
239
- def set_key(key, value, hash, file)
240
- key = key_for(key)
352
+ def array_to_s(array)
353
+ array = Array(array)
354
+ return nil if array.empty?
355
+ array.join(":").tr(" ", ":")
356
+ end
241
357
 
242
- unless hash[key] == value
243
- hash[key] = value
244
- hash.delete(key) if value.nil?
245
- SharedHelpers.filesystem_access(file) do |p|
246
- FileUtils.mkdir_p(p.dirname)
247
- require "bundler/yaml_serializer"
248
- p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
249
- end
358
+ def set_key(raw_key, value, hash, file)
359
+ raw_key = raw_key.to_s
360
+ value = array_to_s(value) if is_array(raw_key)
361
+
362
+ key = key_for(raw_key)
363
+
364
+ return if hash[key] == value
365
+
366
+ hash[key] = value
367
+ hash.delete(key) if value.nil?
368
+
369
+ Validator.validate!(raw_key, converted_value(value, raw_key), hash)
370
+
371
+ return unless file
372
+ SharedHelpers.filesystem_access(file) do |p|
373
+ FileUtils.mkdir_p(p.dirname)
374
+ require "bundler/yaml_serializer"
375
+ p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
250
376
  end
377
+ end
251
378
 
252
- value
379
+ def converted_value(value, key)
380
+ if is_array(key)
381
+ to_array(value)
382
+ elsif value.nil?
383
+ nil
384
+ elsif is_bool(key) || value == "false"
385
+ to_bool(value)
386
+ elsif is_num(key)
387
+ value.to_i
388
+ else
389
+ value.to_s
390
+ end
253
391
  end
254
392
 
255
393
  def global_config_file
256
394
  if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
257
395
  Pathname.new(ENV["BUNDLE_CONFIG"])
258
396
  else
259
- Bundler.user_bundle_path.join("config")
397
+ begin
398
+ Bundler.user_bundle_path("config")
399
+ rescue PermissionError, GenericSystemCallError
400
+ nil
401
+ end
260
402
  end
261
403
  end
262
404
 
@@ -279,25 +421,43 @@ module Bundler
279
421
  }xo
280
422
 
281
423
  def load_config(config_file)
282
- return {} unless config_file
424
+ return {} if !config_file || ignore_config?
283
425
  SharedHelpers.filesystem_access(config_file, :read) do |file|
284
426
  valid_file = file.exist? && !file.size.zero?
285
- return {} if ignore_config? || !valid_file
427
+ return {} unless valid_file
286
428
  require "bundler/yaml_serializer"
287
429
  YAMLSerializer.load file.read
288
430
  end
289
431
  end
290
432
 
433
+ PER_URI_OPTIONS = %w[
434
+ fallback_timeout
435
+ ].freeze
436
+
437
+ NORMALIZE_URI_OPTIONS_PATTERN =
438
+ /
439
+ \A
440
+ (\w+\.)? # optional prefix key
441
+ (https?.*?) # URI
442
+ (\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key
443
+ \z
444
+ /ix
445
+
291
446
  # TODO: duplicates Rubygems#normalize_uri
292
447
  # TODO: is this the correct place to validate mirror URIs?
293
448
  def self.normalize_uri(uri)
294
449
  uri = uri.to_s
295
- uri = "#{uri}/" unless uri =~ %r{/\Z}
450
+ if uri =~ NORMALIZE_URI_OPTIONS_PATTERN
451
+ prefix = $1
452
+ uri = $2
453
+ suffix = $3
454
+ end
455
+ uri = "#{uri}/" unless uri.end_with?("/")
296
456
  uri = URI(uri)
297
457
  unless uri.absolute?
298
458
  raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
299
459
  end
300
- uri
460
+ "#{prefix}#{uri}#{suffix}"
301
461
  end
302
462
  end
303
463
  end