bundler 2.2.26 → 2.3.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +501 -1
  3. data/README.md +1 -1
  4. data/bundler.gemspec +6 -8
  5. data/exe/bundle +7 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/cli/check.rb +1 -1
  10. data/lib/bundler/cli/common.rb +3 -2
  11. data/lib/bundler/cli/config.rb +10 -1
  12. data/lib/bundler/cli/doctor.rb +12 -3
  13. data/lib/bundler/cli/gem.rb +98 -9
  14. data/lib/bundler/cli/info.rb +27 -6
  15. data/lib/bundler/cli/init.rb +5 -1
  16. data/lib/bundler/cli/install.rb +13 -30
  17. data/lib/bundler/cli/issue.rb +4 -3
  18. data/lib/bundler/cli/outdated.rb +12 -3
  19. data/lib/bundler/cli/platform.rb +2 -2
  20. data/lib/bundler/cli/remove.rb +1 -2
  21. data/lib/bundler/cli/show.rb +1 -1
  22. data/lib/bundler/cli/update.rb +8 -4
  23. data/lib/bundler/cli.rb +23 -19
  24. data/lib/bundler/compact_index_client/cache.rb +0 -9
  25. data/lib/bundler/compact_index_client/updater.rb +16 -8
  26. data/lib/bundler/compact_index_client.rb +2 -8
  27. data/lib/bundler/current_ruby.rb +16 -6
  28. data/lib/bundler/definition.rb +204 -217
  29. data/lib/bundler/dependency.rb +23 -71
  30. data/lib/bundler/digest.rb +71 -0
  31. data/lib/bundler/dsl.rb +28 -45
  32. data/lib/bundler/endpoint_specification.rb +19 -13
  33. data/lib/bundler/env.rb +1 -1
  34. data/lib/bundler/environment_preserver.rb +4 -1
  35. data/lib/bundler/errors.rb +28 -2
  36. data/lib/bundler/feature_flag.rb +0 -1
  37. data/lib/bundler/fetcher/base.rb +6 -8
  38. data/lib/bundler/fetcher/compact_index.rb +9 -14
  39. data/lib/bundler/fetcher/index.rb +0 -26
  40. data/lib/bundler/fetcher.rb +20 -22
  41. data/lib/bundler/friendly_errors.rb +26 -34
  42. data/lib/bundler/gem_helper.rb +7 -18
  43. data/lib/bundler/gem_helpers.rb +9 -2
  44. data/lib/bundler/gem_version_promoter.rb +14 -25
  45. data/lib/bundler/index.rb +10 -40
  46. data/lib/bundler/injector.rb +16 -2
  47. data/lib/bundler/inline.rb +2 -12
  48. data/lib/bundler/installer/gem_installer.rb +13 -5
  49. data/lib/bundler/installer/standalone.rb +30 -3
  50. data/lib/bundler/installer.rb +18 -29
  51. data/lib/bundler/lazy_specification.rb +52 -35
  52. data/lib/bundler/lockfile_generator.rb +2 -2
  53. data/lib/bundler/lockfile_parser.rb +12 -10
  54. data/lib/bundler/man/bundle-add.1 +21 -5
  55. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  56. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  57. data/lib/bundler/man/bundle-cache.1 +7 -1
  58. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  59. data/lib/bundler/man/bundle-check.1 +1 -1
  60. data/lib/bundler/man/bundle-clean.1 +2 -2
  61. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  62. data/lib/bundler/man/bundle-config.1 +33 -14
  63. data/lib/bundler/man/bundle-config.1.ronn +30 -18
  64. data/lib/bundler/man/bundle-console.1 +53 -0
  65. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  66. data/lib/bundler/man/bundle-doctor.1 +1 -1
  67. data/lib/bundler/man/bundle-exec.1 +2 -2
  68. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  69. data/lib/bundler/man/bundle-gem.1 +14 -1
  70. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  71. data/lib/bundler/man/bundle-help.1 +13 -0
  72. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  73. data/lib/bundler/man/bundle-info.1 +1 -1
  74. data/lib/bundler/man/bundle-init.1 +1 -1
  75. data/lib/bundler/man/bundle-inject.1 +5 -2
  76. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  77. data/lib/bundler/man/bundle-install.1 +6 -2
  78. data/lib/bundler/man/bundle-install.1.ronn +8 -2
  79. data/lib/bundler/man/bundle-list.1 +1 -1
  80. data/lib/bundler/man/bundle-lock.1 +1 -1
  81. data/lib/bundler/man/bundle-open.1 +1 -1
  82. data/lib/bundler/man/bundle-outdated.1 +3 -10
  83. data/lib/bundler/man/bundle-outdated.1.ronn +1 -10
  84. data/lib/bundler/man/bundle-platform.1 +16 -6
  85. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  86. data/lib/bundler/man/bundle-plugin.1 +81 -0
  87. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  88. data/lib/bundler/man/bundle-pristine.1 +1 -1
  89. data/lib/bundler/man/bundle-remove.1 +1 -1
  90. data/lib/bundler/man/bundle-show.1 +1 -1
  91. data/lib/bundler/man/bundle-update.1 +2 -2
  92. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  93. data/lib/bundler/man/bundle-version.1 +35 -0
  94. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  95. data/lib/bundler/man/bundle-viz.1 +4 -1
  96. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  97. data/lib/bundler/man/bundle.1 +15 -10
  98. data/lib/bundler/man/bundle.1.ronn +12 -7
  99. data/lib/bundler/man/gemfile.5 +117 -80
  100. data/lib/bundler/man/gemfile.5.ronn +105 -84
  101. data/lib/bundler/man/index.txt +4 -0
  102. data/lib/bundler/match_metadata.rb +13 -0
  103. data/lib/bundler/match_platform.rb +0 -1
  104. data/lib/bundler/match_remote_metadata.rb +29 -0
  105. data/lib/bundler/plugin/api/source.rb +4 -9
  106. data/lib/bundler/plugin/installer/git.rb +0 -4
  107. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  108. data/lib/bundler/plugin/installer.rb +3 -1
  109. data/lib/bundler/plugin.rb +25 -6
  110. data/lib/bundler/process_lock.rb +1 -1
  111. data/lib/bundler/remote_specification.rb +10 -4
  112. data/lib/bundler/resolver/base.rb +50 -0
  113. data/lib/bundler/resolver/spec_group.rb +31 -49
  114. data/lib/bundler/resolver.rb +183 -192
  115. data/lib/bundler/ruby_dsl.rb +1 -1
  116. data/lib/bundler/ruby_version.rb +5 -18
  117. data/lib/bundler/rubygems_ext.rb +138 -20
  118. data/lib/bundler/rubygems_gem_installer.rb +42 -16
  119. data/lib/bundler/rubygems_integration.rb +42 -90
  120. data/lib/bundler/runtime.rb +2 -3
  121. data/lib/bundler/self_manager.rb +168 -0
  122. data/lib/bundler/settings.rb +13 -4
  123. data/lib/bundler/shared_helpers.rb +15 -24
  124. data/lib/bundler/source/git/git_proxy.rb +7 -4
  125. data/lib/bundler/source/git.rb +29 -13
  126. data/lib/bundler/source/metadata.rb +3 -3
  127. data/lib/bundler/source/path.rb +1 -1
  128. data/lib/bundler/source/rubygems.rb +148 -161
  129. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  130. data/lib/bundler/source.rb +6 -5
  131. data/lib/bundler/source_list.rb +15 -29
  132. data/lib/bundler/source_map.rb +15 -2
  133. data/lib/bundler/spec_set.rb +52 -32
  134. data/lib/bundler/stub_specification.rb +5 -3
  135. data/lib/bundler/templates/Executable +2 -4
  136. data/lib/bundler/templates/Executable.bundler +2 -2
  137. data/lib/bundler/templates/Executable.standalone +2 -4
  138. data/lib/bundler/templates/Gemfile +0 -2
  139. data/lib/bundler/templates/gems.rb +0 -3
  140. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  141. data/lib/bundler/templates/newgem/README.md.tt +3 -9
  142. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  143. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +5 -4
  144. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +5 -4
  145. data/lib/bundler/templates/newgem/newgem.gemspec.tt +16 -16
  146. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  147. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  148. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  149. data/lib/bundler/ui/shell.rb +1 -1
  150. data/lib/bundler/vendor/.document +1 -0
  151. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  152. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  153. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  154. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  155. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  156. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  157. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  158. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -3
  159. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +32 -26
  160. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  161. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  162. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  163. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  164. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  165. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  166. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  167. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  168. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  169. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  170. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  171. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  172. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  173. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  174. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  175. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  176. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  177. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  178. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  179. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  180. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  181. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  182. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  183. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  184. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  185. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  186. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  187. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  188. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  189. data/lib/bundler/vendored_tsort.rb +4 -0
  190. data/lib/bundler/version.rb +1 -1
  191. data/lib/bundler/worker.rb +2 -2
  192. data/lib/bundler.rb +40 -29
  193. metadata +37 -12
  194. data/lib/bundler/dep_proxy.rb +0 -55
  195. data/lib/bundler/gemdeps.rb +0 -29
  196. data/lib/bundler/psyched_yaml.rb +0 -22
  197. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -180,7 +180,7 @@ module Bundler
180
180
  scopes = %w[global local].select {|s| options[s] }
181
181
  case scopes.size
182
182
  when 0
183
- @scope = "global"
183
+ @scope = inside_app? ? "local" : "global"
184
184
  @explicit_scope = false
185
185
  when 1
186
186
  @scope = scopes.first
@@ -189,6 +189,15 @@ module Bundler
189
189
  "The options #{scopes.join " and "} were specified. Please only use one of the switches at a time."
190
190
  end
191
191
  end
192
+
193
+ private
194
+
195
+ def inside_app?
196
+ Bundler.root
197
+ true
198
+ rescue GemfileNotFound
199
+ false
200
+ end
192
201
  end
193
202
  end
194
203
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rbconfig"
4
+ require "shellwords"
5
+ require "fiddle"
4
6
 
5
7
  module Bundler
6
8
  class CLI::Doctor
@@ -22,14 +24,14 @@ module Bundler
22
24
  end
23
25
 
24
26
  def dylibs_darwin(path)
25
- output = `/usr/bin/otool -L "#{path}"`.chomp
27
+ output = `/usr/bin/otool -L #{path.shellescape}`.chomp
26
28
  dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
27
29
  # ignore @rpath and friends
28
30
  dylibs.reject {|dylib| dylib.start_with? "@" }
29
31
  end
30
32
 
31
33
  def dylibs_ldd(path)
32
- output = `/usr/bin/ldd "#{path}"`.chomp
34
+ output = `/usr/bin/ldd #{path.shellescape}`.chomp
33
35
  output.split("\n").map do |l|
34
36
  match = l.match(LDD_REGEX)
35
37
  next if match.nil?
@@ -70,7 +72,14 @@ module Bundler
70
72
 
71
73
  definition.specs.each do |spec|
72
74
  bundles_for_gem(spec).each do |bundle|
73
- bad_paths = dylibs(bundle).select {|f| !File.exist?(f) }
75
+ bad_paths = dylibs(bundle).select do |f|
76
+ begin
77
+ Fiddle.dlopen(f)
78
+ false
79
+ rescue Fiddle::DLError
80
+ true
81
+ end
82
+ end
74
83
  if bad_paths.any?
75
84
  broken_links[spec] ||= []
76
85
  broken_links[spec].concat(bad_paths)
@@ -38,6 +38,7 @@ module Bundler
38
38
  namespaced_path = name.tr("-", "/")
39
39
  constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
40
40
  constant_array = constant_name.split("::")
41
+ minitest_constant_name = constant_array.clone.tap {|a| a[-1] = "Test#{a[-1]}" }.join("::") # Foo::Bar => Foo::TestBar
41
42
 
42
43
  use_git = Bundler.git_present? && options[:git]
43
44
 
@@ -68,7 +69,8 @@ module Bundler
68
69
  :bundler_version => bundler_dependency_version,
69
70
  :git => use_git,
70
71
  :github_username => github_username.empty? ? "[USERNAME]" : github_username,
71
- :required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0",
72
+ :required_ruby_version => required_ruby_version,
73
+ :minitest_constant_name => minitest_constant_name,
72
74
  }
73
75
  ensure_safe_gem_name(name, constant_array)
74
76
 
@@ -76,6 +78,7 @@ module Bundler
76
78
  "#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
77
79
  "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
78
80
  "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
81
+ "sig/newgem.rbs.tt" => "sig/#{namespaced_path}.rbs",
79
82
  "newgem.gemspec.tt" => "#{name}.gemspec",
80
83
  "Rakefile.tt" => "Rakefile",
81
84
  "README.md.tt" => "README.md",
@@ -103,9 +106,17 @@ module Bundler
103
106
  )
104
107
  config[:test_task] = :spec
105
108
  when "minitest"
109
+ # Generate path for minitest target file (FileList["test/**/test_*.rb"])
110
+ # foo => test/test_foo.rb
111
+ # foo-bar => test/foo/test_bar.rb
112
+ # foo_bar => test/test_foo_bar.rb
113
+ paths = namespaced_path.rpartition("/")
114
+ paths[2] = "test_#{paths[2]}"
115
+ minitest_namespaced_path = paths.join("")
116
+
106
117
  templates.merge!(
107
118
  "test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
108
- "test/minitest/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
119
+ "test/minitest/test_newgem.rb.tt" => "test/#{minitest_namespaced_path}.rb"
109
120
  )
110
121
  config[:test_task] = :test
111
122
  when "test-unit"
@@ -163,15 +174,16 @@ module Bundler
163
174
  templates.merge!("CHANGELOG.md.tt" => "CHANGELOG.md")
164
175
  end
165
176
 
166
- if ask_and_set(:rubocop, "Do you want to add rubocop as a dependency for gems you generate?",
167
- "RuboCop is a static code analyzer that has out-of-the-box rules for many " \
168
- "of the guidelines in the community style guide. " \
169
- "For more information, see the RuboCop docs (https://docs.rubocop.org/en/stable/) " \
170
- "and the Ruby Style Guides (https://github.com/rubocop-hq/ruby-style-guide).")
171
- config[:rubocop] = true
172
- config[:rubocop_version] = Gem.ruby_version < Gem::Version.new("2.4.a") ? "0.81.0" : "1.7"
177
+ config[:linter] = ask_and_set_linter
178
+ case config[:linter]
179
+ when "rubocop"
180
+ config[:linter_version] = rubocop_version
173
181
  Bundler.ui.info "RuboCop enabled in config"
174
182
  templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
183
+ when "standard"
184
+ config[:linter_version] = standard_version
185
+ Bundler.ui.info "Standard enabled in config"
186
+ templates.merge!("standard.yml.tt" => ".standard.yml")
175
187
  end
176
188
 
177
189
  templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
@@ -317,6 +329,58 @@ module Bundler
317
329
  ci_template
318
330
  end
319
331
 
332
+ def ask_and_set_linter
333
+ linter_template = options[:linter] || Bundler.settings["gem.linter"]
334
+ linter_template = deprecated_rubocop_option if linter_template.nil?
335
+
336
+ if linter_template.to_s.empty?
337
+ Bundler.ui.confirm "Do you want to add a code linter and formatter to your gem? " \
338
+ "Supported Linters:\n" \
339
+ "* RuboCop: https://rubocop.org\n" \
340
+ "* Standard: https://github.com/testdouble/standard\n" \
341
+ "\n"
342
+ Bundler.ui.info hint_text("linter")
343
+
344
+ result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):"
345
+ if result =~ /rubocop|standard/
346
+ linter_template = result
347
+ else
348
+ linter_template = false
349
+ end
350
+ end
351
+
352
+ if Bundler.settings["gem.linter"].nil?
353
+ Bundler.settings.set_global("gem.linter", linter_template)
354
+ end
355
+
356
+ # Once gem.linter safely set, unset the deprecated gem.rubocop
357
+ unless Bundler.settings["gem.rubocop"].nil?
358
+ Bundler.settings.set_global("gem.rubocop", nil)
359
+ end
360
+
361
+ if options[:linter] == Bundler.settings["gem.linter"]
362
+ Bundler.ui.info "#{options[:linter]} is already configured, ignoring --linter flag."
363
+ end
364
+
365
+ linter_template
366
+ end
367
+
368
+ def deprecated_rubocop_option
369
+ if !options[:rubocop].nil?
370
+ if options[:rubocop]
371
+ Bundler::SharedHelpers.major_deprecation 2, "--rubocop is deprecated, use --linter=rubocop"
372
+ "rubocop"
373
+ else
374
+ Bundler::SharedHelpers.major_deprecation 2, "--no-rubocop is deprecated, use --linter"
375
+ false
376
+ end
377
+ elsif !Bundler.settings["gem.rubocop"].nil?
378
+ Bundler::SharedHelpers.major_deprecation 2,
379
+ "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
380
+ Bundler.settings["gem.rubocop"] ? "rubocop" : false
381
+ end
382
+ end
383
+
320
384
  def bundler_dependency_version
321
385
  v = Gem::Version.new(Bundler::VERSION)
322
386
  req = v.segments[0..1]
@@ -350,5 +414,30 @@ module Bundler
350
414
  def open_editor(editor, file)
351
415
  thor.run(%(#{editor} "#{file}"))
352
416
  end
417
+
418
+ def required_ruby_version
419
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "2.3.0"
420
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "2.4.0"
421
+ elsif Gem.ruby_version < Gem::Version.new("2.6.a") then "2.5.0"
422
+ else
423
+ "2.6.0"
424
+ end
425
+ end
426
+
427
+ def rubocop_version
428
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.81.0"
429
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.12"
430
+ else
431
+ "1.21"
432
+ end
433
+ end
434
+
435
+ def standard_version
436
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.2.5"
437
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.0"
438
+ else
439
+ "1.3"
440
+ end
441
+ end
353
442
  end
354
443
  end
@@ -18,6 +18,7 @@ module Bundler
18
18
 
19
19
  if spec
20
20
  return print_gem_path(spec) if @options[:path]
21
+ return print_gem_version(spec) if @options[:version]
21
22
  print_gem_info(spec)
22
23
  end
23
24
  end
@@ -39,13 +40,18 @@ module Bundler
39
40
  raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
40
41
  end
41
42
 
43
+ def print_gem_version(spec)
44
+ Bundler.ui.info spec.version.to_s
45
+ end
46
+
42
47
  def print_gem_path(spec)
43
- if spec.name == "bundler"
44
- path = File.expand_path("../../../..", __FILE__)
48
+ name = spec.name
49
+ if name == "bundler"
50
+ path = File.expand_path("../../..", __dir__)
45
51
  else
46
52
  path = spec.full_gem_path
47
- unless File.directory?(path)
48
- return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}"
53
+ if spec.deleted_gem?
54
+ return Bundler.ui.warn "The gem #{name} has been deleted. It was installed at: #{path}"
49
55
  end
50
56
  end
51
57
 
@@ -54,8 +60,9 @@ module Bundler
54
60
 
55
61
  def print_gem_info(spec)
56
62
  metadata = spec.metadata
63
+ name = spec.name
57
64
  gem_info = String.new
58
- gem_info << " * #{spec.name} (#{spec.version}#{spec.git_version})\n"
65
+ gem_info << " * #{name} (#{spec.version}#{spec.git_version})\n"
59
66
  gem_info << "\tSummary: #{spec.summary}\n" if spec.summary
60
67
  gem_info << "\tHomepage: #{spec.homepage}\n" if spec.homepage
61
68
  gem_info << "\tDocumentation: #{metadata["documentation_uri"]}\n" if metadata.key?("documentation_uri")
@@ -66,8 +73,22 @@ module Bundler
66
73
  gem_info << "\tBug Tracker: #{metadata["bug_tracker_uri"]}\n" if metadata.key?("bug_tracker_uri")
67
74
  gem_info << "\tMailing List: #{metadata["mailing_list_uri"]}\n" if metadata.key?("mailing_list_uri")
68
75
  gem_info << "\tPath: #{spec.full_gem_path}\n"
69
- gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem?
76
+ gem_info << "\tDefault Gem: yes\n" if spec.respond_to?(:default_gem?) && spec.default_gem?
77
+ gem_info << "\tReverse Dependencies: \n\t\t#{gem_dependencies.join("\n\t\t")}" if gem_dependencies.any?
78
+
79
+ if name != "bundler" && spec.deleted_gem?
80
+ return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}"
81
+ end
82
+
70
83
  Bundler.ui.info gem_info
71
84
  end
85
+
86
+ def gem_dependencies
87
+ @gem_dependencies ||= Bundler.definition.specs.map do |spec|
88
+ dependency = spec.dependencies.find {|dep| dep.name == gem_name }
89
+ next unless dependency
90
+ "#{spec.name} (#{spec.version}) depends on #{gem_name} (#{dependency.requirements_list.join(", ")})"
91
+ end.compact.sort
92
+ end
72
93
  end
73
94
  end
@@ -32,7 +32,11 @@ module Bundler
32
32
  file << spec.to_gemfile
33
33
  end
34
34
  else
35
- FileUtils.cp(File.expand_path("../../templates/#{gemfile}", __FILE__), gemfile)
35
+ File.open(File.expand_path("../templates/#{gemfile}", __dir__), "r") do |template|
36
+ File.open(gemfile, "wb") do |destination|
37
+ IO.copy_stream(template, destination)
38
+ end
39
+ end
36
40
  end
37
41
 
38
42
  puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}"
@@ -12,6 +12,8 @@ module Bundler
12
12
 
13
13
  warn_if_root
14
14
 
15
+ Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
16
+
15
17
  Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
16
18
 
17
19
  # Disable color in deployment mode
@@ -133,42 +135,23 @@ module Bundler
133
135
  end
134
136
 
135
137
  def normalize_groups
136
- options[:with] &&= options[:with].join(":").tr(" ", ":").split(":")
137
- options[:without] &&= options[:without].join(":").tr(" ", ":").split(":")
138
-
139
138
  check_for_group_conflicts_in_cli_options
140
139
 
141
- Bundler.settings.set_command_option :with, nil if options[:with] == []
142
- Bundler.settings.set_command_option :without, nil if options[:without] == []
143
-
144
- with = options.fetch(:with, [])
145
- with |= Bundler.settings[:with].map(&:to_s)
146
- with -= options[:without] if options[:without]
147
-
148
- without = options.fetch(:without, [])
149
- without |= Bundler.settings[:without].map(&:to_s)
150
- without -= options[:with] if options[:with]
151
-
152
- options[:with] = with
153
- options[:without] = without
154
-
155
- unless Bundler.settings[:without] == options[:without] && Bundler.settings[:with] == options[:with]
156
- # need to nil them out first to get around validation for backwards compatibility
157
- Bundler.settings.set_command_option :without, nil
158
- Bundler.settings.set_command_option :with, nil
159
- Bundler.settings.set_command_option :without, options[:without] - options[:with]
160
- Bundler.settings.set_command_option :with, options[:with]
161
- end
140
+ # need to nil them out first to get around validation for backwards compatibility
141
+ Bundler.settings.set_command_option :without, nil
142
+ Bundler.settings.set_command_option :with, nil
143
+ Bundler.settings.set_command_option :without, options[:without]
144
+ Bundler.settings.set_command_option :with, options[:with]
162
145
  end
163
146
 
164
147
  def normalize_settings
165
148
  Bundler.settings.set_command_option :path, nil if options[:system]
166
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
167
- Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil?
168
- end
169
149
  Bundler.settings.set_command_option_if_given :path, options[:path]
170
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
171
- Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
150
+
151
+ if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
152
+ Bundler.settings.temporary(:path_relative_to_cwd => false) do
153
+ Bundler.settings.set_command_option :path, "bundle"
154
+ end
172
155
  end
173
156
 
174
157
  bin_option = options["binstubs"]
@@ -185,7 +168,7 @@ module Bundler
185
168
 
186
169
  Bundler.settings.set_command_option_if_given :clean, options["clean"]
187
170
 
188
- normalize_groups
171
+ normalize_groups if options[:without] || options[:with]
189
172
 
190
173
  options[:force] = options[:redownload]
191
174
  end
@@ -20,9 +20,10 @@ module Bundler
20
20
 
21
21
  Hopefully the troubleshooting steps above resolved your problem! If things
22
22
  still aren't working the way you expect them to, please let us know so
23
- that we can diagnose and help fix the problem you're having. Please
24
- view the Filing Issues guide for more information:
25
- https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/ISSUES.md
23
+ that we can diagnose and help fix the problem you're having, by filling
24
+ in the new issue form located at
25
+ https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
26
+ and copy and pasting the information below.
26
27
 
27
28
  EOS
28
29
 
@@ -46,7 +46,7 @@ module Bundler
46
46
 
47
47
  Bundler::CLI::Common.configure_gem_version_promoter(
48
48
  Bundler.definition,
49
- options
49
+ options.merge(:strict => @strict)
50
50
  )
51
51
 
52
52
  definition_resolution = proc do
@@ -129,6 +129,12 @@ module Bundler
129
129
 
130
130
  private
131
131
 
132
+ def loaded_from_for(spec)
133
+ return unless spec.respond_to?(:loaded_from)
134
+
135
+ spec.loaded_from
136
+ end
137
+
132
138
  def groups_text(group_text, groups)
133
139
  "#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\""
134
140
  end
@@ -184,7 +190,10 @@ module Bundler
184
190
 
185
191
  def print_gem(current_spec, active_spec, dependency, groups)
186
192
  spec_version = "#{active_spec.version}#{active_spec.git_version}"
187
- spec_version += " (from #{active_spec.loaded_from})" if Bundler.ui.debug? && active_spec.loaded_from
193
+ if Bundler.ui.debug?
194
+ loaded_from = loaded_from_for(active_spec)
195
+ spec_version += " (from #{loaded_from})" if loaded_from
196
+ end
188
197
  current_version = "#{current_spec.version}#{current_spec.git_version}"
189
198
 
190
199
  if dependency && dependency.specific?
@@ -211,7 +220,7 @@ module Bundler
211
220
  dependency = dependency.requirement if dependency
212
221
 
213
222
  ret_val = [active_spec.name, current_version, spec_version, dependency.to_s, groups.to_s]
214
- ret_val << active_spec.loaded_from.to_s if Bundler.ui.debug?
223
+ ret_val << loaded_from_for(active_spec).to_s if Bundler.ui.debug?
215
224
  ret_val
216
225
  end
217
226
 
@@ -9,7 +9,7 @@ module Bundler
9
9
 
10
10
  def run
11
11
  platforms, ruby_version = Bundler.ui.silence do
12
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version
12
+ locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
13
13
  gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
14
14
  [Bundler.definition.platforms.map {|p| "* #{p}" },
15
15
  locked_ruby_version || gemfile_ruby_version]
@@ -23,7 +23,7 @@ module Bundler
23
23
  output << "No ruby version specified"
24
24
  end
25
25
  else
26
- output << "Your platform is: #{RUBY_PLATFORM}"
26
+ output << "Your platform is: #{Gem::Platform.local}"
27
27
  output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
28
28
 
29
29
  if ruby_version
@@ -11,8 +11,7 @@ module Bundler
11
11
  raise InvalidOption, "Please specify gems to remove." if @gems.empty?
12
12
 
13
13
  Injector.remove(@gems, {})
14
-
15
- Installer.install(Bundler.root, Bundler.definition) if @options["install"]
14
+ Installer.install(Bundler.root, Bundler.definition)
16
15
  end
17
16
  end
18
17
  end
@@ -18,7 +18,7 @@ module Bundler
18
18
 
19
19
  if gem_name
20
20
  if gem_name == "bundler"
21
- path = File.expand_path("../../../..", __FILE__)
21
+ path = File.expand_path("../../..", __dir__)
22
22
  else
23
23
  spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match)
24
24
  return unless spec
@@ -11,12 +11,16 @@ module Bundler
11
11
  def run
12
12
  Bundler.ui.level = "warn" if options[:quiet]
13
13
 
14
+ update_bundler = options[:bundler]
15
+
16
+ Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler
17
+
14
18
  Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
15
19
 
16
20
  sources = Array(options[:source])
17
21
  groups = Array(options[:group]).map(&:to_sym)
18
22
 
19
- full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
23
+ full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !update_bundler
20
24
 
21
25
  if full_update && !options[:all]
22
26
  if Bundler.feature_flag.update_requires_all_flag?
@@ -49,7 +53,7 @@ module Bundler
49
53
 
50
54
  Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
51
55
  :conservative => conservative,
52
- :bundler => options[:bundler])
56
+ :bundler => update_bundler)
53
57
  end
54
58
 
55
59
  Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
@@ -66,7 +70,7 @@ module Bundler
66
70
 
67
71
  if locked_gems = Bundler.definition.locked_gems
68
72
  previous_locked_info = locked_gems.specs.reduce({}) do |h, s|
69
- h[s.name] = { :spec => s, :version => s.version, :source => s.source.to_s }
73
+ h[s.name] = { :spec => s, :version => s.version, :source => s.source.identifier }
70
74
  h
71
75
  end
72
76
  end
@@ -95,7 +99,7 @@ module Bundler
95
99
  end
96
100
 
97
101
  locked_source = locked_info[:source]
98
- new_source = new_spec.source.to_s
102
+ new_source = new_spec.source.identifier
99
103
  next if locked_source != new_source
100
104
 
101
105
  new_version = new_spec.version
data/lib/bundler/cli.rb CHANGED
@@ -61,6 +61,8 @@ module Bundler
61
61
  Bundler.reset_settings_and_root!
62
62
  end
63
63
 
64
+ Bundler.self_manager.restart_with_locked_bundler_if_needed
65
+
64
66
  Bundler.settings.set_command_option_if_given :retry, options[:retry]
65
67
 
66
68
  current_cmd = args.last[:current_command].name
@@ -184,6 +186,7 @@ module Bundler
184
186
  method_option "install", :type => :boolean, :banner =>
185
187
  "Runs 'bundle install' after removing the gems from the Gemfile"
186
188
  def remove(*gems)
189
+ SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install")
187
190
  require_relative "cli/remove"
188
191
  Remove.new(gems, options).run
189
192
  end
@@ -215,6 +218,8 @@ module Bundler
215
218
  "Specify the number of jobs to run in parallel"
216
219
  method_option "local", :type => :boolean, :banner =>
217
220
  "Do not attempt to fetch gems remotely and use the gem cache instead"
221
+ method_option "prefer-local", :type => :boolean, :banner =>
222
+ "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
218
223
  method_option "no-cache", :type => :boolean, :banner =>
219
224
  "Don't update the existing gem cache."
220
225
  method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
@@ -233,7 +238,7 @@ module Bundler
233
238
  "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
234
239
  method_option "trust-policy", :alias => "P", :type => :string, :banner =>
235
240
  "Gem trust policy (like gem install -P). Must be one of " +
236
- Bundler.rubygems.security_policy_keys.join("|")
241
+ Bundler.rubygems.security_policy_keys.join("|")
237
242
  method_option "without", :type => :array, :banner =>
238
243
  "Exclude gems that are part of the specified named group."
239
244
  method_option "with", :type => :array, :banner =>
@@ -330,6 +335,7 @@ module Bundler
330
335
 
331
336
  desc "info GEM [OPTIONS]", "Show information for the given gem"
332
337
  method_option "path", :type => :boolean, :banner => "Print full path to gem"
338
+ method_option "version", :type => :boolean, :banner => "Print gem version"
333
339
  def info(gem_name)
334
340
  require_relative "cli/info"
335
341
  Info.new(options, gem_name).run
@@ -365,8 +371,12 @@ module Bundler
365
371
  method_option "version", :aliases => "-v", :type => :string
366
372
  method_option "group", :aliases => "-g", :type => :string
367
373
  method_option "source", :aliases => "-s", :type => :string
374
+ method_option "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
375
+ method_option "path", :type => :string
368
376
  method_option "git", :type => :string
377
+ method_option "github", :type => :string
369
378
  method_option "branch", :type => :string
379
+ method_option "ref", :type => :string
370
380
  method_option "skip-install", :type => :boolean, :banner =>
371
381
  "Adds gem to the Gemfile but does not install it"
372
382
  method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
@@ -384,7 +394,7 @@ module Bundler
384
394
  are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
385
395
 
386
396
  For more information on patch level options (--major, --minor, --patch,
387
- --update-strict) see documentation on the same options on the update command.
397
+ --strict) see documentation on the same options on the update command.
388
398
  D
389
399
  method_option "group", :type => :string, :banner => "List gems from a specific group"
390
400
  method_option "groups", :type => :boolean, :banner => "List gems organized by groups"
@@ -392,10 +402,9 @@ module Bundler
392
402
  "Do not attempt to fetch gems remotely and use the gem cache instead"
393
403
  method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
394
404
  method_option "source", :type => :array, :banner => "Check against a specific source"
395
- strict_is_update = Bundler.feature_flag.forget_cli_options?
396
- method_option "filter-strict", :type => :boolean, :aliases => strict_is_update ? [] : %w[--strict], :banner =>
405
+ method_option "filter-strict", :type => :boolean, :aliases => "--strict", :banner =>
397
406
  "Only list newer versions allowed by your Gemfile requirements"
398
- method_option "update-strict", :type => :boolean, :aliases => strict_is_update ? %w[--strict] : [], :banner =>
407
+ method_option "update-strict", :type => :boolean, :banner =>
399
408
  "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
400
409
  method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
401
410
  method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
@@ -508,7 +517,7 @@ module Bundler
508
517
  end
509
518
  end
510
519
 
511
- desc "version", "Prints the bundler's version information"
520
+ desc "version", "Prints Bundler version information"
512
521
  def version
513
522
  cli_help = current_command.name == "cli_help"
514
523
  if cli_help || ARGV.include?("version")
@@ -551,7 +560,7 @@ module Bundler
551
560
  method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
552
561
  method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
553
562
  def viz
554
- SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
563
+ SharedHelpers.major_deprecation 2, "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
555
564
  require_relative "cli/viz"
556
565
  Viz.new(options.dup).run
557
566
  end
@@ -574,6 +583,8 @@ module Bundler
574
583
  :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
575
584
  method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
576
585
  :desc => "Generate CI configuration, either GitHub Actions, Travis CI, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|travis|gitlab|circle)`"
586
+ method_option :linter, :type => :string, :lazy_default => Bundler.settings["gem.linter"] || "",
587
+ :desc => "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
577
588
  method_option :github_username, :type => :string, :default => Bundler.settings["gem.github_username"], :banner => "Set your username on GitHub", :desc => "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
578
589
 
579
590
  def gem(name)
@@ -602,14 +613,14 @@ module Bundler
602
613
  private :gem
603
614
 
604
615
  def self.source_root
605
- File.expand_path(File.join(File.dirname(__FILE__), "templates"))
616
+ File.expand_path("templates", __dir__)
606
617
  end
607
618
 
608
619
  desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true
609
620
  method_option "dry-run", :type => :boolean, :default => false, :banner =>
610
621
  "Only print out changes, do not clean gems"
611
622
  method_option "force", :type => :boolean, :default => false, :banner =>
612
- "Forces clean even if --path is not set"
623
+ "Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application."
613
624
  def clean
614
625
  require_relative "cli/clean"
615
626
  Clean.new(options.dup).run
@@ -800,17 +811,10 @@ module Bundler
800
811
 
801
812
  current = Gem::Version.new(VERSION)
802
813
  return if current >= latest
803
- latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max
804
-
805
- installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`"
806
- if latest_installed && latest_installed > current
807
- suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`"
808
- suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest
809
- else
810
- suggestion = installation
811
- end
812
814
 
813
- Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
815
+ Bundler.ui.warn \
816
+ "The latest bundler is #{latest}, but you are currently running #{current}.\n" \
817
+ "To update to the most recent version, run `bundle update --bundler`"
814
818
  rescue RuntimeError
815
819
  nil
816
820
  end