bundler 1.15.1 → 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 (294) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +320 -0
  3. data/README.md +17 -8
  4. data/bundler.gemspec +25 -9
  5. data/exe/bundle +1 -6
  6. data/exe/bundle_ruby +4 -3
  7. data/lib/bundler/build_metadata.rb +53 -0
  8. data/lib/bundler/capistrano.rb +5 -0
  9. data/lib/bundler/cli/add.rb +15 -6
  10. data/lib/bundler/cli/binstubs.rb +17 -9
  11. data/lib/bundler/cli/cache.rb +5 -4
  12. data/lib/bundler/cli/check.rb +3 -5
  13. data/lib/bundler/cli/clean.rb +5 -6
  14. data/lib/bundler/cli/common.rb +11 -2
  15. data/lib/bundler/cli/config.rb +2 -1
  16. data/lib/bundler/cli/console.rb +2 -1
  17. data/lib/bundler/cli/doctor.rb +48 -1
  18. data/lib/bundler/cli/exec.rb +6 -5
  19. data/lib/bundler/cli/gem.rb +13 -8
  20. data/lib/bundler/cli/info.rb +0 -1
  21. data/lib/bundler/cli/init.rb +18 -6
  22. data/lib/bundler/cli/inject.rb +1 -0
  23. data/lib/bundler/cli/install.rb +64 -77
  24. data/lib/bundler/cli/issue.rb +1 -1
  25. data/lib/bundler/cli/list.rb +58 -0
  26. data/lib/bundler/cli/lock.rb +0 -1
  27. data/lib/bundler/cli/open.rb +2 -2
  28. data/lib/bundler/cli/outdated.rb +20 -9
  29. data/lib/bundler/cli/package.rb +9 -6
  30. data/lib/bundler/cli/platform.rb +1 -0
  31. data/lib/bundler/cli/plugin.rb +1 -0
  32. data/lib/bundler/cli/pristine.rb +20 -6
  33. data/lib/bundler/cli/remove.rb +18 -0
  34. data/lib/bundler/cli/show.rb +0 -1
  35. data/lib/bundler/cli/update.rb +35 -7
  36. data/lib/bundler/cli/viz.rb +4 -0
  37. data/lib/bundler/cli.rb +234 -90
  38. data/lib/bundler/compact_index_client/cache.rb +1 -2
  39. data/lib/bundler/compact_index_client/updater.rb +35 -7
  40. data/lib/bundler/compact_index_client.rb +1 -0
  41. data/lib/bundler/compatibility_guard.rb +14 -0
  42. data/lib/bundler/constants.rb +1 -0
  43. data/lib/bundler/current_ruby.rb +13 -5
  44. data/lib/bundler/definition.rb +192 -139
  45. data/lib/bundler/dep_proxy.rb +3 -1
  46. data/lib/bundler/dependency.rb +9 -9
  47. data/lib/bundler/deployment.rb +1 -1
  48. data/lib/bundler/deprecate.rb +15 -3
  49. data/lib/bundler/dsl.rb +115 -64
  50. data/lib/bundler/endpoint_specification.rb +10 -1
  51. data/lib/bundler/env.rb +90 -29
  52. data/lib/bundler/environment_preserver.rb +27 -6
  53. data/lib/bundler/errors.rb +1 -0
  54. data/lib/bundler/feature_flag.rb +46 -4
  55. data/lib/bundler/fetcher/base.rb +1 -0
  56. data/lib/bundler/fetcher/compact_index.rb +2 -11
  57. data/lib/bundler/fetcher/dependency.rb +2 -1
  58. data/lib/bundler/fetcher/downloader.rb +11 -5
  59. data/lib/bundler/fetcher/index.rb +3 -2
  60. data/lib/bundler/fetcher.rb +18 -11
  61. data/lib/bundler/friendly_errors.rb +6 -1
  62. data/lib/bundler/gem_helper.rb +19 -10
  63. data/lib/bundler/gem_helpers.rb +1 -0
  64. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  65. data/lib/bundler/gem_tasks.rb +1 -0
  66. data/lib/bundler/gem_version_promoter.rb +17 -2
  67. data/lib/bundler/gemdeps.rb +1 -0
  68. data/lib/bundler/graph.rb +1 -0
  69. data/lib/bundler/index.rb +8 -8
  70. data/lib/bundler/injector.rb +192 -30
  71. data/lib/bundler/inline.rb +10 -10
  72. data/lib/bundler/installer/gem_installer.rb +12 -2
  73. data/lib/bundler/installer/parallel_installer.rb +78 -42
  74. data/lib/bundler/installer/standalone.rb +1 -0
  75. data/lib/bundler/installer.rb +138 -53
  76. data/lib/bundler/lazy_specification.rb +3 -2
  77. data/lib/bundler/lockfile_generator.rb +95 -0
  78. data/lib/bundler/lockfile_parser.rb +10 -4
  79. data/lib/bundler/match_platform.rb +1 -0
  80. data/lib/bundler/mirror.rb +8 -5
  81. data/lib/bundler/plugin/api/source.rb +9 -2
  82. data/lib/bundler/plugin/events.rb +61 -0
  83. data/lib/bundler/plugin/index.rb +7 -2
  84. data/lib/bundler/plugin/installer.rb +7 -6
  85. data/lib/bundler/plugin/source_list.rb +7 -8
  86. data/lib/bundler/plugin.rb +13 -5
  87. data/lib/bundler/process_lock.rb +24 -0
  88. data/lib/bundler/psyched_yaml.rb +10 -0
  89. data/lib/bundler/remote_specification.rb +10 -1
  90. data/lib/bundler/resolver/spec_group.rb +106 -0
  91. data/lib/bundler/resolver.rb +158 -195
  92. data/lib/bundler/retry.rb +1 -0
  93. data/lib/bundler/ruby_dsl.rb +1 -0
  94. data/lib/bundler/ruby_version.rb +2 -1
  95. data/lib/bundler/rubygems_ext.rb +5 -4
  96. data/lib/bundler/rubygems_gem_installer.rb +31 -1
  97. data/lib/bundler/rubygems_integration.rb +71 -32
  98. data/lib/bundler/runtime.rb +11 -9
  99. data/lib/bundler/settings/validator.rb +102 -0
  100. data/lib/bundler/settings.rb +213 -86
  101. data/lib/bundler/setup.rb +4 -7
  102. data/lib/bundler/shared_helpers.rb +131 -26
  103. data/lib/bundler/similarity_detector.rb +1 -0
  104. data/lib/bundler/source/gemspec.rb +1 -0
  105. data/lib/bundler/source/git/git_proxy.rb +21 -11
  106. data/lib/bundler/source/git.rb +24 -19
  107. data/lib/bundler/source/metadata.rb +62 -0
  108. data/lib/bundler/source/path/installer.rb +2 -0
  109. data/lib/bundler/source/path.rb +11 -7
  110. data/lib/bundler/source/rubygems/remote.rb +8 -2
  111. data/lib/bundler/source/rubygems.rb +161 -84
  112. data/lib/bundler/source.rb +36 -0
  113. data/lib/bundler/source_list.rb +75 -15
  114. data/lib/bundler/spec_set.rb +12 -6
  115. data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  116. data/lib/bundler/stub_specification.rb +1 -0
  117. data/lib/bundler/templates/.document +1 -0
  118. data/lib/bundler/templates/Executable +12 -0
  119. data/lib/bundler/templates/Executable.bundler +105 -0
  120. data/lib/bundler/templates/Gemfile +3 -0
  121. data/lib/bundler/templates/gems.rb +8 -0
  122. data/lib/bundler/templates/newgem/Gemfile.tt +2 -0
  123. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  124. data/lib/bundler/templates/newgem/gitignore.tt +0 -1
  125. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  126. data/lib/bundler/templates/newgem/newgem.gemspec.tt +12 -3
  127. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  128. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  129. data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
  130. data/lib/bundler/ui/rg_proxy.rb +1 -0
  131. data/lib/bundler/ui/shell.rb +17 -4
  132. data/lib/bundler/ui/silent.rb +1 -0
  133. data/lib/bundler/ui.rb +1 -0
  134. data/lib/bundler/uri_credentials_filter.rb +1 -0
  135. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  136. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  137. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  138. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  139. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  140. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -0
  141. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  142. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  143. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  144. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  145. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  146. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  147. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +15 -4
  148. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -2
  149. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
  150. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  151. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  152. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  153. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +491 -148
  154. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  155. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  156. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  157. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +3 -1
  158. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -0
  159. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -0
  160. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +9 -1
  161. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +45 -8
  162. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +9 -3
  163. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -3
  164. data/lib/bundler/vendor/thor/lib/thor/base.rb +27 -4
  165. data/lib/bundler/vendor/thor/lib/thor/command.rb +9 -7
  166. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +12 -0
  167. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  168. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  169. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +5 -5
  170. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +6 -5
  171. data/lib/bundler/vendor/thor/lib/thor/runner.rb +6 -4
  172. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -9
  173. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  174. data/lib/bundler/vendor/thor/lib/thor.rb +25 -8
  175. data/lib/bundler/vendored_fileutils.rb +9 -0
  176. data/lib/bundler/vendored_molinillo.rb +1 -0
  177. data/lib/bundler/vendored_persistent.rb +35 -0
  178. data/lib/bundler/vendored_thor.rb +1 -0
  179. data/lib/bundler/version.rb +6 -2
  180. data/lib/bundler/version_ranges.rb +1 -0
  181. data/lib/bundler/vlad.rb +5 -0
  182. data/lib/bundler/worker.rb +1 -0
  183. data/lib/bundler/yaml_serializer.rb +3 -3
  184. data/lib/bundler.rb +86 -52
  185. data/man/bundle-add.1 +18 -3
  186. data/man/bundle-add.1.txt +26 -14
  187. data/man/bundle-add.ronn +13 -2
  188. data/man/bundle-binstubs.1 +11 -1
  189. data/man/bundle-binstubs.1.txt +33 -18
  190. data/man/bundle-binstubs.ronn +15 -1
  191. data/man/bundle-check.1 +4 -4
  192. data/man/bundle-check.1.txt +15 -14
  193. data/man/bundle-check.ronn +3 -3
  194. data/man/bundle-clean.1 +1 -1
  195. data/man/bundle-clean.1.txt +10 -10
  196. data/man/bundle-config.1 +129 -29
  197. data/man/bundle-config.1.txt +285 -174
  198. data/man/bundle-config.ronn +167 -88
  199. data/man/bundle-doctor.1 +44 -0
  200. data/man/bundle-doctor.1.txt +44 -0
  201. data/man/bundle-doctor.ronn +33 -0
  202. data/man/bundle-exec.1 +6 -3
  203. data/man/bundle-exec.1.txt +78 -71
  204. data/man/bundle-exec.ronn +10 -3
  205. data/man/bundle-gem.1 +4 -4
  206. data/man/bundle-gem.1.txt +41 -40
  207. data/man/bundle-gem.ronn +3 -2
  208. data/man/bundle-info.1 +1 -1
  209. data/man/bundle-info.1.txt +8 -8
  210. data/man/bundle-init.1 +9 -4
  211. data/man/bundle-init.1.txt +23 -13
  212. data/man/bundle-init.ronn +15 -4
  213. data/man/bundle-inject.1 +4 -4
  214. data/man/bundle-inject.1.txt +10 -10
  215. data/man/bundle-inject.ronn +3 -3
  216. data/man/bundle-install.1 +31 -28
  217. data/man/bundle-install.1.txt +205 -194
  218. data/man/bundle-install.ronn +44 -35
  219. data/man/bundle-list.1 +50 -0
  220. data/man/bundle-list.1.txt +43 -0
  221. data/man/bundle-list.ronn +33 -0
  222. data/man/bundle-lock.1 +1 -1
  223. data/man/bundle-lock.1.txt +47 -47
  224. data/man/bundle-lock.ronn +1 -1
  225. data/man/bundle-open.1 +1 -1
  226. data/man/bundle-open.1.txt +7 -7
  227. data/man/bundle-outdated.1 +7 -3
  228. data/man/bundle-outdated.1.txt +40 -36
  229. data/man/bundle-outdated.ronn +6 -2
  230. data/man/bundle-package.1 +6 -3
  231. data/man/bundle-package.1.txt +44 -39
  232. data/man/bundle-package.ronn +7 -2
  233. data/man/bundle-platform.1 +1 -1
  234. data/man/bundle-platform.1.txt +13 -13
  235. data/man/bundle-pristine.1 +21 -3
  236. data/man/bundle-pristine.1.txt +33 -10
  237. data/man/bundle-pristine.ronn +24 -3
  238. data/man/bundle-remove.1 +31 -0
  239. data/man/bundle-remove.1.txt +34 -0
  240. data/man/bundle-remove.ronn +23 -0
  241. data/man/bundle-show.1 +3 -3
  242. data/man/bundle-show.1.txt +14 -12
  243. data/man/bundle-show.ronn +3 -2
  244. data/man/bundle-update.1 +13 -9
  245. data/man/bundle-update.1.txt +133 -130
  246. data/man/bundle-update.ronn +21 -17
  247. data/man/bundle-viz.1 +7 -7
  248. data/man/bundle-viz.1.txt +17 -15
  249. data/man/bundle-viz.ronn +6 -6
  250. data/man/bundle.1 +31 -32
  251. data/man/bundle.1.txt +63 -75
  252. data/man/bundle.ronn +35 -47
  253. data/man/gemfile.5 +44 -8
  254. data/man/gemfile.5.ronn +54 -8
  255. data/man/gemfile.5.txt +218 -165
  256. data/man/index.txt +25 -15
  257. metadata +36 -44
  258. data/.codeclimate.yml +0 -25
  259. data/.gitignore +0 -18
  260. data/.rspec +0 -3
  261. data/.rubocop.yml +0 -131
  262. data/.rubocop_todo.yml +0 -418
  263. data/.travis.yml +0 -122
  264. data/CODE_OF_CONDUCT.md +0 -42
  265. data/CONTRIBUTING.md +0 -17
  266. data/Rakefile +0 -346
  267. data/bin/rake +0 -19
  268. data/bin/rspec +0 -15
  269. data/bin/rubocop +0 -17
  270. data/bin/with_rubygems +0 -39
  271. data/doc/README.md +0 -30
  272. data/doc/TROUBLESHOOTING.md +0 -64
  273. data/doc/contributing/BUG_TRIAGE.md +0 -36
  274. data/doc/contributing/COMMUNITY.md +0 -13
  275. data/doc/contributing/GETTING_HELP.md +0 -11
  276. data/doc/contributing/HOW_YOU_CAN_HELP.md +0 -27
  277. data/doc/contributing/ISSUES.md +0 -51
  278. data/doc/contributing/README.md +0 -38
  279. data/doc/development/NEW_FEATURES.md +0 -10
  280. data/doc/development/PULL_REQUESTS.md +0 -40
  281. data/doc/development/README.md +0 -19
  282. data/doc/development/RELEASING.md +0 -9
  283. data/doc/development/SETUP.md +0 -29
  284. data/doc/documentation/README.md +0 -29
  285. data/doc/documentation/VISION.md +0 -26
  286. data/doc/documentation/WRITING.md +0 -54
  287. data/lib/bundler/postit_trampoline.rb +0 -73
  288. data/lib/bundler/vendor/postit/lib/postit/environment.rb +0 -44
  289. data/lib/bundler/vendor/postit/lib/postit/installer.rb +0 -28
  290. data/lib/bundler/vendor/postit/lib/postit/parser.rb +0 -21
  291. data/lib/bundler/vendor/postit/lib/postit/setup.rb +0 -12
  292. data/lib/bundler/vendor/postit/lib/postit/version.rb +0 -3
  293. data/lib/bundler/vendor/postit/lib/postit.rb +0 -15
  294. data/task/release.rake +0 -116
data/lib/bundler/cli.rb CHANGED
@@ -1,10 +1,18 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler"
3
4
  require "bundler/vendored_thor"
4
5
 
5
6
  module Bundler
6
7
  class CLI < Thor
7
- AUTO_INSTALL_CMDS = %w(show binstubs outdated exec open console licenses clean).freeze
8
+ require "bundler/cli/common"
9
+
10
+ package_name "Bundler"
11
+
12
+ AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean].freeze
13
+ PARSEABLE_COMMANDS = %w[
14
+ check config help exec platform show version
15
+ ].freeze
8
16
 
9
17
  def self.start(*)
10
18
  super
@@ -12,12 +20,14 @@ module Bundler
12
20
  Bundler.ui = UI::Shell.new
13
21
  raise e
14
22
  ensure
15
- warn_on_outdated_bundler
16
23
  Bundler::SharedHelpers.print_major_deprecations!
17
24
  end
18
25
 
19
26
  def self.dispatch(*)
20
- super {|i| i.send(:print_command) }
27
+ super do |i|
28
+ i.send(:print_command)
29
+ i.send(:warn_on_outdated_bundler)
30
+ end
21
31
  end
22
32
 
23
33
  def initialize(*args)
@@ -25,11 +35,11 @@ module Bundler
25
35
 
26
36
  custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
27
37
  if custom_gemfile && !custom_gemfile.empty?
28
- ENV["BUNDLE_GEMFILE"] = File.expand_path(custom_gemfile)
38
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile)
29
39
  Bundler.reset_paths!
30
40
  end
31
41
 
32
- Bundler.settings[:retry] = options[:retry] if options[:retry]
42
+ Bundler.settings.set_command_option_if_given :retry, options[:retry]
33
43
 
34
44
  current_cmd = args.last[:current_command].name
35
45
  auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
@@ -37,7 +47,6 @@ module Bundler
37
47
  raise InvalidOption, e.message
38
48
  ensure
39
49
  self.options ||= {}
40
- Bundler.settings.cli_flags_given = !options.empty?
41
50
  unprinted_warnings = Bundler.ui.unprinted_warnings
42
51
  Bundler.ui = UI::Shell.new(options)
43
52
  Bundler.ui.level = "debug" if options["verbose"]
@@ -52,10 +61,41 @@ module Bundler
52
61
  end
53
62
  end
54
63
 
64
+ def self.deprecated_option(*args, &blk)
65
+ return if Bundler.feature_flag.forget_cli_options?
66
+ method_option(*args, &blk)
67
+ end
68
+
55
69
  check_unknown_options!(:except => [:config, :exec])
56
70
  stop_on_unknown_option! :exec
57
71
 
58
- default_task :install
72
+ desc "cli_help", "Prints a summary of bundler commands", :hide => true
73
+ def cli_help
74
+ version
75
+ Bundler.ui.info "\n"
76
+
77
+ primary_commands = ["install", "update",
78
+ Bundler.feature_flag.cache_command_is_package? ? "cache" : "package",
79
+ "exec", "config", "help"]
80
+
81
+ list = self.class.printable_commands(true)
82
+ by_name = list.group_by {|name, _message| name.match(/^bundle (\w+)/)[1] }
83
+ utilities = by_name.keys.sort - primary_commands
84
+ primary_commands.map! {|name| (by_name[name] || raise("no primary command #{name}")).first }
85
+ utilities.map! {|name| by_name[name].first }
86
+
87
+ shell.say "Bundler commands:\n\n"
88
+
89
+ shell.say " Primary commands:\n"
90
+ shell.print_table(primary_commands, :indent => 4, :truncate => true)
91
+ shell.say
92
+ shell.say " Utilities:\n"
93
+ shell.print_table(utilities, :indent => 4, :truncate => true)
94
+ shell.say
95
+ self.class.send(:class_options_help, shell)
96
+ end
97
+ default_task(Bundler.feature_flag.default_cli_command)
98
+
59
99
  class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
60
100
  class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
61
101
  :desc => "Specify the number of times you wish to attempt network commands"
@@ -86,9 +126,6 @@ module Bundler
86
126
  end
87
127
  end
88
128
 
89
- # Ensure `bundle help --no-color` is valid
90
- all_commands["help"].disable_class_options = false
91
-
92
129
  def self.handle_no_command_error(command, has_namespace = $thor_runner)
93
130
  if Bundler.feature_flag.plugins? && Bundler::Plugin.command?(command)
94
131
  return Bundler::Plugin.exec_command(command, ARGV[1..-1])
@@ -105,7 +142,7 @@ module Bundler
105
142
  Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
106
143
  dependency listed in the gemspec file to the newly created Gemfile.
107
144
  D
108
- method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
145
+ deprecated_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
109
146
  def init
110
147
  require "bundler/cli/init"
111
148
  Init.new(options.dup).run
@@ -122,13 +159,24 @@ module Bundler
122
159
  method_option "gemfile", :type => :string, :banner =>
123
160
  "Use the specified gemfile instead of Gemfile"
124
161
  method_option "path", :type => :string, :banner =>
125
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
162
+ "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
126
163
  map "c" => "check"
127
164
  def check
128
165
  require "bundler/cli/check"
129
166
  Check.new(options).run
130
167
  end
131
168
 
169
+ desc "remove [GEM [GEM ...]]", "Removes gems from the Gemfile"
170
+ long_desc <<-D
171
+ Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning.
172
+ D
173
+ method_option "install", :type => :boolean, :banner =>
174
+ "Runs 'bundle install' after removing the gems from the Gemfile"
175
+ def remove(*gems)
176
+ require "bundler/cli/remove"
177
+ Remove.new(gems, options).run
178
+ end
179
+
132
180
  desc "install [OPTIONS]", "Install the current environment to the system"
133
181
  long_desc <<-D
134
182
  Install will install all of the gems in the current bundle, making them available
@@ -140,13 +188,13 @@ module Bundler
140
188
 
141
189
  If the bundle has already been installed, bundler will tell you so and then exit.
142
190
  D
143
- method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
191
+ deprecated_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
144
192
  "Generate bin stubs for bundled gems to ./bin"
145
- method_option "clean", :type => :boolean, :banner =>
193
+ deprecated_option "clean", :type => :boolean, :banner =>
146
194
  "Run bundle clean automatically after install"
147
- method_option "deployment", :type => :boolean, :banner =>
195
+ deprecated_option "deployment", :type => :boolean, :banner =>
148
196
  "Install using defaults tuned for deployment environments"
149
- method_option "frozen", :type => :boolean, :banner =>
197
+ deprecated_option "frozen", :type => :boolean, :banner =>
150
198
  "Do not allow the Gemfile.lock to be updated after this install"
151
199
  method_option "full-index", :type => :boolean, :banner =>
152
200
  "Fall back to using the single-file index of all gems"
@@ -156,38 +204,39 @@ module Bundler
156
204
  "Specify the number of jobs to run in parallel"
157
205
  method_option "local", :type => :boolean, :banner =>
158
206
  "Do not attempt to fetch gems remotely and use the gem cache instead"
159
- method_option "no-cache", :type => :boolean, :banner =>
207
+ deprecated_option "no-cache", :type => :boolean, :banner =>
160
208
  "Don't update the existing gem cache."
161
- method_option "force", :type => :boolean, :banner =>
209
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
162
210
  "Force downloading every gem."
163
- method_option "no-prune", :type => :boolean, :banner =>
211
+ deprecated_option "no-prune", :type => :boolean, :banner =>
164
212
  "Don't remove stale gems from the cache."
165
- method_option "path", :type => :string, :banner =>
213
+ deprecated_option "path", :type => :string, :banner =>
166
214
  "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
167
215
  method_option "quiet", :type => :boolean, :banner =>
168
216
  "Only output warnings and errors."
169
- method_option "shebang", :type => :string, :banner =>
217
+ deprecated_option "shebang", :type => :string, :banner =>
170
218
  "Specify a different shebang executable name than the default (usually 'ruby')"
171
219
  method_option "standalone", :type => :array, :lazy_default => [], :banner =>
172
220
  "Make a bundle that can work without the Bundler runtime"
173
- method_option "system", :type => :boolean, :banner =>
221
+ deprecated_option "system", :type => :boolean, :banner =>
174
222
  "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
175
223
  method_option "trust-policy", :alias => "P", :type => :string, :banner =>
176
224
  "Gem trust policy (like gem install -P). Must be one of " +
177
225
  Bundler.rubygems.security_policy_keys.join("|")
178
- method_option "without", :type => :array, :banner =>
226
+ deprecated_option "without", :type => :array, :banner =>
179
227
  "Exclude gems that are part of the specified named group."
180
- method_option "with", :type => :array, :banner =>
228
+ deprecated_option "with", :type => :array, :banner =>
181
229
  "Include gems that are part of the specified named group."
182
230
  map "i" => "install"
183
231
  def install
232
+ SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
184
233
  require "bundler/cli/install"
185
234
  Bundler.settings.temporary(:no_install => false) do
186
235
  Install.new(options.dup).run
187
236
  end
188
237
  end
189
238
 
190
- desc "update [OPTIONS]", "update the current environment"
239
+ desc "update [OPTIONS]", "Update the current environment"
191
240
  long_desc <<-D
192
241
  Update will install the newest versions of the gems listed in the Gemfile. Use
193
242
  update when you have changed the Gemfile, or if you want to get the newest
@@ -195,6 +244,8 @@ module Bundler
195
244
  D
196
245
  method_option "full-index", :type => :boolean, :banner =>
197
246
  "Fall back to using the single-file index of all gems"
247
+ method_option "gemfile", :type => :string, :banner =>
248
+ "Use the specified gemfile instead of Gemfile"
198
249
  method_option "group", :aliases => "-g", :type => :array, :banner =>
199
250
  "Update a specific group"
200
251
  method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
@@ -205,7 +256,7 @@ module Bundler
205
256
  "Only output warnings and errors."
206
257
  method_option "source", :type => :array, :banner =>
207
258
  "Update a specific source (and all gems associated with it)"
208
- method_option "force", :type => :boolean, :banner =>
259
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
209
260
  "Force downloading every gem."
210
261
  method_option "ruby", :type => :boolean, :banner =>
211
262
  "Update ruby specified in Gemfile.lock"
@@ -221,7 +272,10 @@ module Bundler
221
272
  "Do not allow any gem to be updated past latest --patch | --minor | --major"
222
273
  method_option "conservative", :type => :boolean, :banner =>
223
274
  "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
275
+ method_option "all", :type => :boolean, :banner =>
276
+ "Update everything."
224
277
  def update(*gems)
278
+ SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
225
279
  require "bundler/cli/update"
226
280
  Update.new(options, gems).run
227
281
  end
@@ -236,12 +290,41 @@ module Bundler
236
290
  method_option "outdated", :type => :boolean,
237
291
  :banner => "Show verbose output including whether gems are outdated."
238
292
  def show(gem_name = nil)
239
- Bundler::SharedHelpers.major_deprecation("use `bundle show` instead of `bundle list`") if ARGV[0] == "list"
293
+ if ARGV[0] == "show"
294
+ rest = ARGV[1..-1]
295
+
296
+ new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list"
297
+
298
+ new_arguments = rest.map do |arg|
299
+ next arg if arg != "--paths"
300
+ next "--path" if new_command == "info"
301
+ end
302
+
303
+ old_argv = ARGV.join(" ")
304
+ new_argv = [new_command, *new_arguments.compact].join(" ")
305
+
306
+ Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
307
+ end
240
308
  require "bundler/cli/show"
241
309
  Show.new(options, gem_name).run
242
310
  end
243
- # TODO: 2.0 remove `bundle list`
244
- map %w(list) => "show"
311
+ # TODO: 2.0 remove `bundle show`
312
+
313
+ if Bundler.feature_flag.list_command?
314
+ desc "list", "List all gems in the bundle"
315
+ method_option "name-only", :type => :boolean, :banner => "print only the gem names"
316
+ method_option "only-group", :type => :string, :banner => "print gems from a particular group"
317
+ method_option "without-group", :type => :string, :banner => "print all gems expect from a group"
318
+ method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
319
+ def list
320
+ require "bundler/cli/list"
321
+ List.new(options).run
322
+ end
323
+
324
+ map %w[ls] => "list"
325
+ else
326
+ map %w[list] => "show"
327
+ end
245
328
 
246
329
  desc "info GEM [OPTIONS]", "Show information for the given gem"
247
330
  method_option "path", :type => :boolean, :banner => "Print full path to gem"
@@ -260,8 +343,12 @@ module Bundler
260
343
  "Overwrite existing binstubs if they exist"
261
344
  method_option "path", :type => :string, :lazy_default => "bin", :banner =>
262
345
  "Binstub destination directory (default bin)"
346
+ method_option "shebang", :type => :string, :banner =>
347
+ "Specify a different shebang executable name than the default (usually 'ruby')"
263
348
  method_option "standalone", :type => :boolean, :banner =>
264
349
  "Make binstubs that can work without the Bundler runtime"
350
+ method_option "all", :type => :boolean, :banner =>
351
+ "Install binstubs for all gems"
265
352
  def binstubs(*gems)
266
353
  require "bundler/cli/binstubs"
267
354
  Binstubs.new(options, gems).run
@@ -274,13 +361,16 @@ module Bundler
274
361
  method_option "version", :aliases => "-v", :type => :string
275
362
  method_option "group", :aliases => "-g", :type => :string
276
363
  method_option "source", :aliases => "-s", :type => :string
277
-
278
- def add(gem_name)
364
+ method_option "skip-install", :type => :boolean, :banner =>
365
+ "Adds gem to the Gemfile but does not install it"
366
+ method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
367
+ method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
368
+ def add(*gems)
279
369
  require "bundler/cli/add"
280
- Add.new(options.dup, gem_name).run
370
+ Add.new(options.dup, gems).run
281
371
  end
282
372
 
283
- desc "outdated GEM [OPTIONS]", "list installed gems with newer versions available"
373
+ desc "outdated GEM [OPTIONS]", "List installed gems with newer versions available"
284
374
  long_desc <<-D
285
375
  Outdated lists the names and versions of gems that have a newer version available
286
376
  in the given source. Calling outdated with [GEM [GEM]] will only check for newer
@@ -290,8 +380,8 @@ module Bundler
290
380
  For more information on patch level options (--major, --minor, --patch,
291
381
  --update-strict) see documentation on the same options on the update command.
292
382
  D
293
- method_option "group", :aliases => "--group", :type => :string, :banner => "List gems from a specific group"
294
- method_option "groups", :aliases => "--groups", :type => :boolean, :banner => "List gems organized by groups"
383
+ method_option "group", :type => :string, :banner => "List gems from a specific group"
384
+ method_option "groups", :type => :boolean, :banner => "List gems organized by groups"
295
385
  method_option "local", :type => :boolean, :banner =>
296
386
  "Do not attempt to fetch gems remotely and use the gem cache instead"
297
387
  method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
@@ -308,22 +398,34 @@ module Bundler
308
398
  method_option "filter-patch", :type => :boolean, :banner => "Only list patch newer versions"
309
399
  method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
310
400
  "Use minimal formatting for more parseable output"
401
+ method_option "only-explicit", :type => :boolean, :banner =>
402
+ "Only list gems specified in your Gemfile, not their dependencies"
311
403
  def outdated(*gems)
312
404
  require "bundler/cli/outdated"
313
405
  Outdated.new(options, gems).run
314
406
  end
315
407
 
316
- desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true
317
- method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
318
- method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
319
- method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
320
- def cache
321
- require "bundler/cli/cache"
322
- Cache.new(options).run
408
+ if Bundler.feature_flag.cache_command_is_package?
409
+ map %w[cache] => :package
410
+ else
411
+ desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true
412
+ unless Bundler.feature_flag.cache_command_is_package?
413
+ method_option "all", :type => :boolean,
414
+ :banner => "Include all sources (including path and git)."
415
+ end
416
+ method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
417
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
418
+ def cache
419
+ require "bundler/cli/cache"
420
+ Cache.new(options).run
421
+ end
323
422
  end
324
423
 
325
- desc "package [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
326
- method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
424
+ desc "#{Bundler.feature_flag.cache_command_is_package? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
425
+ unless Bundler.feature_flag.cache_command_is_package?
426
+ method_option "all", :type => :boolean,
427
+ :banner => "Include all sources (including path and git)."
428
+ end
327
429
  method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
328
430
  method_option "cache-path", :type => :string, :banner =>
329
431
  "Specify a different cache path than the default (vendor/cache)."
@@ -345,14 +447,15 @@ module Bundler
345
447
  require "bundler/cli/package"
346
448
  Package.new(options).run
347
449
  end
348
- map %w(pack) => :package
450
+ map %w[pack] => :package
349
451
 
350
452
  desc "exec [OPTIONS]", "Run the command in context of the bundle"
351
453
  method_option :keep_file_descriptors, :type => :boolean, :default => false
454
+ method_option :gemfile, :type => :string, :required => false
352
455
  long_desc <<-D
353
456
  Exec runs a command, providing it access to the gems in the bundle. While using
354
457
  bundle exec you can require and call the bundled gems as if they were installed
355
- into the system wide Rubygems repository.
458
+ into the system wide RubyGems repository.
356
459
  D
357
460
  map "e" => "exec"
358
461
  def exec(*args)
@@ -360,7 +463,7 @@ module Bundler
360
463
  Exec.new(options, args).run
361
464
  end
362
465
 
363
- desc "config NAME [VALUE]", "retrieve or set a configuration value"
466
+ desc "config NAME [VALUE]", "Retrieve or set a configuration value"
364
467
  long_desc <<-D
365
468
  Retrieves or sets a configuration value. If only one parameter is provided, retrieve the value. If two parameters are provided, replace the
366
469
  existing value with the newly provided one.
@@ -384,18 +487,28 @@ module Bundler
384
487
  Open.new(options, name).run
385
488
  end
386
489
 
387
- desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
388
- def console(group = nil)
389
- # TODO: Remove for 2.0
390
- require "bundler/cli/console"
391
- Console.new(options, group).run
490
+ if Bundler.feature_flag.console_command?
491
+ desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
492
+ def console(group = nil)
493
+ require "bundler/cli/console"
494
+ Console.new(options, group).run
495
+ end
392
496
  end
393
497
 
394
498
  desc "version", "Prints the bundler's version information"
395
499
  def version
396
- Bundler.ui.info "Bundler version #{Bundler::VERSION}"
500
+ cli_help = current_command.name == "cli_help"
501
+ if cli_help || ARGV.include?("version")
502
+ build_info = " (#{BuildMetadata.built_at} commit #{BuildMetadata.git_commit_sha})"
503
+ end
504
+
505
+ if !cli_help && Bundler.feature_flag.print_only_version_number?
506
+ Bundler.ui.info "#{Bundler::VERSION}#{build_info}"
507
+ else
508
+ Bundler.ui.info "Bundler version #{Bundler::VERSION}#{build_info}"
509
+ end
397
510
  end
398
- map %w(-v --version) => :version
511
+ map %w[-v --version] => :version
399
512
 
400
513
  desc "licenses", "Prints the license of all gems in the bundle"
401
514
  def licenses
@@ -411,25 +524,28 @@ module Bundler
411
524
  end
412
525
  end
413
526
 
414
- desc "viz [OPTIONS]", "Generates a visual dependency graph"
415
- long_desc <<-D
416
- Viz generates a PNG file of the current Gemfile as a dependency graph.
417
- Viz requires the ruby-graphviz gem (and its dependencies).
418
- The associated gems must also be installed via 'bundle install'.
419
- D
420
- method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
421
- method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
422
- method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
423
- method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
424
- method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
425
- def viz
426
- require "bundler/cli/viz"
427
- Viz.new(options.dup).run
527
+ if Bundler.feature_flag.viz_command?
528
+ desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true
529
+ long_desc <<-D
530
+ Viz generates a PNG file of the current Gemfile as a dependency graph.
531
+ Viz requires the ruby-graphviz gem (and its dependencies).
532
+ The associated gems must also be installed via 'bundle install'.
533
+ D
534
+ method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
535
+ method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
536
+ method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
537
+ method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
538
+ method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
539
+ def viz
540
+ SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
541
+ require "bundler/cli/viz"
542
+ Viz.new(options.dup).run
543
+ end
428
544
  end
429
545
 
430
546
  old_gem = instance_method(:gem)
431
547
 
432
- desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a rubygem"
548
+ desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
433
549
  method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library."
434
550
  method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config gem.coc true`."
435
551
  method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
@@ -468,7 +584,7 @@ module Bundler
468
584
  File.expand_path(File.join(File.dirname(__FILE__), "templates"))
469
585
  end
470
586
 
471
- desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory"
587
+ desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true
472
588
  method_option "dry-run", :type => :boolean, :default => false, :banner =>
473
589
  "Only print out changes, do not clean gems"
474
590
  method_option "force", :type => :boolean, :default => false, :banner =>
@@ -486,13 +602,13 @@ module Bundler
486
602
  Platform.new(options).run
487
603
  end
488
604
 
489
- desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile"
605
+ desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", :hide => true
490
606
  method_option "source", :type => :string, :banner =>
491
607
  "Install gem from the given source"
492
608
  method_option "group", :type => :string, :banner =>
493
609
  "Install gem into a bundler group"
494
610
  def inject(name, version)
495
- SharedHelpers.major_deprecation "The `inject` command has been replaced by the `add` command"
611
+ SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
496
612
  require "bundler/cli/inject"
497
613
  Inject.new(options.dup, name, version).run
498
614
  end
@@ -529,7 +645,7 @@ module Bundler
529
645
 
530
646
  desc "env", "Print information about the environment Bundler is running under"
531
647
  def env
532
- Env.new.write($stdout)
648
+ Env.write($stdout)
533
649
  end
534
650
 
535
651
  desc "doctor [OPTIONS]", "Checks the bundle for common problems"
@@ -553,15 +669,20 @@ module Bundler
553
669
  Issue.new.run
554
670
  end
555
671
 
556
- desc "pristine", "Restores installed gems to pristine condition from files located in the gem cache. Gem installed from a git repository will be issued `git checkout --force`."
557
- def pristine
672
+ desc "pristine [GEMS...]", "Restores installed gems to pristine condition"
673
+ long_desc <<-D
674
+ Restores installed gems to pristine condition from files located in the
675
+ gem cache. Gems installed from a git repository will be issued `git
676
+ checkout --force`.
677
+ D
678
+ def pristine(*gems)
558
679
  require "bundler/cli/pristine"
559
- Pristine.new.run
680
+ Pristine.new(gems).run
560
681
  end
561
682
 
562
683
  if Bundler.feature_flag.plugins?
563
684
  require "bundler/cli/plugin"
564
- desc "plugin SUBCOMMAND ...ARGS", "manage the bundler plugins"
685
+ desc "plugin", "Manage the bundler plugins"
565
686
  subcommand "plugin", Plugin
566
687
  end
567
688
 
@@ -569,14 +690,14 @@ module Bundler
569
690
  # into the corresponding `bundle help #{command}` call
570
691
  def self.reformatted_help_args(args)
571
692
  bundler_commands = all_commands.keys
572
- help_flags = %w(--help -h)
573
- exec_commands = %w(e ex exe exec)
693
+ help_flags = %w[--help -h]
694
+ exec_commands = %w[e ex exe exec]
574
695
  help_used = args.index {|a| help_flags.include? a }
575
696
  exec_used = args.index {|a| exec_commands.include? a }
576
697
  command = args.find {|a| bundler_commands.include? a }
577
698
  if exec_used && help_used
578
699
  if exec_used + help_used == 1
579
- %w(help exec)
700
+ %w[help exec]
580
701
  else
581
702
  args
582
703
  end
@@ -611,20 +732,35 @@ module Bundler
611
732
  end
612
733
  end
613
734
 
614
- def print_command
615
- return unless ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] || Bundler.ui.debug?
735
+ def current_command
616
736
  _, _, config = @_initializer
617
- current_command = config[:current_command].name
618
- return if %w(exec version check platform show help).include?(current_command)
619
- command = ["bundle", current_command] + args
620
- command << Thor::Options.to_switches(options)
737
+ config[:current_command]
738
+ end
739
+
740
+ def print_command
741
+ return unless Bundler.ui.debug?
742
+ cmd = current_command
743
+ command_name = cmd.name
744
+ return if PARSEABLE_COMMANDS.include?(command_name)
745
+ command = ["bundle", command_name] + args
746
+ options_to_print = options.dup
747
+ options_to_print.delete_if do |k, v|
748
+ next unless o = cmd.options[k]
749
+ o.default == v
750
+ end
751
+ command << Thor::Options.to_switches(options_to_print.sort_by(&:first)).strip
621
752
  command.reject!(&:empty?)
622
753
  Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
623
754
  end
624
755
 
625
- def self.warn_on_outdated_bundler
756
+ def warn_on_outdated_bundler
626
757
  return if Bundler.settings[:disable_version_check]
627
758
 
759
+ command_name = current_command.name
760
+ return if PARSEABLE_COMMANDS.include?(command_name)
761
+
762
+ return unless SharedHelpers.md5_available?
763
+
628
764
  latest = Fetcher::CompactIndex.
629
765
  new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil).
630
766
  send(:compact_index_client).
@@ -636,11 +772,19 @@ module Bundler
636
772
 
637
773
  current = Gem::Version.new(VERSION)
638
774
  return if current >= latest
775
+ latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max
776
+
777
+ installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`"
778
+ if latest_installed && latest_installed > current
779
+ suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`"
780
+ suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest
781
+ else
782
+ suggestion = installation
783
+ end
639
784
 
640
- Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\nTo update, run `gem install bundler#{" --pre" if latest.prerelease?}`"
641
- rescue
785
+ Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
786
+ rescue RuntimeError
642
787
  nil
643
788
  end
644
- private_class_method :warn_on_outdated_bundler
645
789
  end
646
790
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require "digest/md5"
3
2
 
4
3
  module Bundler
5
4
  class CompactIndexClient
@@ -68,7 +67,7 @@ module Bundler
68
67
  def info_path(name)
69
68
  name = name.to_s
70
69
  if name =~ /[^a-z0-9_-]/
71
- name += "-#{Digest::MD5.hexdigest(name).downcase}"
70
+ name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
72
71
  info_roots.last.join(name)
73
72
  else
74
73
  info_roots.first.join(name)