rubygems-update 2.6.4 → 2.6.5

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

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (288) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -24
  3. data/CODE_OF_CONDUCT.md +2 -2
  4. data/CONTRIBUTING.rdoc +1 -1
  5. data/History.txt +30 -1
  6. data/Manifest.txt +233 -3
  7. data/Rakefile +30 -1
  8. data/appveyor.yml +0 -2
  9. data/bundler/CHANGELOG.md +2407 -0
  10. data/bundler/CODE_OF_CONDUCT.md +42 -0
  11. data/bundler/CONTRIBUTING.md +36 -0
  12. data/bundler/DEVELOPMENT.md +148 -0
  13. data/bundler/ISSUES.md +100 -0
  14. data/bundler/LICENSE.md +23 -0
  15. data/bundler/README.md +40 -0
  16. data/bundler/exe/bundle +35 -0
  17. data/bundler/exe/bundle_ruby +61 -0
  18. data/bundler/exe/bundler +22 -0
  19. data/bundler/lib/bundler.rb +455 -0
  20. data/bundler/lib/bundler/capistrano.rb +17 -0
  21. data/bundler/lib/bundler/cli.rb +497 -0
  22. data/bundler/lib/bundler/cli/binstubs.rb +40 -0
  23. data/bundler/lib/bundler/cli/cache.rb +35 -0
  24. data/bundler/lib/bundler/cli/check.rb +40 -0
  25. data/bundler/lib/bundler/cli/clean.rb +26 -0
  26. data/bundler/lib/bundler/cli/common.rb +56 -0
  27. data/bundler/lib/bundler/cli/config.rb +100 -0
  28. data/bundler/lib/bundler/cli/console.rb +39 -0
  29. data/bundler/lib/bundler/cli/exec.rb +82 -0
  30. data/bundler/lib/bundler/cli/gem.rb +214 -0
  31. data/bundler/lib/bundler/cli/init.rb +33 -0
  32. data/bundler/lib/bundler/cli/inject.rb +33 -0
  33. data/bundler/lib/bundler/cli/install.rb +225 -0
  34. data/bundler/lib/bundler/cli/lock.rb +48 -0
  35. data/bundler/lib/bundler/cli/open.rb +25 -0
  36. data/bundler/lib/bundler/cli/outdated.rb +151 -0
  37. data/bundler/lib/bundler/cli/package.rb +46 -0
  38. data/bundler/lib/bundler/cli/platform.rb +45 -0
  39. data/bundler/lib/bundler/cli/plugin.rb +23 -0
  40. data/bundler/lib/bundler/cli/show.rb +75 -0
  41. data/bundler/lib/bundler/cli/update.rb +72 -0
  42. data/bundler/lib/bundler/cli/viz.rb +27 -0
  43. data/bundler/lib/bundler/constants.rb +6 -0
  44. data/bundler/lib/bundler/current_ruby.rb +84 -0
  45. data/bundler/lib/bundler/definition.rb +744 -0
  46. data/bundler/lib/bundler/dep_proxy.rb +46 -0
  47. data/bundler/lib/bundler/dependency.rb +127 -0
  48. data/bundler/lib/bundler/deployment.rb +63 -0
  49. data/bundler/lib/bundler/deprecate.rb +16 -0
  50. data/bundler/lib/bundler/dsl.rb +512 -0
  51. data/bundler/lib/bundler/endpoint_specification.rb +129 -0
  52. data/bundler/lib/bundler/env.rb +83 -0
  53. data/bundler/lib/bundler/environment.rb +42 -0
  54. data/bundler/lib/bundler/environment_preserver.rb +38 -0
  55. data/bundler/lib/bundler/errors.rb +124 -0
  56. data/bundler/lib/bundler/fetcher.rb +304 -0
  57. data/bundler/lib/bundler/fetcher/base.rb +41 -0
  58. data/bundler/lib/bundler/fetcher/compact_index.rb +103 -0
  59. data/bundler/lib/bundler/fetcher/dependency.rb +92 -0
  60. data/bundler/lib/bundler/fetcher/downloader.rb +66 -0
  61. data/bundler/lib/bundler/fetcher/index.rb +51 -0
  62. data/bundler/lib/bundler/friendly_errors.rb +103 -0
  63. data/bundler/lib/bundler/gem_helper.rb +188 -0
  64. data/bundler/lib/bundler/gem_helpers.rb +32 -0
  65. data/bundler/lib/bundler/gem_remote_fetcher.rb +42 -0
  66. data/bundler/lib/bundler/gem_tasks.rb +6 -0
  67. data/bundler/lib/bundler/graph.rb +172 -0
  68. data/bundler/lib/bundler/index.rb +191 -0
  69. data/bundler/lib/bundler/injector.rb +63 -0
  70. data/bundler/lib/bundler/inline.rb +74 -0
  71. data/bundler/lib/bundler/installer.rb +217 -0
  72. data/bundler/lib/bundler/installer/gem_installer.rb +77 -0
  73. data/bundler/lib/bundler/installer/parallel_installer.rb +126 -0
  74. data/bundler/lib/bundler/installer/standalone.rb +52 -0
  75. data/bundler/lib/bundler/lazy_specification.rb +85 -0
  76. data/bundler/lib/bundler/lockfile_parser.rb +233 -0
  77. data/bundler/lib/bundler/match_platform.rb +14 -0
  78. data/bundler/lib/bundler/mirror.rb +218 -0
  79. data/bundler/lib/bundler/plugin.rb +156 -0
  80. data/bundler/lib/bundler/plugin/api.rb +56 -0
  81. data/bundler/lib/bundler/plugin/dsl.rb +29 -0
  82. data/bundler/lib/bundler/plugin/index.rb +88 -0
  83. data/bundler/lib/bundler/plugin/installer.rb +99 -0
  84. data/bundler/lib/bundler/plugin/installer/git.rb +38 -0
  85. data/bundler/lib/bundler/plugin/installer/rubygems.rb +27 -0
  86. data/bundler/lib/bundler/plugin/source_list.rb +24 -0
  87. data/bundler/lib/bundler/postit_trampoline.rb +57 -0
  88. data/bundler/lib/bundler/psyched_yaml.rb +27 -0
  89. data/bundler/lib/bundler/remote_specification.rb +85 -0
  90. data/bundler/lib/bundler/resolver.rb +368 -0
  91. data/bundler/lib/bundler/retry.rb +61 -0
  92. data/bundler/lib/bundler/ruby_dsl.rb +17 -0
  93. data/bundler/lib/bundler/ruby_version.rb +140 -0
  94. data/bundler/lib/bundler/rubygems_ext.rb +178 -0
  95. data/bundler/lib/bundler/rubygems_gem_installer.rb +10 -0
  96. data/bundler/lib/bundler/rubygems_integration.rb +710 -0
  97. data/bundler/lib/bundler/runtime.rb +282 -0
  98. data/bundler/lib/bundler/settings.rb +259 -0
  99. data/bundler/lib/bundler/setup.rb +28 -0
  100. data/bundler/lib/bundler/shared_helpers.rb +212 -0
  101. data/bundler/lib/bundler/similarity_detector.rb +62 -0
  102. data/bundler/lib/bundler/source.rb +37 -0
  103. data/bundler/lib/bundler/source/gemspec.rb +13 -0
  104. data/bundler/lib/bundler/source/git.rb +297 -0
  105. data/bundler/lib/bundler/source/git/git_proxy.rb +218 -0
  106. data/bundler/lib/bundler/source/path.rb +245 -0
  107. data/bundler/lib/bundler/source/path/installer.rb +44 -0
  108. data/bundler/lib/bundler/source/rubygems.rb +450 -0
  109. data/bundler/lib/bundler/source/rubygems/remote.rb +59 -0
  110. data/bundler/lib/bundler/source_list.rb +106 -0
  111. data/bundler/lib/bundler/spec_set.rb +157 -0
  112. data/bundler/lib/bundler/ssl_certs/.document +1 -0
  113. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +65 -0
  114. data/bundler/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  115. data/bundler/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  116. data/{lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot-2048.pem → bundler/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem} +0 -0
  117. data/bundler/lib/bundler/stub_specification.rb +24 -0
  118. data/bundler/lib/bundler/templates/Executable +17 -0
  119. data/bundler/lib/bundler/templates/Executable.standalone +12 -0
  120. data/bundler/lib/bundler/templates/Gemfile +5 -0
  121. data/bundler/lib/bundler/templates/newgem/.travis.yml.tt +5 -0
  122. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
  123. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  124. data/bundler/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
  125. data/bundler/lib/bundler/templates/newgem/README.md.tt +41 -0
  126. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +29 -0
  127. data/bundler/lib/bundler/templates/newgem/bin/console.tt +14 -0
  128. data/bundler/lib/bundler/templates/newgem/bin/setup.tt +8 -0
  129. data/bundler/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  130. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
  131. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  132. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  133. data/bundler/lib/bundler/templates/newgem/gitignore.tt +16 -0
  134. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
  135. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  136. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +46 -0
  137. data/bundler/lib/bundler/templates/newgem/rspec.tt +2 -0
  138. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
  139. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
  140. data/bundler/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
  141. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
  142. data/bundler/lib/bundler/ui.rb +8 -0
  143. data/bundler/lib/bundler/ui/rg_proxy.rb +18 -0
  144. data/bundler/lib/bundler/ui/shell.rb +114 -0
  145. data/bundler/lib/bundler/ui/silent.rb +48 -0
  146. data/bundler/lib/bundler/uri_credentials_filter.rb +36 -0
  147. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +79 -0
  148. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +98 -0
  149. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +80 -0
  150. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +4 -0
  151. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +10 -0
  152. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +50 -0
  153. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +80 -0
  154. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +203 -0
  155. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +35 -0
  156. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +58 -0
  157. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +61 -0
  158. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +53 -0
  159. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +114 -0
  160. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +45 -0
  161. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +35 -0
  162. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +123 -0
  163. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -0
  164. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +5 -0
  165. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +100 -0
  166. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +65 -0
  167. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +460 -0
  168. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +45 -0
  169. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +54 -0
  170. data/bundler/lib/bundler/vendor/net/http/faster.rb +26 -0
  171. data/bundler/lib/bundler/vendor/net/http/persistent.rb +1230 -0
  172. data/bundler/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
  173. data/bundler/lib/bundler/vendor/postit/lib/postit.rb +15 -0
  174. data/bundler/lib/bundler/vendor/postit/lib/postit/environment.rb +44 -0
  175. data/bundler/lib/bundler/vendor/postit/lib/postit/installer.rb +28 -0
  176. data/bundler/lib/bundler/vendor/postit/lib/postit/parser.rb +21 -0
  177. data/bundler/lib/bundler/vendor/postit/lib/postit/setup.rb +12 -0
  178. data/bundler/lib/bundler/vendor/postit/lib/postit/version.rb +3 -0
  179. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +484 -0
  180. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +319 -0
  181. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  182. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +59 -0
  183. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
  184. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
  185. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
  186. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
  187. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +656 -0
  188. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +133 -0
  189. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  190. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
  191. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
  192. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +32 -0
  193. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
  194. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
  195. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
  196. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
  197. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  198. data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  199. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +73 -0
  200. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  201. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +125 -0
  202. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +218 -0
  203. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
  204. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +322 -0
  205. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
  206. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +421 -0
  207. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
  208. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
  209. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +267 -0
  210. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
  211. data/bundler/lib/bundler/vendored_molinillo.rb +3 -0
  212. data/bundler/lib/bundler/vendored_persistent.rb +12 -0
  213. data/bundler/lib/bundler/vendored_thor.rb +4 -0
  214. data/bundler/lib/bundler/version.rb +11 -0
  215. data/bundler/lib/bundler/vlad.rb +12 -0
  216. data/bundler/lib/bundler/worker.rb +82 -0
  217. data/bundler/lib/bundler/yaml_serializer.rb +67 -0
  218. data/bundler/man/bundle-config.ronn +193 -0
  219. data/bundler/man/bundle-exec.ronn +136 -0
  220. data/bundler/man/bundle-gem.ronn +77 -0
  221. data/bundler/man/bundle-install.ronn +404 -0
  222. data/bundler/man/bundle-lock.ronn +47 -0
  223. data/bundler/man/bundle-package.ronn +67 -0
  224. data/bundler/man/bundle-platform.ronn +42 -0
  225. data/bundler/man/bundle-update.ronn +194 -0
  226. data/bundler/man/bundle.ronn +98 -0
  227. data/bundler/man/gemfile.5.ronn +499 -0
  228. data/bundler/man/index.txt +8 -0
  229. data/lib/rubygems.rb +42 -2
  230. data/lib/rubygems/config_file.rb +1 -1
  231. data/lib/rubygems/defaults.rb +18 -0
  232. data/lib/rubygems/installer.rb +1 -0
  233. data/lib/rubygems/package.rb +3 -1
  234. data/lib/rubygems/package/tar_writer.rb +10 -16
  235. data/lib/rubygems/remote_fetcher.rb +1 -15
  236. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +50 -0
  237. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +80 -0
  238. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +57 -145
  239. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +35 -0
  240. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +58 -0
  241. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +61 -0
  242. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +53 -0
  243. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +114 -0
  244. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +45 -0
  245. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +35 -0
  246. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +123 -0
  247. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +1 -1
  248. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  249. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +55 -54
  250. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +4 -2
  251. data/lib/rubygems/security/signer.rb +2 -0
  252. data/lib/rubygems/specification.rb +4 -4
  253. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  254. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  255. data/test/rubygems/alternate_cert.pem +10 -9
  256. data/test/rubygems/alternate_cert_32.pem +10 -9
  257. data/test/rubygems/child_cert.pem +11 -9
  258. data/test/rubygems/child_cert_32.pem +11 -9
  259. data/test/rubygems/encrypted_private_key.pem +26 -26
  260. data/test/rubygems/expired_cert.pem +9 -8
  261. data/test/rubygems/future_cert.pem +9 -8
  262. data/test/rubygems/future_cert_32.pem +9 -8
  263. data/test/rubygems/grandchild_cert.pem +11 -9
  264. data/test/rubygems/grandchild_cert_32.pem +11 -9
  265. data/test/rubygems/invalid_issuer_cert.pem +11 -9
  266. data/test/rubygems/invalid_issuer_cert_32.pem +11 -9
  267. data/test/rubygems/invalid_signer_cert.pem +10 -9
  268. data/test/rubygems/invalid_signer_cert_32.pem +10 -9
  269. data/test/rubygems/invalidchild_cert.pem +11 -9
  270. data/test/rubygems/invalidchild_cert_32.pem +11 -9
  271. data/test/rubygems/public_cert.pem +11 -9
  272. data/test/rubygems/public_cert_32.pem +10 -9
  273. data/test/rubygems/test_bundled_ca.rb +1 -1
  274. data/test/rubygems/test_gem.rb +7 -0
  275. data/test/rubygems/test_gem_installer.rb +119 -0
  276. data/test/rubygems/test_gem_package.rb +9 -3
  277. data/test/rubygems/test_gem_package_tar_writer.rb +24 -0
  278. data/test/rubygems/test_gem_remote_fetcher.rb +0 -12
  279. data/test/rubygems/test_gem_security_signer.rb +8 -0
  280. data/test/rubygems/test_gem_specification.rb +1 -1
  281. data/test/rubygems/wrong_key_cert.pem +10 -9
  282. data/test/rubygems/wrong_key_cert_32.pem +10 -9
  283. data/util/ci +73 -0
  284. data/util/create_certs.rb +64 -49
  285. data/util/update_bundled_ca_certificates.rb +23 -2
  286. metadata +257 -19
  287. data/lib/gauntlet_rubygems.rb +0 -51
  288. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRoot.pem +0 -18
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+ module Bundler
3
+ class CLI::Package
4
+ attr_reader :options
5
+
6
+ def initialize(options)
7
+ @options = options
8
+ end
9
+
10
+ def run
11
+ Bundler.ui.level = "error" if options[:quiet]
12
+ Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path]
13
+ Bundler.settings[:cache_all_platforms] = options["all-platforms"] if options.key?("all-platforms")
14
+ Bundler.settings[:cache_path] = options["cache-path"] if options.key?("cache-path")
15
+
16
+ setup_cache_all
17
+ install
18
+
19
+ # TODO: move cache contents here now that all bundles are locked
20
+ custom_path = Pathname.new(options[:path]) if options[:path]
21
+ Bundler.load.cache(custom_path)
22
+ end
23
+
24
+ private
25
+
26
+ def install
27
+ require "bundler/cli/install"
28
+ options = self.options.dup
29
+ if Bundler.settings[:cache_all_platforms]
30
+ options["local"] = false
31
+ options["update"] = true
32
+ end
33
+ Bundler::CLI::Install.new(options).run
34
+ end
35
+
36
+ def setup_cache_all
37
+ Bundler.settings[:cache_all] = options[:all] if options.key?("all")
38
+
39
+ if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all]
40
+ Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
41
+ "to package them as well, please pass the --all flag. This will be the default " \
42
+ "on Bundler 2.0."
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ module Bundler
3
+ class CLI::Platform
4
+ attr_reader :options
5
+ def initialize(options)
6
+ @options = options
7
+ end
8
+
9
+ def run
10
+ platforms, ruby_version = Bundler.ui.silence do
11
+ locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version
12
+ gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
13
+ [Bundler.definition.platforms.map {|p| "* #{p}" },
14
+ locked_ruby_version || gemfile_ruby_version]
15
+ end
16
+ output = []
17
+
18
+ if options[:ruby]
19
+ if ruby_version
20
+ output << ruby_version
21
+ else
22
+ output << "No ruby version specified"
23
+ end
24
+ else
25
+ output << "Your platform is: #{RUBY_PLATFORM}"
26
+ output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
27
+
28
+ if ruby_version
29
+ output << "Your Gemfile specifies a Ruby version requirement:\n* #{ruby_version}"
30
+
31
+ begin
32
+ Bundler.definition.validate_ruby!
33
+ output << "Your current platform satisfies the Ruby version requirement."
34
+ rescue RubyVersionMismatch => e
35
+ output << e.message
36
+ end
37
+ else
38
+ output << "Your Gemfile does not specify a Ruby version requirement."
39
+ end
40
+ end
41
+
42
+ Bundler.ui.info output.join("\n\n")
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require "bundler/vendored_thor"
3
+ module Bundler
4
+ class CLI::Plugin < Thor
5
+ desc "install PLUGINS", "Install the plugin from the source"
6
+ long_desc <<-D
7
+ Install plugins either from the rubygems source provided (with --source option) or from a git source provided with (--git option). If no sources are provided, it uses Gem.sources
8
+ D
9
+ method_option "source", :type => :string, :default => nil, :banner =>
10
+ "URL of the RubyGems source to fetch the plugin from"
11
+ method_option "version", :type => :string, :default => nil, :banner =>
12
+ "The version of the plugin to fetch"
13
+ method_option "git", :type => :string, :default => nil, :banner =>
14
+ "URL of the git repo to fetch from"
15
+ method_option "branch", :type => :string, :default => nil, :banner =>
16
+ "The git branch to checkout"
17
+ method_option "ref", :type => :string, :default => nil, :banner =>
18
+ "The git revision to check out"
19
+ def install(*plugins)
20
+ Bundler::Plugin.install(plugins, options)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+ require "bundler/cli/common"
3
+
4
+ module Bundler
5
+ class CLI::Show
6
+ attr_reader :options, :gem_name, :latest_specs
7
+ def initialize(options, gem_name)
8
+ @options = options
9
+ @gem_name = gem_name
10
+ @verbose = options[:verbose] || options[:outdated]
11
+ @latest_specs = fetch_latest_specs if @verbose
12
+ end
13
+
14
+ def run
15
+ Bundler.ui.silence do
16
+ Bundler.definition.validate_ruby!
17
+ Bundler.load.lock
18
+ end
19
+
20
+ if gem_name
21
+ if gem_name == "bundler"
22
+ path = File.expand_path("../../../..", __FILE__)
23
+ else
24
+ spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match)
25
+ return unless spec
26
+ path = spec.full_gem_path
27
+ unless File.directory?(path)
28
+ Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at:"
29
+ end
30
+ end
31
+ return Bundler.ui.info(path)
32
+ end
33
+
34
+ if options[:paths]
35
+ Bundler.load.specs.sort_by(&:name).map do |s|
36
+ Bundler.ui.info s.full_gem_path
37
+ end
38
+ else
39
+ Bundler.ui.info "Gems included by the bundle:"
40
+ Bundler.load.specs.sort_by(&:name).each do |s|
41
+ desc = " * #{s.name} (#{s.version}#{s.git_version})"
42
+ if @verbose
43
+ latest = latest_specs.find {|l| l.name == s.name }
44
+ Bundler.ui.info <<-END.gsub(/^ +/, "")
45
+ #{desc}
46
+ \tSummary: #{s.summary || "No description available."}
47
+ \tHomepage: #{s.homepage || "No website available."}
48
+ \tStatus: #{outdated?(s, latest) ? "Outdated - #{s.version} < #{latest.version}" : "Up to date"}
49
+ END
50
+ else
51
+ Bundler.ui.info desc
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ def fetch_latest_specs
60
+ definition = Bundler.definition(true)
61
+ if options[:outdated]
62
+ Bundler.ui.info "Fetching remote specs for outdated check...\n\n"
63
+ Bundler.ui.silence { definition.resolve_remotely! }
64
+ else
65
+ definition.resolve_with_cache!
66
+ end
67
+ definition.specs
68
+ end
69
+
70
+ def outdated?(current, latest)
71
+ return false unless latest
72
+ Gem::Version.new(current.version) < Gem::Version.new(latest.version)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+ module Bundler
3
+ class CLI::Update
4
+ attr_reader :options, :gems
5
+ def initialize(options, gems)
6
+ @options = options
7
+ @gems = gems
8
+ end
9
+
10
+ def run
11
+ Bundler.ui.level = "error" if options[:quiet]
12
+
13
+ sources = Array(options[:source])
14
+ groups = Array(options[:group]).map(&:to_sym)
15
+
16
+ if gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
17
+ # We're doing a full update
18
+ Bundler.definition(true)
19
+ else
20
+ unless Bundler.default_lockfile.exist?
21
+ raise GemfileLockNotFound, "This Bundle hasn't been installed yet. " \
22
+ "Run `bundle install` to update and install the bundled gems."
23
+ end
24
+ # cycle through the requested gems, to make sure they exist
25
+ names = Bundler.locked_gems.specs.map(&:name)
26
+ gems.each do |g|
27
+ next if names.include?(g)
28
+ require "bundler/cli/common"
29
+ raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(g, names)
30
+ end
31
+
32
+ if groups.any?
33
+ specs = Bundler.definition.specs_for groups
34
+ gems.concat(specs.map(&:name))
35
+ end
36
+
37
+ Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby])
38
+ end
39
+
40
+ Bundler::Fetcher.disable_endpoint = options["full-index"]
41
+
42
+ opts = options.dup
43
+ opts["update"] = true
44
+ opts["local"] = options[:local]
45
+
46
+ Bundler.settings[:jobs] = opts["jobs"] if opts["jobs"]
47
+
48
+ # rubygems plugins sometimes hook into the gem install process
49
+ Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
50
+
51
+ Bundler.definition.validate_ruby!
52
+ Installer.install Bundler.root, Bundler.definition, opts
53
+ Bundler.load.cache if Bundler.app_cache.exist?
54
+
55
+ if Bundler.settings[:clean] && Bundler.settings[:path]
56
+ require "bundler/cli/clean"
57
+ Bundler::CLI::Clean.new(options).run
58
+ end
59
+
60
+ Bundler.ui.confirm "Bundle updated!"
61
+ without_groups_messages
62
+ end
63
+
64
+ private
65
+
66
+ def without_groups_messages
67
+ return unless Bundler.settings.without.any?
68
+ require "bundler/cli/common"
69
+ Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ module Bundler
3
+ class CLI::Viz
4
+ attr_reader :options, :gem_name
5
+ def initialize(options)
6
+ @options = options
7
+ end
8
+
9
+ def run
10
+ require "graphviz"
11
+
12
+ options[:without] = options[:without].join(":").tr(" ", ":").split(":")
13
+ output_file = File.expand_path(options[:file])
14
+
15
+ graph = Graph.new(Bundler.load, output_file, options[:version], options[:requirements], options[:format], options[:without])
16
+ graph.viz
17
+ rescue LoadError => e
18
+ Bundler.ui.error e.inspect
19
+ Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
20
+ Bundler.ui.warn "`gem install ruby-graphviz`"
21
+ rescue StandardError => e
22
+ raise unless e.message =~ /GraphViz not installed or dot not in PATH/
23
+ Bundler.ui.error e.message
24
+ Bundler.ui.warn "Please install GraphViz. On a Mac with homebrew, you can run `brew install graphviz`."
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ module Bundler
3
+ WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
4
+ FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
5
+ NULL = WINDOWS ? "NUL" : "/dev/null"
6
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ module Bundler
3
+ # Returns current version of Ruby
4
+ #
5
+ # @return [CurrentRuby] Current version of Ruby
6
+ def self.current_ruby
7
+ @current_ruby ||= CurrentRuby.new
8
+ end
9
+
10
+ class CurrentRuby
11
+ KNOWN_MINOR_VERSIONS = %w(
12
+ 1.8
13
+ 1.9
14
+ 2.0
15
+ 2.1
16
+ 2.2
17
+ 2.3
18
+ 2.4
19
+ ).freeze
20
+
21
+ KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
22
+
23
+ KNOWN_PLATFORMS = %w(
24
+ jruby
25
+ maglev
26
+ mingw
27
+ mri
28
+ mswin
29
+ mswin64
30
+ rbx
31
+ ruby
32
+ x64_mingw
33
+ ).freeze
34
+
35
+ def ruby?
36
+ !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev")
37
+ end
38
+
39
+ def mri?
40
+ !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")
41
+ end
42
+
43
+ def rbx?
44
+ ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
45
+ end
46
+
47
+ def jruby?
48
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
49
+ end
50
+
51
+ def maglev?
52
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"
53
+ end
54
+
55
+ def mswin?
56
+ Bundler::WINDOWS
57
+ end
58
+
59
+ def mswin64?
60
+ Bundler::WINDOWS && Gem::Platform.local.os == "mswin64" && Gem::Platform.local.cpu == "x64"
61
+ end
62
+
63
+ def mingw?
64
+ Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu != "x64"
65
+ end
66
+
67
+ def x64_mingw?
68
+ Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu == "x64"
69
+ end
70
+
71
+ (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
72
+ trimmed_version = version.tr(".", "")
73
+ define_method(:"on_#{trimmed_version}?") do
74
+ RUBY_VERSION.start_with?("#{version}.")
75
+ end
76
+
77
+ KNOWN_PLATFORMS.each do |platform|
78
+ define_method(:"#{platform}_#{trimmed_version}?") do
79
+ send(:"#{platform}?") && send(:"on_#{trimmed_version}?")
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,744 @@
1
+ # frozen_string_literal: true
2
+ require "bundler/lockfile_parser"
3
+ require "digest/sha1"
4
+ require "set"
5
+
6
+ module Bundler
7
+ class Definition
8
+ include GemHelpers
9
+
10
+ attr_reader :dependencies, :platforms, :ruby_version, :locked_deps
11
+
12
+ # Given a gemfile and lockfile creates a Bundler definition
13
+ #
14
+ # @param gemfile [Pathname] Path to Gemfile
15
+ # @param lockfile [Pathname,nil] Path to Gemfile.lock
16
+ # @param unlock [Hash, Boolean, nil] Gems that have been requested
17
+ # to be updated or true if all gems should be updated
18
+ # @return [Bundler::Definition]
19
+ def self.build(gemfile, lockfile, unlock)
20
+ unlock ||= {}
21
+ gemfile = Pathname.new(gemfile).expand_path
22
+
23
+ raise GemfileNotFound, "#{gemfile} not found" unless gemfile.file?
24
+
25
+ Dsl.evaluate(gemfile, lockfile, unlock)
26
+ end
27
+
28
+ #
29
+ # How does the new system work?
30
+ #
31
+ # * Load information from Gemfile and Lockfile
32
+ # * Invalidate stale locked specs
33
+ # * All specs from stale source are stale
34
+ # * All specs that are reachable only through a stale
35
+ # dependency are stale.
36
+ # * If all fresh dependencies are satisfied by the locked
37
+ # specs, then we can try to resolve locally.
38
+ #
39
+ # @param lockfile [Pathname] Path to Gemfile.lock
40
+ # @param dependencies [Array(Bundler::Dependency)] array of dependencies from Gemfile
41
+ # @param sources [Bundler::SourceList]
42
+ # @param unlock [Hash, Boolean, nil] Gems that have been requested
43
+ # to be updated or true if all gems should be updated
44
+ # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
45
+ # @param optional_groups [Array(String)] A list of optional groups
46
+ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [])
47
+ @unlocking = unlock == true || !unlock.empty?
48
+
49
+ @dependencies = dependencies
50
+ @sources = sources
51
+ @unlock = unlock
52
+ @optional_groups = optional_groups
53
+ @remote = false
54
+ @specs = nil
55
+ @ruby_version = ruby_version
56
+
57
+ @lockfile_contents = String.new
58
+ @locked_bundler_version = nil
59
+ @locked_ruby_version = nil
60
+
61
+ if lockfile && File.exist?(lockfile)
62
+ @lockfile_contents = Bundler.read_file(lockfile)
63
+ locked = LockfileParser.new(@lockfile_contents)
64
+ @platforms = locked.platforms
65
+ @locked_bundler_version = locked.bundler_version
66
+ @locked_ruby_version = locked.ruby_version
67
+
68
+ if unlock != true
69
+ @locked_deps = locked.dependencies
70
+ @locked_specs = SpecSet.new(locked.specs)
71
+ @locked_sources = locked.sources
72
+ else
73
+ @unlock = {}
74
+ @locked_deps = []
75
+ @locked_specs = SpecSet.new([])
76
+ @locked_sources = []
77
+ end
78
+ else
79
+ @unlock = {}
80
+ @platforms = []
81
+ @locked_deps = []
82
+ @locked_specs = SpecSet.new([])
83
+ @locked_sources = []
84
+ end
85
+
86
+ @unlock[:gems] ||= []
87
+ @unlock[:sources] ||= []
88
+ @unlock[:ruby] ||= if @ruby_version && @locked_ruby_version
89
+ unless locked_ruby_version_object = RubyVersion.from_string(@locked_ruby_version)
90
+ raise LockfileError, "Failed to create a `RubyVersion` object from " \
91
+ "`#{@locked_ruby_version}` found in #{lockfile} -- try running `bundle update --ruby`."
92
+ end
93
+ @ruby_version.diff(locked_ruby_version_object)
94
+ end
95
+ @unlocking ||= @unlock[:ruby] || (!@locked_ruby_version ^ !@ruby_version)
96
+
97
+ current_platform = Bundler.rubygems.platforms.map {|p| generic(p) }.compact.last
98
+ add_platform(current_platform)
99
+
100
+ @path_changes = converge_paths
101
+ eager_unlock = expand_dependencies(@unlock[:gems])
102
+ @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
103
+
104
+ @source_changes = converge_sources
105
+ @dependency_changes = converge_dependencies
106
+ @local_changes = converge_locals
107
+
108
+ fixup_dependency_types!
109
+ end
110
+
111
+ def fixup_dependency_types!
112
+ # XXX This is a temporary workaround for a bug when using rubygems 1.8.15
113
+ # where Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
114
+ # doesn't carry a notion of the dependency type, if you use
115
+ # add_development_dependency in a gemspec that's loaded with the gemspec
116
+ # directive, the lockfile dependencies and resolved dependencies end up
117
+ # with a mismatch on #type.
118
+ # Test coverage to catch a regression on this is in gemspec_spec.rb
119
+ @dependencies.each do |d|
120
+ if ld = @locked_deps.find {|l| l.name == d.name }
121
+ ld.instance_variable_set(:@type, d.type)
122
+ end
123
+ end
124
+ end
125
+
126
+ def resolve_with_cache!
127
+ raise "Specs already loaded" if @specs
128
+ sources.cached!
129
+ specs
130
+ end
131
+
132
+ def resolve_remotely!
133
+ raise "Specs already loaded" if @specs
134
+ @remote = true
135
+ sources.remote!
136
+ specs
137
+ end
138
+
139
+ # For given dependency list returns a SpecSet with Gemspec of all the required
140
+ # dependencies.
141
+ # 1. The method first resolves the dependencies specified in Gemfile
142
+ # 2. After that it tries and fetches gemspec of resolved dependencies
143
+ #
144
+ # @return [Bundler::SpecSet]
145
+ def specs
146
+ @specs ||= begin
147
+ begin
148
+ specs = resolve.materialize(Bundler.settings[:cache_all_platforms] ? dependencies : requested_dependencies)
149
+ rescue GemNotFound => e # Handle yanked gem
150
+ gem_name, gem_version = extract_gem_info(e)
151
+ locked_gem = @locked_specs[gem_name].last
152
+ raise if locked_gem.nil? || locked_gem.version.to_s != gem_version
153
+ raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
154
+ "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
155
+ "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
156
+ "to a different version of #{locked_gem} that hasn't been removed in order to install."
157
+ end
158
+ unless specs["bundler"].any?
159
+ local = Bundler.settings[:frozen] ? rubygems_index : index
160
+ bundler = local.search(Gem::Dependency.new("bundler", VERSION)).last
161
+ specs["bundler"] = bundler if bundler
162
+ end
163
+
164
+ specs
165
+ end
166
+ end
167
+
168
+ def new_specs
169
+ specs - @locked_specs
170
+ end
171
+
172
+ def removed_specs
173
+ @locked_specs - specs
174
+ end
175
+
176
+ def new_platform?
177
+ @new_platform
178
+ end
179
+
180
+ def missing_specs
181
+ missing = []
182
+ resolve.materialize(requested_dependencies, missing)
183
+ missing
184
+ end
185
+
186
+ def missing_dependencies
187
+ missing = []
188
+ resolve.materialize(current_dependencies, missing)
189
+ missing
190
+ end
191
+
192
+ def requested_specs
193
+ @requested_specs ||= begin
194
+ groups = requested_groups
195
+ groups.map!(&:to_sym)
196
+ specs_for(groups)
197
+ end
198
+ end
199
+
200
+ def current_dependencies
201
+ dependencies.reject {|d| !d.should_include? }
202
+ end
203
+
204
+ def specs_for(groups)
205
+ deps = dependencies.select {|d| (d.groups & groups).any? }
206
+ deps.delete_if {|d| !d.should_include? }
207
+ specs.for(expand_dependencies(deps))
208
+ end
209
+
210
+ # Resolve all the dependencies specified in Gemfile. It ensures that
211
+ # dependencies that have been already resolved via locked file and are fresh
212
+ # are reused when resolving dependencies
213
+ #
214
+ # @return [SpecSet] resolved dependencies
215
+ def resolve
216
+ @resolve ||= begin
217
+ last_resolve = converge_locked_specs
218
+ if Bundler.settings[:frozen] || (!@unlocking && nothing_changed?)
219
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
220
+ last_resolve
221
+ else
222
+ # Run a resolve against the locally available gems
223
+ Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies")
224
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, ruby_version)
225
+ end
226
+ end
227
+ end
228
+
229
+ def index
230
+ @index ||= Index.build do |idx|
231
+ dependency_names = @dependencies.map(&:name)
232
+
233
+ sources.all_sources.each do |source|
234
+ source.dependency_names = dependency_names.dup
235
+ idx.add_source source.specs
236
+ dependency_names -= pinned_spec_names(source.specs)
237
+ dependency_names.concat(source.unmet_deps).uniq!
238
+ end
239
+ end
240
+ end
241
+
242
+ # used when frozen is enabled so we can find the bundler
243
+ # spec, even if (say) a git gem is not checked out.
244
+ def rubygems_index
245
+ @rubygems_index ||= Index.build do |idx|
246
+ sources.rubygems_sources.each do |rubygems|
247
+ idx.add_source rubygems.specs
248
+ end
249
+ end
250
+ end
251
+
252
+ def has_rubygems_remotes?
253
+ sources.rubygems_sources.any? {|s| s.remotes.any? }
254
+ end
255
+
256
+ def has_local_dependencies?
257
+ !sources.path_sources.empty? || !sources.git_sources.empty?
258
+ end
259
+
260
+ def spec_git_paths
261
+ sources.git_sources.map {|s| s.path.to_s }
262
+ end
263
+
264
+ def groups
265
+ dependencies.map(&:groups).flatten.uniq
266
+ end
267
+
268
+ def lock(file, preserve_unknown_sections = false)
269
+ contents = to_lock
270
+
271
+ # Convert to \r\n if the existing lock has them
272
+ # i.e., Windows with `git config core.autocrlf=true`
273
+ contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
274
+
275
+ if @locked_bundler_version
276
+ locked_major = @locked_bundler_version.segments.first
277
+ current_major = Gem::Version.create(Bundler::VERSION).segments.first
278
+
279
+ if updating_major = locked_major < current_major
280
+ Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \
281
+ "after which you will be unable to return to Bundler #{@locked_bundler_version.segments.first}."
282
+ end
283
+ end
284
+
285
+ preserve_unknown_sections ||= !updating_major && (Bundler.settings[:frozen] || !@unlocking)
286
+ return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
287
+
288
+ if Bundler.settings[:frozen]
289
+ Bundler.ui.error "Cannot write a changed lockfile while frozen."
290
+ return
291
+ end
292
+
293
+ SharedHelpers.filesystem_access(file) do |p|
294
+ File.open(p, "wb") {|f| f.puts(contents) }
295
+ end
296
+ end
297
+
298
+ def locked_bundler_version
299
+ if @locked_bundler_version && @locked_bundler_version < Gem::Version.new(Bundler::VERSION)
300
+ new_version = Bundler::VERSION
301
+ end
302
+
303
+ new_version || @locked_bundler_version || Bundler::VERSION
304
+ end
305
+
306
+ def locked_ruby_version
307
+ return unless ruby_version
308
+ if @unlock[:ruby] || !@locked_ruby_version
309
+ Bundler::RubyVersion.system
310
+ else
311
+ @locked_ruby_version
312
+ end
313
+ end
314
+
315
+ def to_lock
316
+ out = String.new
317
+
318
+ sources.lock_sources.each do |source|
319
+ # Add the source header
320
+ out << source.to_lock
321
+ # Find all specs for this source
322
+ resolve.
323
+ select {|s| source.can_lock?(s) }.
324
+ # This needs to be sorted by full name so that
325
+ # gems with the same name, but different platform
326
+ # are ordered consistently
327
+ sort_by(&:full_name).
328
+ each do |spec|
329
+ next if spec.name == "bundler"
330
+ out << spec.to_lock
331
+ end
332
+ out << "\n"
333
+ end
334
+
335
+ out << "PLATFORMS\n"
336
+
337
+ platforms.map(&:to_s).sort.each do |p|
338
+ out << " #{p}\n"
339
+ end
340
+
341
+ out << "\n"
342
+ out << "DEPENDENCIES\n"
343
+
344
+ handled = []
345
+ dependencies.sort_by(&:to_s).each do |dep|
346
+ next if handled.include?(dep.name)
347
+ out << dep.to_lock
348
+ handled << dep.name
349
+ end
350
+
351
+ if locked_ruby_version
352
+ out << "\nRUBY VERSION\n"
353
+ out << " #{locked_ruby_version}\n"
354
+ end
355
+
356
+ # Record the version of Bundler that was used to create the lockfile
357
+ out << "\nBUNDLED WITH\n"
358
+ out << " #{locked_bundler_version}\n"
359
+
360
+ out
361
+ end
362
+
363
+ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
364
+ msg = String.new
365
+ msg << "You are trying to install in deployment mode after changing\n" \
366
+ "your Gemfile. Run `bundle install` elsewhere and add the\n" \
367
+ "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
368
+
369
+ unless explicit_flag
370
+ msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
371
+ "freeze \nby running `bundle install --no-deployment`."
372
+ end
373
+
374
+ added = []
375
+ deleted = []
376
+ changed = []
377
+
378
+ gemfile_sources = sources.lock_sources
379
+
380
+ new_sources = gemfile_sources - @locked_sources
381
+ deleted_sources = @locked_sources - gemfile_sources
382
+
383
+ new_deps = @dependencies - @locked_deps
384
+ deleted_deps = @locked_deps - @dependencies
385
+
386
+ # Check if it is possible that the source is only changed thing
387
+ if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
388
+ new_sources.reject! {|source| source.is_a_path? && source.path.exist? }
389
+ deleted_sources.reject! {|source| source.is_a_path? && source.path.exist? }
390
+ end
391
+
392
+ if @locked_sources != gemfile_sources
393
+ if new_sources.any?
394
+ added.concat new_sources.map {|source| "* source: #{source}" }
395
+ end
396
+
397
+ if deleted_sources.any?
398
+ deleted.concat deleted_sources.map {|source| "* source: #{source}" }
399
+ end
400
+ end
401
+
402
+ added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
403
+ if deleted_deps.any?
404
+ deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" }
405
+ end
406
+
407
+ both_sources = Hash.new {|h, k| h[k] = [] }
408
+ @dependencies.each {|d| both_sources[d.name][0] = d }
409
+ @locked_deps.each {|d| both_sources[d.name][1] = d.source }
410
+
411
+ both_sources.each do |name, (dep, lock_source)|
412
+ next unless (dep.nil? && !lock_source.nil?) || (!dep.nil? && !lock_source.nil? && !lock_source.can_lock?(dep))
413
+ gemfile_source_name = (dep && dep.source) || "no specified source"
414
+ lockfile_source_name = lock_source || "no specified source"
415
+ changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
416
+ end
417
+
418
+ msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
419
+ msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
420
+ msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
421
+ msg << "\n"
422
+
423
+ raise ProductionError, msg if added.any? || deleted.any? || changed.any?
424
+ end
425
+
426
+ def validate_ruby!
427
+ return unless ruby_version
428
+
429
+ if diff = ruby_version.diff(Bundler::RubyVersion.system)
430
+ problem, expected, actual = diff
431
+
432
+ msg = case problem
433
+ when :engine
434
+ "Your Ruby engine is #{actual}, but your Gemfile specified #{expected}"
435
+ when :version
436
+ "Your Ruby version is #{actual}, but your Gemfile specified #{expected}"
437
+ when :engine_version
438
+ "Your #{Bundler::RubyVersion.system.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}"
439
+ when :patchlevel
440
+ if !expected.is_a?(String)
441
+ "The Ruby patchlevel in your Gemfile must be a string"
442
+ else
443
+ "Your Ruby patchlevel is #{actual}, but your Gemfile specified #{expected}"
444
+ end
445
+ end
446
+
447
+ raise RubyVersionMismatch, msg
448
+ end
449
+ end
450
+
451
+ def add_platform(platform)
452
+ @new_platform ||= !@platforms.include?(platform)
453
+ @platforms |= [platform]
454
+ end
455
+
456
+ attr_reader :sources
457
+ private :sources
458
+
459
+ private
460
+
461
+ def nothing_changed?
462
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes
463
+ end
464
+
465
+ def pretty_dep(dep, source = false)
466
+ msg = String.new(dep.name)
467
+ msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
468
+ msg << " from the `#{dep.source}` source" if source && dep.source
469
+ msg
470
+ end
471
+
472
+ # Check if the specs of the given source changed
473
+ # according to the locked source. A block should be
474
+ # in order to specify how the locked version of
475
+ # the source should be found.
476
+ def specs_changed?(source, &block)
477
+ locked = @locked_sources.find(&block)
478
+
479
+ if locked
480
+ unlocking = @locked_specs.any? do |locked_spec|
481
+ locked_spec.source.class == locked.class && locked_spec.source != locked
482
+ end
483
+ end
484
+
485
+ !locked || unlocking || dependencies_for_source_changed?(source) || specs_for_source_changed?(source)
486
+ end
487
+
488
+ def dependencies_for_source_changed?(source)
489
+ deps_for_source = @dependencies.select {|s| s.source == source }
490
+ locked_deps_for_source = @locked_deps.select {|s| s.source == source }
491
+
492
+ Set.new(deps_for_source) != Set.new(locked_deps_for_source)
493
+ end
494
+
495
+ def specs_for_source_changed?(source)
496
+ locked_index = Index.new
497
+ locked_index.use(@locked_specs.select {|s| source.can_lock?(s) })
498
+
499
+ source.specs != locked_index
500
+ end
501
+
502
+ # Get all locals and override their matching sources.
503
+ # Return true if any of the locals changed (for example,
504
+ # they point to a new revision) or depend on new specs.
505
+ def converge_locals
506
+ locals = []
507
+
508
+ Bundler.settings.local_overrides.map do |k, v|
509
+ spec = @dependencies.find {|s| s.name == k }
510
+ source = spec && spec.source
511
+ if source && source.respond_to?(:local_override!)
512
+ source.unlock! if @unlock[:gems].include?(spec.name)
513
+ locals << [source, source.local_override!(v)]
514
+ end
515
+ end
516
+
517
+ locals.any? do |source, changed|
518
+ changed || specs_changed?(source) {|o| source.class == o.class && source.uri == o.uri }
519
+ end
520
+ end
521
+
522
+ def converge_paths
523
+ sources.path_sources.any? do |source|
524
+ specs_changed?(source) do |ls|
525
+ ls.class == source.class && ls.path == source.path
526
+ end
527
+ end
528
+ end
529
+
530
+ def converge_sources
531
+ changes = false
532
+
533
+ # Get the Rubygems sources from the Gemfile.lock
534
+ locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
535
+ # Get the Rubygems remotes from the Gemfile
536
+ actual_remotes = sources.rubygems_remotes
537
+
538
+ # If there is a Rubygems source in both
539
+ if !locked_gem_sources.empty? && !actual_remotes.empty?
540
+ locked_gem_sources.each do |locked_gem|
541
+ # Merge the remotes from the Gemfile into the Gemfile.lock
542
+ changes |= locked_gem.replace_remotes(actual_remotes)
543
+ end
544
+ end
545
+
546
+ # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
547
+ # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
548
+ # source in the Gemfile.lock, use the one from the Gemfile.
549
+ changes |= sources.replace_sources!(@locked_sources)
550
+
551
+ sources.all_sources.each do |source|
552
+ # If the source is unlockable and the current command allows an unlock of
553
+ # the source (for example, you are doing a `bundle update <foo>` of a git-pinned
554
+ # gem), unlock it. For git sources, this means to unlock the revision, which
555
+ # will cause the `ref` used to be the most recent for the branch (or master) if
556
+ # an explicit `ref` is not used.
557
+ if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name)
558
+ source.unlock!
559
+ changes = true
560
+ end
561
+ end
562
+
563
+ changes
564
+ end
565
+
566
+ def converge_dependencies
567
+ (@dependencies + @locked_deps).each do |dep|
568
+ locked_source = @locked_deps.select {|d| d.name == dep.name }.last
569
+ # This is to make sure that if bundler is installing in deployment mode and
570
+ # after locked_source and sources don't match, we still use locked_source.
571
+ if Bundler.settings[:frozen] && !locked_source.nil? &&
572
+ locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
573
+ dep.source = locked_source.source
574
+ elsif dep.source
575
+ dep.source = sources.get(dep.source)
576
+ end
577
+ end
578
+ Set.new(@dependencies) != Set.new(@locked_deps)
579
+ end
580
+
581
+ # Remove elements from the locked specs that are expired. This will most
582
+ # commonly happen if the Gemfile has changed since the lockfile was last
583
+ # generated
584
+ def converge_locked_specs
585
+ deps = []
586
+
587
+ # Build a list of dependencies that are the same in the Gemfile
588
+ # and Gemfile.lock. If the Gemfile modified a dependency, but
589
+ # the gem in the Gemfile.lock still satisfies it, this is fine
590
+ # too.
591
+ locked_deps_hash = @locked_deps.inject({}) do |hsh, dep|
592
+ hsh[dep] = dep
593
+ hsh
594
+ end
595
+ @dependencies.each do |dep|
596
+ locked_dep = locked_deps_hash[dep]
597
+
598
+ if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
599
+ deps << dep
600
+ elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source)
601
+ @locked_specs.each do |s|
602
+ @unlock[:gems] << s.name if s.source == dep.source
603
+ end
604
+
605
+ dep.source.unlock! if dep.source.respond_to?(:unlock!)
606
+ dep.source.specs.each {|s| @unlock[:gems] << s.name }
607
+ end
608
+ end
609
+
610
+ converged = []
611
+ @locked_specs.each do |s|
612
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
613
+ dep = @dependencies.find {|d| s.satisfies?(d) }
614
+ s.source = (dep && dep.source) || sources.get(s.source)
615
+
616
+ # Don't add a spec to the list if its source is expired. For example,
617
+ # if you change a Git gem to Rubygems.
618
+ next if s.source.nil? || @unlock[:sources].include?(s.source.name)
619
+
620
+ # XXX This is a backwards-compatibility fix to preserve the ability to
621
+ # unlock a single gem by passing its name via `--source`. See issue #3759
622
+ next if s.source.nil? || @unlock[:sources].include?(s.name)
623
+
624
+ # If the spec is from a path source and it doesn't exist anymore
625
+ # then we unlock it.
626
+
627
+ # Path sources have special logic
628
+ if s.source.instance_of?(Source::Path)
629
+ other = s.source.specs[s].first
630
+
631
+ # If the spec is no longer in the path source, unlock it. This
632
+ # commonly happens if the version changed in the gemspec
633
+ next unless other
634
+
635
+ deps2 = other.dependencies.select {|d| d.type != :development }
636
+ # If the dependencies of the path source have changed, unlock it
637
+ next unless s.dependencies.sort == deps2.sort
638
+ end
639
+
640
+ converged << s
641
+ end
642
+
643
+ resolve = SpecSet.new(converged)
644
+ resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems])
645
+ diff = @locked_specs.to_a - resolve.to_a
646
+
647
+ # Now, we unlock any sources that do not have anymore gems pinned to it
648
+ sources.all_sources.each do |source|
649
+ next unless source.respond_to?(:unlock!)
650
+
651
+ unless resolve.any? {|s| s.source == source }
652
+ source.unlock! if !diff.empty? && diff.any? {|s| s.source == source }
653
+ end
654
+ end
655
+
656
+ resolve
657
+ end
658
+
659
+ def in_locked_deps?(dep, locked_dep)
660
+ # Because the lockfile can't link a dep to a specific remote, we need to
661
+ # treat sources as equivalent anytime the locked dep has all the remotes
662
+ # that the Gemfile dep does.
663
+ locked_dep && locked_dep.source && dep.source && locked_dep.source.include?(dep.source)
664
+ end
665
+
666
+ def satisfies_locked_spec?(dep)
667
+ @locked_specs.any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
668
+ end
669
+
670
+ def expanded_dependencies
671
+ @expanded_dependencies ||= expand_dependencies(dependencies, @remote)
672
+ end
673
+
674
+ def expand_dependencies(dependencies, remote = false)
675
+ deps = []
676
+ dependencies.each do |dep|
677
+ dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
678
+ next unless remote || dep.current_platform?
679
+ dep.gem_platforms(@platforms).each do |p|
680
+ deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
681
+ end
682
+ end
683
+ deps
684
+ end
685
+
686
+ def requested_dependencies
687
+ groups = requested_groups
688
+ groups.map!(&:to_sym)
689
+ dependencies.reject {|d| !d.should_include? || (d.groups & groups).empty? }
690
+ end
691
+
692
+ def source_requirements
693
+ # Load all specs from remote sources
694
+ index
695
+
696
+ # Record the specs available in each gem's source, so that those
697
+ # specs will be available later when the resolver knows where to
698
+ # look for that gemspec (or its dependencies)
699
+ source_requirements = {}
700
+ dependencies.each do |dep|
701
+ next unless dep.source
702
+ source_requirements[dep.name] = dep.source.specs
703
+ end
704
+ source_requirements
705
+ end
706
+
707
+ def pinned_spec_names(specs)
708
+ names = []
709
+ specs.each do |s|
710
+ # TODO: when two sources without blocks is an error, we can change
711
+ # this check to !s.source.is_a?(Source::LocalRubygems). For now,
712
+ # we need to ask every Rubygems for every gem name.
713
+ if s.source.is_a?(Source::Git) || s.source.is_a?(Source::Path)
714
+ names << s.name
715
+ end
716
+ end
717
+ names.uniq!
718
+ names
719
+ end
720
+
721
+ def requested_groups
722
+ groups - Bundler.settings.without - @optional_groups + Bundler.settings.with
723
+ end
724
+
725
+ def lockfiles_equal?(current, proposed, preserve_unknown_sections)
726
+ if preserve_unknown_sections
727
+ sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
728
+ sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
729
+ sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
730
+ pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
731
+ whitespace_cleanup = /\n{2,}/
732
+ current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
733
+ proposed = proposed.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
734
+ end
735
+ current == proposed
736
+ end
737
+
738
+ def extract_gem_info(error)
739
+ # This method will extract the error message like "Could not find foo-1.2.3 in any of the sources"
740
+ # to an array. The first element will be the gem name (e.g. foo), the second will be the version number.
741
+ error.message.scan(/Could not find (\w+)-(\d+(?:\.\d+)+)/).flatten
742
+ end
743
+ end
744
+ end