bundler 2.2.24 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +149 -1
  3. data/README.md +1 -1
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli/cache.rb +1 -1
  6. data/lib/bundler/cli/doctor.rb +4 -3
  7. data/lib/bundler/cli/exec.rb +1 -6
  8. data/lib/bundler/cli/gem.rb +90 -10
  9. data/lib/bundler/cli/info.rb +16 -4
  10. data/lib/bundler/cli/install.rb +4 -17
  11. data/lib/bundler/cli/issue.rb +4 -3
  12. data/lib/bundler/cli/list.rb +7 -1
  13. data/lib/bundler/cli/open.rb +1 -2
  14. data/lib/bundler/cli/remove.rb +1 -2
  15. data/lib/bundler/cli/update.rb +3 -3
  16. data/lib/bundler/cli.rb +16 -10
  17. data/lib/bundler/compact_index_client/updater.rb +0 -5
  18. data/lib/bundler/compact_index_client.rb +2 -2
  19. data/lib/bundler/definition.rb +84 -150
  20. data/lib/bundler/digest.rb +71 -0
  21. data/lib/bundler/dsl.rb +32 -4
  22. data/lib/bundler/environment_preserver.rb +4 -1
  23. data/lib/bundler/errors.rb +19 -3
  24. data/lib/bundler/fetcher.rb +2 -1
  25. data/lib/bundler/friendly_errors.rb +5 -30
  26. data/lib/bundler/gem_helper.rb +6 -17
  27. data/lib/bundler/installer/gem_installer.rb +3 -16
  28. data/lib/bundler/installer/standalone.rb +13 -8
  29. data/lib/bundler/installer.rb +0 -1
  30. data/lib/bundler/lazy_specification.rb +17 -1
  31. data/lib/bundler/lockfile_parser.rb +2 -0
  32. data/lib/bundler/man/bundle-add.1 +1 -1
  33. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  34. data/lib/bundler/man/bundle-cache.1 +1 -1
  35. data/lib/bundler/man/bundle-check.1 +1 -1
  36. data/lib/bundler/man/bundle-clean.1 +1 -1
  37. data/lib/bundler/man/bundle-config.1 +3 -3
  38. data/lib/bundler/man/bundle-config.1.ronn +2 -2
  39. data/lib/bundler/man/bundle-doctor.1 +1 -1
  40. data/lib/bundler/man/bundle-exec.1 +1 -1
  41. data/lib/bundler/man/bundle-gem.1 +14 -1
  42. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  43. data/lib/bundler/man/bundle-info.1 +1 -1
  44. data/lib/bundler/man/bundle-init.1 +1 -1
  45. data/lib/bundler/man/bundle-inject.1 +1 -1
  46. data/lib/bundler/man/bundle-install.1 +1 -1
  47. data/lib/bundler/man/bundle-list.1 +1 -1
  48. data/lib/bundler/man/bundle-lock.1 +1 -1
  49. data/lib/bundler/man/bundle-open.1 +1 -1
  50. data/lib/bundler/man/bundle-outdated.1 +1 -1
  51. data/lib/bundler/man/bundle-platform.1 +1 -1
  52. data/lib/bundler/man/bundle-pristine.1 +1 -1
  53. data/lib/bundler/man/bundle-remove.1 +1 -1
  54. data/lib/bundler/man/bundle-show.1 +1 -1
  55. data/lib/bundler/man/bundle-update.1 +1 -1
  56. data/lib/bundler/man/bundle-viz.1 +1 -1
  57. data/lib/bundler/man/bundle.1 +1 -1
  58. data/lib/bundler/man/gemfile.5 +27 -1
  59. data/lib/bundler/man/gemfile.5.ronn +8 -0
  60. data/lib/bundler/plugin/api/source.rb +1 -0
  61. data/lib/bundler/plugin/installer.rb +2 -0
  62. data/lib/bundler/plugin.rb +23 -6
  63. data/lib/bundler/resolver.rb +8 -17
  64. data/lib/bundler/rubygems_ext.rb +4 -0
  65. data/lib/bundler/rubygems_gem_installer.rb +25 -5
  66. data/lib/bundler/rubygems_integration.rb +28 -9
  67. data/lib/bundler/runtime.rb +17 -8
  68. data/lib/bundler/settings.rb +13 -1
  69. data/lib/bundler/setup.rb +2 -2
  70. data/lib/bundler/shared_helpers.rb +2 -10
  71. data/lib/bundler/source/git/git_proxy.rb +8 -6
  72. data/lib/bundler/source/git.rb +22 -4
  73. data/lib/bundler/source/rubygems.rb +70 -81
  74. data/lib/bundler/source/rubygems_aggregate.rb +4 -0
  75. data/lib/bundler/source.rb +4 -0
  76. data/lib/bundler/source_list.rb +22 -31
  77. data/lib/bundler/spec_set.rb +14 -36
  78. data/lib/bundler/templates/Executable.bundler +6 -6
  79. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  80. data/lib/bundler/templates/newgem/Rakefile.tt +5 -1
  81. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -2
  82. data/lib/bundler/templates/newgem/newgem.gemspec.tt +16 -14
  83. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  84. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  85. data/lib/bundler/vendor/.document +1 -0
  86. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  87. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  88. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  89. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  90. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  91. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  92. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  93. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  94. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  95. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  96. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  97. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  98. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  99. data/lib/bundler/vendored_tsort.rb +4 -0
  100. data/lib/bundler/version.rb +1 -1
  101. data/lib/bundler/worker.rb +19 -4
  102. data/lib/bundler.rb +13 -22
  103. metadata +20 -7
  104. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GEMFILE" "5" "June 2021" "" ""
4
+ .TH "GEMFILE" "5" "December 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
@@ -506,6 +506,32 @@ gem "rails", :git => "git://github\.com/rails/rails\.git"
506
506
  .P
507
507
  Since the \fBgithub\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
508
508
  .
509
+ .P
510
+ You can also directly pass a pull request URL:
511
+ .
512
+ .IP "" 4
513
+ .
514
+ .nf
515
+
516
+ gem "rails", :github => "https://github\.com/rails/rails/pull/43753"
517
+ .
518
+ .fi
519
+ .
520
+ .IP "" 0
521
+ .
522
+ .P
523
+ Which is equivalent to:
524
+ .
525
+ .IP "" 4
526
+ .
527
+ .nf
528
+
529
+ gem "rails", :github => "rails/rails", branch: "refs/pull/43753/head"
530
+ .
531
+ .fi
532
+ .
533
+ .IP "" 0
534
+ .
509
535
  .SS "GIST"
510
536
  If the git repository you want to use is hosted as a Github Gist and is public, you can use the :gist shorthand to specify the gist identifier (without the trailing "\.git")\.
511
537
  .
@@ -372,6 +372,14 @@ Are both equivalent to
372
372
 
373
373
  Since the `github` method is a specialization of `git_source`, it accepts a `:branch` named argument.
374
374
 
375
+ You can also directly pass a pull request URL:
376
+
377
+ gem "rails", :github => "https://github.com/rails/rails/pull/43753"
378
+
379
+ Which is equivalent to:
380
+
381
+ gem "rails", :github => "rails/rails", branch: "refs/pull/43753/head"
382
+
375
383
  ### GIST
376
384
 
377
385
  If the git repository you want to use is hosted as a Github Gist and is public, you can use
@@ -283,6 +283,7 @@ module Bundler
283
283
  def to_s
284
284
  "plugin source for #{@type} with uri #{@uri}"
285
285
  end
286
+ alias_method :identifier, :to_s
286
287
 
287
288
  # Note: Do not override if you don't know what you are doing.
288
289
  def include?(other)
@@ -81,6 +81,8 @@ module Bundler
81
81
 
82
82
  deps = names.map {|name| Dependency.new name, version }
83
83
 
84
+ Bundler.configure_gem_home_and_path(Plugin.root)
85
+
84
86
  definition = Definition.new(nil, deps, source_list, true)
85
87
  install_definition(definition)
86
88
  end
@@ -13,6 +13,7 @@ module Bundler
13
13
  class MalformattedPlugin < PluginError; end
14
14
  class UndefinedCommandError < PluginError; end
15
15
  class UnknownSourceError < PluginError; end
16
+ class PluginInstallError < PluginError; end
16
17
 
17
18
  PLUGIN_FILE_NAME = "plugins.rb".freeze
18
19
 
@@ -38,12 +39,11 @@ module Bundler
38
39
  specs = Installer.new.install(names, options)
39
40
 
40
41
  save_plugins names, specs
41
- rescue PluginError => e
42
+ rescue PluginError
42
43
  specs_to_delete = specs.select {|k, _v| names.include?(k) && !index.commands.values.include?(k) }
43
44
  specs_to_delete.each_value {|spec| Bundler.rm_rf(spec.full_gem_path) }
44
45
 
45
- names_list = names.map {|name| "`#{name}`" }.join(", ")
46
- Bundler.ui.error "Failed to install the following plugins: #{names_list}. The underlying error was: #{e.message}.\n #{e.backtrace.join("\n ")}"
46
+ raise
47
47
  end
48
48
 
49
49
  # Uninstalls plugins by the given names
@@ -245,10 +245,11 @@ module Bundler
245
245
  # @param [Array<String>] names of inferred source plugins that can be ignored
246
246
  def save_plugins(plugins, specs, optional_plugins = [])
247
247
  plugins.each do |name|
248
+ next if index.installed?(name)
249
+
248
250
  spec = specs[name]
249
- validate_plugin! Pathname.new(spec.full_gem_path)
250
- installed = register_plugin(name, spec, optional_plugins.include?(name))
251
- Bundler.ui.info "Installed plugin #{name}" if installed
251
+
252
+ save_plugin(name, spec, optional_plugins.include?(name))
252
253
  end
253
254
  end
254
255
 
@@ -263,6 +264,22 @@ module Bundler
263
264
  raise MalformattedPlugin, "#{PLUGIN_FILE_NAME} was not found in the plugin." unless plugin_file.file?
264
265
  end
265
266
 
267
+ # Validates and registers a plugin.
268
+ #
269
+ # @param [String] name the name of the plugin
270
+ # @param [Specification] spec of installed plugin
271
+ # @param [Boolean] optional_plugin, removed if there is conflict with any
272
+ # other plugin (used for default source plugins)
273
+ #
274
+ # @raise [PluginInstallError] if validation or registration raises any error
275
+ def save_plugin(name, spec, optional_plugin = false)
276
+ validate_plugin! Pathname.new(spec.full_gem_path)
277
+ installed = register_plugin(name, spec, optional_plugin)
278
+ Bundler.ui.info "Installed plugin #{name}" if installed
279
+ rescue PluginError => e
280
+ raise PluginInstallError, "Failed to install plugin `#{spec.name}`, due to #{e.class} (#{e.message})"
281
+ end
282
+
266
283
  # Runs the plugins.rb file in an isolated namespace, records the plugin
267
284
  # actions it registers for and then passes the data to index to be stored.
268
285
  #
@@ -30,10 +30,8 @@ module Bundler
30
30
  @resolver = Molinillo::Resolver.new(self, self)
31
31
  @search_for = {}
32
32
  @base_dg = Molinillo::DependencyGraph.new
33
- aggregate_global_source = @source_requirements[:default].is_a?(Source::RubygemsAggregate)
34
33
  @base.each do |ls|
35
34
  dep = Dependency.new(ls.name, ls.version)
36
- ls.source = source_for(ls.name) unless aggregate_global_source
37
35
  @base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true)
38
36
  end
39
37
  additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) }
@@ -255,12 +253,6 @@ module Bundler
255
253
  next if name == "bundler"
256
254
  next unless search_for(requirement).empty?
257
255
 
258
- cache_message = begin
259
- " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
260
- rescue GemfileNotFound
261
- nil
262
- end
263
-
264
256
  if (base = @base[name]) && !base.empty?
265
257
  version = base.first.version
266
258
  message = "You have requested:\n" \
@@ -269,18 +261,17 @@ module Bundler
269
261
  "Try running `bundle update #{name}`\n\n" \
270
262
  "If you are updating multiple gems in your Gemfile at once,\n" \
271
263
  "try passing them all to `bundle update`"
272
- elsif source = @source_requirements[name]
264
+ else
265
+ source = source_for(name)
273
266
  specs = source.specs.search(name)
274
267
  versions_with_platforms = specs.map {|s| [s.version, s.platform] }
268
+ cache_message = begin
269
+ " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
270
+ rescue GemfileNotFound
271
+ nil
272
+ end
275
273
  message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
276
- message << if versions_with_platforms.any?
277
- "The source contains the following versions of '#{name}': #{formatted_versions_with_platforms(versions_with_platforms)}"
278
- else
279
- "The source does not contain any versions of '#{name}'"
280
- end
281
- else
282
- message = "Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in any of the gem sources " \
283
- "listed in your Gemfile#{cache_message}."
274
+ message << "The source contains the following versions of '#{name}': #{formatted_versions_with_platforms(versions_with_platforms)}" if versions_with_platforms.any?
284
275
  end
285
276
  raise GemNotFound, message
286
277
  end
@@ -85,6 +85,10 @@ module Gem
85
85
  dependencies - development_dependencies
86
86
  end
87
87
 
88
+ def deleted_gem?
89
+ !default_gem? && !File.directory?(full_gem_path)
90
+ end
91
+
88
92
  private
89
93
 
90
94
  def dependencies_to_gemfile(dependencies, group = nil)
@@ -16,10 +16,12 @@ module Bundler
16
16
  spec.loaded_from = spec_file
17
17
 
18
18
  # Completely remove any previous gem files
19
- FileUtils.rm_rf gem_dir
20
- FileUtils.rm_rf spec.extension_dir
19
+ strict_rm_rf gem_dir
20
+ strict_rm_rf spec.extension_dir
21
21
 
22
- FileUtils.mkdir_p gem_dir, :mode => 0o755
22
+ SharedHelpers.filesystem_access(gem_dir, :create) do
23
+ FileUtils.mkdir_p gem_dir, :mode => 0o755
24
+ end
23
25
 
24
26
  extract_files
25
27
 
@@ -31,7 +33,10 @@ module Bundler
31
33
  generate_plugins
32
34
 
33
35
  write_spec
34
- write_cache_file
36
+
37
+ SharedHelpers.filesystem_access("#{gem_home}/cache", :write) do
38
+ write_cache_file
39
+ end
35
40
 
36
41
  say spec.post_install_message unless spec.post_install_message.nil?
37
42
 
@@ -61,7 +66,10 @@ module Bundler
61
66
 
62
67
  def build_extensions
63
68
  extension_cache_path = options[:bundler_extension_cache_path]
64
- return super unless extension_cache_path && extension_dir = spec.extension_dir
69
+ unless extension_cache_path && extension_dir = spec.extension_dir
70
+ require "shellwords" # compensate missing require in rubygems before version 3.2.25
71
+ return super
72
+ end
65
73
 
66
74
  extension_dir = Pathname.new(extension_dir)
67
75
  build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
@@ -71,6 +79,7 @@ module Bundler
71
79
  FileUtils.cp_r extension_cache_path, spec.extension_dir
72
80
  end
73
81
  else
82
+ require "shellwords" # compensate missing require in rubygems before version 3.2.25
74
83
  super
75
84
  if extension_dir.directory? # not made for gems without extensions
76
85
  SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
@@ -83,6 +92,17 @@ module Bundler
83
92
 
84
93
  private
85
94
 
95
+ def strict_rm_rf(dir)
96
+ # FileUtils.rm_rf should probably rise in case of permission issues like
97
+ # `rm -rf` does. However, it fails to delete the folder silently due to
98
+ # https://github.com/ruby/fileutils/issues/57. It should probably be fixed
99
+ # inside `fileutils` but for now I`m checking whether the folder was
100
+ # removed after it completes, and raising otherwise.
101
+ FileUtils.rm_rf dir
102
+
103
+ raise PermissionError.new(dir, :delete) if File.directory?(dir)
104
+ end
105
+
86
106
  def validate_bundler_checksum(checksum)
87
107
  return true if Bundler.settings[:disable_checksum_validation]
88
108
  return true unless checksum
@@ -34,10 +34,12 @@ module Bundler
34
34
  end
35
35
 
36
36
  def build_args
37
+ require "rubygems/command"
37
38
  Gem::Command.build_args
38
39
  end
39
40
 
40
41
  def build_args=(args)
42
+ require "rubygems/command"
41
43
  Gem::Command.build_args = args
42
44
  end
43
45
 
@@ -84,16 +86,12 @@ module Bundler
84
86
  def spec_missing_extensions?(spec, default = true)
85
87
  return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
86
88
 
87
- return false if spec_default_gem?(spec)
89
+ return false if spec.default_gem?
88
90
  return false if spec.extensions.empty?
89
91
 
90
92
  default
91
93
  end
92
94
 
93
- def spec_default_gem?(spec)
94
- spec.respond_to?(:default_gem?) && spec.default_gem?
95
- end
96
-
97
95
  def spec_matches_for_glob(spec, glob)
98
96
  return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
99
97
 
@@ -502,14 +500,15 @@ module Bundler
502
500
  end
503
501
 
504
502
  def fetch_specs(remote, name)
503
+ require "rubygems/remote_fetcher"
505
504
  path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
506
505
  fetcher = gem_remote_fetcher
507
506
  fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
508
507
  string = fetcher.fetch_path(path)
509
508
  Bundler.load_marshal(string)
510
- rescue Gem::RemoteFetcher::FetchError => e
509
+ rescue Gem::RemoteFetcher::FetchError
511
510
  # it's okay for prerelease to fail
512
- raise e unless name == "prerelease_specs"
511
+ raise unless name == "prerelease_specs"
513
512
  end
514
513
 
515
514
  def fetch_all_remote_specs(remote)
@@ -519,12 +518,32 @@ module Bundler
519
518
  specs.concat(pres)
520
519
  end
521
520
 
522
- def download_gem(spec, uri, path)
521
+ def download_gem(spec, uri, cache_dir)
522
+ require "rubygems/remote_fetcher"
523
523
  uri = Bundler.settings.mirror_for(uri)
524
524
  fetcher = gem_remote_fetcher
525
525
  fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
526
526
  Bundler::Retry.new("download gem from #{uri}").attempts do
527
- fetcher.download(spec, uri, path)
527
+ gem_file_name = spec.file_name
528
+ local_gem_path = File.join cache_dir, gem_file_name
529
+ return if File.exist? local_gem_path
530
+
531
+ begin
532
+ remote_gem_path = uri + "gems/#{gem_file_name}"
533
+ remote_gem_path = remote_gem_path.to_s if provides?("< 3.2.0.rc.1")
534
+
535
+ SharedHelpers.filesystem_access(local_gem_path) do
536
+ fetcher.cache_update_path remote_gem_path, local_gem_path
537
+ end
538
+ rescue Gem::RemoteFetcher::FetchError
539
+ raise if spec.original_platform == spec.platform
540
+
541
+ original_gem_file_name = "#{spec.original_name}.gem"
542
+ raise if gem_file_name == original_gem_file_name
543
+
544
+ gem_file_name = original_gem_file_name
545
+ retry
546
+ end
528
547
  end
529
548
  rescue Gem::RemoteFetcher::FetchError => e
530
549
  raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
@@ -22,10 +22,6 @@ module Bundler
22
22
 
23
23
  # Activate the specs
24
24
  load_paths = specs.map do |spec|
25
- unless spec.loaded_from
26
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
27
- end
28
-
29
25
  check_for_activated_spec!(spec)
30
26
 
31
27
  Bundler.rubygems.mark_loaded(spec)
@@ -104,7 +100,7 @@ module Bundler
104
100
 
105
101
  alias_method :gems, :specs
106
102
 
107
- def cache(custom_path = nil)
103
+ def cache(custom_path = nil, local = false)
108
104
  cache_path = Bundler.app_cache(custom_path)
109
105
  SharedHelpers.filesystem_access(cache_path) do |p|
110
106
  FileUtils.mkdir_p(p)
@@ -112,7 +108,20 @@ module Bundler
112
108
 
113
109
  Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
114
110
 
115
- specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
111
+ specs_to_cache = if Bundler.settings[:cache_all_platforms]
112
+ @definition.resolve.materialized_for_all_platforms
113
+ else
114
+ begin
115
+ specs
116
+ rescue GemNotFound
117
+ if local
118
+ Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
119
+ end
120
+
121
+ raise
122
+ end
123
+ end
124
+
116
125
  specs_to_cache.each do |spec|
117
126
  next if spec.name == "bundler"
118
127
  next if spec.source.is_a?(Source::Gemspec)
@@ -256,7 +265,7 @@ module Bundler
256
265
 
257
266
  return if manuals.empty?
258
267
  Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
259
- ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
268
+ ENV["MANPATH"] ? ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) : [""]
260
269
  ).uniq.join(File::PATH_SEPARATOR)
261
270
  end
262
271
 
@@ -282,7 +291,7 @@ module Bundler
282
291
  return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
283
292
  return if activated_spec.version == spec.version
284
293
 
285
- suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
294
+ suggestion = if activated_spec.default_gem?
286
295
  "Since #{spec.name} is a default gem, you can either remove your dependency on it" \
287
296
  " or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
288
297
  else
@@ -419,7 +419,15 @@ module Bundler
419
419
  elsif is_credential(key)
420
420
  "[REDACTED]"
421
421
  elsif is_userinfo(converted)
422
- converted.gsub(/:.*$/, ":[REDACTED]")
422
+ username, pass = converted.split(":", 2)
423
+
424
+ if pass == "x-oauth-basic"
425
+ username = "[REDACTED]"
426
+ else
427
+ pass = "[REDACTED]"
428
+ end
429
+
430
+ [username, pass].join(":")
423
431
  else
424
432
  converted
425
433
  end
@@ -428,6 +436,10 @@ module Bundler
428
436
  def global_config_file
429
437
  if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
430
438
  Pathname.new(ENV["BUNDLE_CONFIG"])
439
+ elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
440
+ Pathname.new(ENV["BUNDLE_USER_CONFIG"])
441
+ elsif ENV["BUNDLE_USER_HOME"] && !ENV["BUNDLE_USER_HOME"].empty?
442
+ Pathname.new(ENV["BUNDLE_USER_HOME"]).join("config")
431
443
  elsif Bundler.rubygems.user_home && !Bundler.rubygems.user_home.empty?
432
444
  Pathname.new(Bundler.rubygems.user_home).join(".bundle/config")
433
445
  end
data/lib/bundler/setup.rb CHANGED
@@ -9,10 +9,10 @@ if Bundler::SharedHelpers.in_bundle?
9
9
  begin
10
10
  Bundler.ui.silence { Bundler.setup }
11
11
  rescue Bundler::BundlerError => e
12
- Bundler.ui.warn "\e[31m#{e.message}\e[0m"
12
+ Bundler.ui.error e.message
13
13
  Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
14
14
  if e.is_a?(Bundler::GemNotFound)
15
- Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m"
15
+ Bundler.ui.warn "Run `bundle install` to install missing gems."
16
16
  end
17
17
  exit e.status_code
18
18
  end
@@ -152,13 +152,6 @@ module Bundler
152
152
  Bundler.ui.warn message
153
153
  end
154
154
 
155
- def trap(signal, override = false, &block)
156
- prior = Signal.trap(signal) do
157
- block.call
158
- prior.call unless override
159
- end
160
- end
161
-
162
155
  def ensure_same_dependencies(spec, old_deps, new_deps)
163
156
  new_deps = new_deps.reject {|d| d.type == :development }
164
157
  old_deps = old_deps.reject {|d| d.type == :development }
@@ -327,12 +320,11 @@ module Bundler
327
320
  end
328
321
 
329
322
  def clean_load_path
330
- bundler_lib = bundler_ruby_lib
331
-
332
323
  loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
333
324
 
334
325
  $LOAD_PATH.reject! do |p|
335
- next if resolve_path(p).start_with?(bundler_lib)
326
+ resolved_path = resolve_path(p)
327
+ next if $LOADED_FEATURES.any? {|lf| lf.start_with?(resolved_path) }
336
328
  loaded_gem_paths.delete(p)
337
329
  end
338
330
  $LOAD_PATH.uniq!
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class Source
7
5
  class Git
@@ -58,7 +56,6 @@ module Bundler
58
56
  @ref = ref
59
57
  @revision = revision
60
58
  @git = git
61
- raise GitNotInstalledError.new if allow? && !Bundler.git_present?
62
59
  end
63
60
 
64
61
  def revision
@@ -98,12 +95,12 @@ module Bundler
98
95
  SharedHelpers.filesystem_access(path.dirname) do |p|
99
96
  FileUtils.mkdir_p(p)
100
97
  end
101
- git_retry "clone", configured_uri, path.to_s, "--bare", "--no-hardlinks", "--quiet"
98
+ git_retry "clone", "--bare", "--no-hardlinks", "--quiet", "--", configured_uri, path.to_s
102
99
  return unless extra_ref
103
100
  end
104
101
 
105
102
  with_path do
106
- git_retry(*["fetch", "--force", "--quiet", "--tags", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
103
+ git_retry(*["fetch", "--force", "--quiet", "--tags", "--", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
107
104
  end
108
105
  end
109
106
 
@@ -210,7 +207,11 @@ module Bundler
210
207
  end
211
208
 
212
209
  def allow?
213
- @git ? @git.allow_git_ops? : true
210
+ allowed = @git ? @git.allow_git_ops? : true
211
+
212
+ raise GitNotInstalledError.new if allowed && !Bundler.git_present?
213
+
214
+ allowed
214
215
  end
215
216
 
216
217
  def with_path(&blk)
@@ -224,6 +225,7 @@ module Bundler
224
225
  end
225
226
 
226
227
  def check_allowed(command)
228
+ require "shellwords"
227
229
  command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
228
230
  raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
229
231
  command_with_no_credentials
@@ -42,7 +42,7 @@ module Bundler
42
42
  %w[ref branch tag submodules].each do |opt|
43
43
  out << " #{opt}: #{options[opt]}\n" if options[opt]
44
44
  end
45
- out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
45
+ out << " glob: #{@glob}\n" unless default_glob?
46
46
  out << " specs:\n"
47
47
  end
48
48
 
@@ -75,12 +75,20 @@ module Bundler
75
75
  git_proxy.branch
76
76
  end
77
77
 
78
- rev = " (at #{at}@#{shortref_for_display(revision)})"
78
+ rev = "at #{at}@#{shortref_for_display(revision)}"
79
79
  rescue GitError
80
80
  ""
81
81
  end
82
82
 
83
- "#{@safe_uri}#{rev}"
83
+ specifiers = [rev, glob_for_display].compact
84
+ suffix =
85
+ if specifiers.any?
86
+ " (#{specifiers.join(", ")})"
87
+ else
88
+ ""
89
+ end
90
+
91
+ "#{@safe_uri}#{suffix}"
84
92
  end
85
93
 
86
94
  def name
@@ -282,6 +290,14 @@ module Bundler
282
290
  ref[0..11]
283
291
  end
284
292
 
293
+ def glob_for_display
294
+ default_glob? ? nil : "glob: #{@glob}"
295
+ end
296
+
297
+ def default_glob?
298
+ @glob == DEFAULT_GLOB
299
+ end
300
+
285
301
  def uri_hash
286
302
  if uri =~ %r{^\w+://(\w+@)?}
287
303
  # Downcase the domain component of the URI
@@ -291,7 +307,9 @@ module Bundler
291
307
  # If there is no URI scheme, assume it is an ssh/git URI
292
308
  input = uri
293
309
  end
294
- SharedHelpers.digest(:SHA1).hexdigest(input)
310
+ # We use SHA1 here for historical reason and to preserve backward compatibility.
311
+ # But a transition to a simpler mangling algorithm would be welcome.
312
+ Bundler::Digest.sha1(input)
295
313
  end
296
314
 
297
315
  def cached_revision