bundler 2.2.15 → 2.2.20

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -6
  3. data/bundler.gemspec +2 -3
  4. data/lib/bundler.rb +1 -0
  5. data/lib/bundler/build_metadata.rb +2 -2
  6. data/lib/bundler/cli.rb +16 -35
  7. data/lib/bundler/cli/check.rb +4 -2
  8. data/lib/bundler/cli/common.rb +15 -2
  9. data/lib/bundler/cli/gem.rb +9 -1
  10. data/lib/bundler/cli/outdated.rb +10 -11
  11. data/lib/bundler/compact_index_client/updater.rb +9 -5
  12. data/lib/bundler/current_ruby.rb +1 -0
  13. data/lib/bundler/definition.rb +27 -84
  14. data/lib/bundler/feature_flag.rb +0 -2
  15. data/lib/bundler/fetcher.rb +2 -1
  16. data/lib/bundler/fetcher/downloader.rb +8 -4
  17. data/lib/bundler/fetcher/index.rb +0 -1
  18. data/lib/bundler/friendly_errors.rb +2 -4
  19. data/lib/bundler/gem_helper.rb +16 -0
  20. data/lib/bundler/index.rb +1 -2
  21. data/lib/bundler/injector.rb +2 -2
  22. data/lib/bundler/inline.rb +1 -1
  23. data/lib/bundler/lazy_specification.rb +3 -3
  24. data/lib/bundler/man/bundle-add.1 +1 -1
  25. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  26. data/lib/bundler/man/bundle-cache.1 +1 -1
  27. data/lib/bundler/man/bundle-check.1 +1 -1
  28. data/lib/bundler/man/bundle-clean.1 +1 -1
  29. data/lib/bundler/man/bundle-config.1 +21 -10
  30. data/lib/bundler/man/bundle-config.1.ronn +21 -11
  31. data/lib/bundler/man/bundle-doctor.1 +1 -1
  32. data/lib/bundler/man/bundle-exec.1 +1 -1
  33. data/lib/bundler/man/bundle-gem.1 +1 -1
  34. data/lib/bundler/man/bundle-info.1 +1 -1
  35. data/lib/bundler/man/bundle-init.1 +1 -1
  36. data/lib/bundler/man/bundle-inject.1 +1 -1
  37. data/lib/bundler/man/bundle-install.1 +1 -1
  38. data/lib/bundler/man/bundle-list.1 +1 -1
  39. data/lib/bundler/man/bundle-lock.1 +1 -1
  40. data/lib/bundler/man/bundle-open.1 +1 -1
  41. data/lib/bundler/man/bundle-outdated.1 +1 -1
  42. data/lib/bundler/man/bundle-platform.1 +1 -1
  43. data/lib/bundler/man/bundle-pristine.1 +1 -1
  44. data/lib/bundler/man/bundle-remove.1 +1 -1
  45. data/lib/bundler/man/bundle-show.1 +1 -1
  46. data/lib/bundler/man/bundle-update.1 +1 -1
  47. data/lib/bundler/man/bundle-viz.1 +1 -1
  48. data/lib/bundler/man/bundle.1 +1 -1
  49. data/lib/bundler/man/gemfile.5 +1 -1
  50. data/lib/bundler/plugin.rb +2 -2
  51. data/lib/bundler/plugin/api/source.rb +14 -0
  52. data/lib/bundler/resolver.rb +13 -96
  53. data/lib/bundler/resolver/spec_group.rb +0 -24
  54. data/lib/bundler/retry.rb +1 -1
  55. data/lib/bundler/rubygems_ext.rb +2 -2
  56. data/lib/bundler/rubygems_integration.rb +4 -3
  57. data/lib/bundler/settings.rb +74 -12
  58. data/lib/bundler/source.rb +11 -0
  59. data/lib/bundler/source/rubygems.rb +23 -10
  60. data/lib/bundler/source/rubygems_aggregate.rb +64 -0
  61. data/lib/bundler/source_list.rb +33 -10
  62. data/lib/bundler/source_map.rb +58 -0
  63. data/lib/bundler/spec_set.rb +18 -7
  64. data/lib/bundler/templates/Gemfile +1 -1
  65. data/lib/bundler/templates/gems.rb +1 -1
  66. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -4
  67. data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  68. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  69. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +1 -1
  70. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  71. data/lib/bundler/version.rb +1 -1
  72. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7969bf6c1c6e781cd3d6f06c9d832cc7604c9304ed19da98e52744f1ea22dac9
4
- data.tar.gz: c4d0c758c8d71ad5de08b2ac6bfec61306e276dda94505a2942dc68657769571
3
+ metadata.gz: 4a5ddfd28833c653d3cd3a52747d330b88afb969505fb0f86f6d9d0284ecd258
4
+ data.tar.gz: cf7cd1023266b890498a486f908f1dbdc84f8a5c932af96a57bcdfe75e09b4fc
5
5
  SHA512:
6
- metadata.gz: ed31592d981989e540c694657fdf663e4a53a8c635e797d5f85b1240f80dcefa30433e926459235d5614c42da2081c6a45304eeacb0f1bec963e4ab64702e19e
7
- data.tar.gz: 6381ced4711505050ef620d25d9a6d693a98c70f2fd667d6e7ac506ade25ddbc9909d16e0715cbfeacb7cc07e1cd2a1655d48c91844d214bfd66a502f68b0072
6
+ metadata.gz: c370cdb78e65a16549392990fd9c3666a7db97269992a9904b22b247d37673ea76910501ad3cea81657d860eccbfa887d7949912384eb180e274c125a2b2d98e
7
+ data.tar.gz: 52cc6c1e34756194d72937614886b566d887b8cd97d7f13d826f53e9fc51e570a3f7c15ea04ced78ba4e1a956960945302cd050a19d276544519fb8daccfd212
data/CHANGELOG.md CHANGED
@@ -1,4 +1,84 @@
1
- # 2.2.15 (March 18, 2021)
1
+ # 2.2.20 (June 11, 2021)
2
+
3
+ ## Enhancements:
4
+
5
+ - Don't print bug report template on server side errors [#4663](https://github.com/rubygems/rubygems/pull/4663)
6
+ - Don't load `resolv` unnecessarily [#4640](https://github.com/rubygems/rubygems/pull/4640)
7
+
8
+ ## Bug fixes:
9
+
10
+ - Fix `bundle outdated` edge case [#4648](https://github.com/rubygems/rubygems/pull/4648)
11
+ - Fix `bundle check` with scoped rubygems sources [#4639](https://github.com/rubygems/rubygems/pull/4639)
12
+
13
+ ## Performance:
14
+
15
+ - Don't use `extra_rdoc_files` with md files in gemspec to make installing bundler with docs faster [#4628](https://github.com/rubygems/rubygems/pull/4628)
16
+
17
+ # 2.2.19 (May 31, 2021)
18
+
19
+ ## Bug fixes:
20
+
21
+ - Restore support for configuration keys with dashes [#4582](https://github.com/rubygems/rubygems/pull/4582)
22
+ - Fix some cached gems being unintentionally ignored when using rubygems 3.2.18 [#4623](https://github.com/rubygems/rubygems/pull/4623)
23
+
24
+ # 2.2.18 (May 25, 2021)
25
+
26
+ ## Security fixes:
27
+
28
+ - Fix dependency confusion issues with implicit dependencies [#4609](https://github.com/rubygems/rubygems/pull/4609)
29
+
30
+ ## Enhancements:
31
+
32
+ - Use simpler notation for generated `required_ruby_version` [#4598](https://github.com/rubygems/rubygems/pull/4598)
33
+ - Undeprecate bundle show [#4586](https://github.com/rubygems/rubygems/pull/4586)
34
+ - Make sure link to new issue uses the proper template [#4592](https://github.com/rubygems/rubygems/pull/4592)
35
+
36
+ ## Bug fixes:
37
+
38
+ - Fix platform specific gems being removed from the lockfile [#4580](https://github.com/rubygems/rubygems/pull/4580)
39
+
40
+ # 2.2.17 (May 5, 2021)
41
+
42
+ ## Enhancements:
43
+
44
+ - Improve authentication required error message to include an alternative using `ENV` [#4565](https://github.com/rubygems/rubygems/pull/4565)
45
+ - Discard partial range responses without etag [#4563](https://github.com/rubygems/rubygems/pull/4563)
46
+ - Fix configuring ENV for a gem server with a name including dashes [#4571](https://github.com/rubygems/rubygems/pull/4571)
47
+ - Redact credentials from `bundle env` and `bundle config` [#4566](https://github.com/rubygems/rubygems/pull/4566)
48
+ - Redact all sources in verbose mode [#4564](https://github.com/rubygems/rubygems/pull/4564)
49
+ - Improve `bundle pristine` error if `BUNDLE_GEMFILE` does not exist [#4536](https://github.com/rubygems/rubygems/pull/4536)
50
+ - [CurrentRuby] Add 3.0 as a known minor [#4535](https://github.com/rubygems/rubygems/pull/4535)
51
+ - Prefer File.read instead of IO.read [#4530](https://github.com/rubygems/rubygems/pull/4530)
52
+ - Add space after open curly bracket in Gemfile and gems.rb template [#4518](https://github.com/rubygems/rubygems/pull/4518)
53
+
54
+ ## Bug fixes:
55
+
56
+ - Make sure specs are fetched from the right source when materializing [#4562](https://github.com/rubygems/rubygems/pull/4562)
57
+ - Fix `bundle cache` with an up-to-date lockfile and specs not already installed [#4554](https://github.com/rubygems/rubygems/pull/4554)
58
+ - Ignore `deployment` setting in inline mode [#4523](https://github.com/rubygems/rubygems/pull/4523)
59
+
60
+ ## Performance:
61
+
62
+ - Don't materialize resolutions when not necessary [#4556](https://github.com/rubygems/rubygems/pull/4556)
63
+
64
+ # 2.2.16 (April 8, 2021)
65
+
66
+ ## Enhancements:
67
+
68
+ - Add `--github-username` option and config to `bundle gem` [#3687](https://github.com/rubygems/rubygems/pull/3687)
69
+ - Bump vendored `tmpdir` library copy [#4506](https://github.com/rubygems/rubygems/pull/4506)
70
+ - Add `rake build:checksum` task to build checksums for a gem package [#4156](https://github.com/rubygems/rubygems/pull/4156)
71
+ - Enable bundler-cache for GitHub Actions template [#4498](https://github.com/rubygems/rubygems/pull/4498)
72
+ - Improve `bundle info` error when gem is on a "disabled" group [#4492](https://github.com/rubygems/rubygems/pull/4492)
73
+ - Small tweak to yank message [#4494](https://github.com/rubygems/rubygems/pull/4494)
74
+ - Don't show duplicate entries in `bundle outdated` output [#4474](https://github.com/rubygems/rubygems/pull/4474)
75
+ - Never downgrade top level gems when running `bundle update` [#4473](https://github.com/rubygems/rubygems/pull/4473)
76
+
77
+ ## Bug fixes:
78
+
79
+ - Fix incorrect logic for filtering metadata matching candidates [#4497](https://github.com/rubygems/rubygems/pull/4497)
80
+
81
+ # 2.2.15 (March 19, 2021)
2
82
 
3
83
  ## Enhancements:
4
84
 
@@ -455,7 +535,7 @@
455
535
  - Ignore `frozen` setting in inline mode ([#7125](https://github.com/rubygems/bundler/pull/7125))
456
536
  - Fix incorrect "bundler attempted to update GEM but version stayed the same" message when updating git sourced gems ([#6325](https://github.com/rubygems/bundler/pull/6325))
457
537
  - Don't check for existence of a writable home directory if `BUNDLE_USER_HOME` is set ([#6885](https://github.com/rubygems/bundler/pull/6885))
458
- - Fix error message when server would respond to a bad username/password requiest with a 401 ([#6928](https://github.com/rubygems/bundler/pull/6928))
538
+ - Fix error message when server would respond to a bad username/password request with a 401 ([#6928](https://github.com/rubygems/bundler/pull/6928))
459
539
  - Fix `bundle outdated` pluralization when multiple groups are requested ([#7063](https://github.com/rubygems/bundler/pull/7063))
460
540
  - Fix `bundle install` not updating conservatively when gemspec is changed ([#7143](https://github.com/rubygems/bundler/pull/7143))
461
541
  - Fix `bundle exec` not respecting custom process titles inside scripts ([#7140](https://github.com/rubygems/bundler/pull/7140))
@@ -2100,7 +2180,7 @@ Changes
2100
2180
  - fix Bundler.which for directories ([#2697](https://github.com/rubygems/bundler/issues/2697), @rhysd)
2101
2181
  - properly require `Capistrano::Version` ([#2690](https://github.com/rubygems/bundler/issues/2690), @steveklabnik)
2102
2182
  - search for git.exe and git
2103
- - fix the bug that downloads every spec when API fetcher encouters an error
2183
+ - fix the bug that downloads every spec when API fetcher encounters an error
2104
2184
  - only retry network requests
2105
2185
 
2106
2186
  # 1.4.0.rc.1 (September 29, 2013)
@@ -2724,7 +2804,7 @@ Changes
2724
2804
 
2725
2805
  - Implement `to_ary` to avoid calls to method_missing (@tenderlove, [#1274](https://github.com/rubygems/bundler/issues/1274))
2726
2806
  - bundle clean removes old .gem files (@cldwalker, [#1293](https://github.com/rubygems/bundler/issues/1293))
2727
- - Correcly identify missing child dependency in error message
2807
+ - Correctly identify missing child dependency in error message
2728
2808
  - Run pre-install, post-build, and post-install gem hooks for git gems (@warhammerkid, [#1120](https://github.com/rubygems/bundler/issues/1120))
2729
2809
  - create Gemfile.lock for empty Gemfile ([#1218](https://github.com/rubygems/bundler/issues/1218))
2730
2810
 
@@ -2875,7 +2955,7 @@ Changes
2875
2955
 
2876
2956
  - Performance fix for MRI 1.9 (@efficientcloud, [#1288](https://github.com/rubygems/bundler/issues/1288))
2877
2957
  - Shortcuts (like `bundle i`) for all commands (@amatsuda)
2878
- - Correcly identify missing child dependency in error message
2958
+ - Correctly identify missing child dependency in error message
2879
2959
 
2880
2960
  ## Bug fixes:
2881
2961
 
@@ -3111,7 +3191,7 @@ Changes
3111
3191
 
3112
3192
  - Various bugfixes to the built-in rake helpers
3113
3193
  - Fix a bug where shortrefs weren't unique enough and were
3114
- therfore colliding
3194
+ therefore colliding
3115
3195
  - Fix a small bug involving checking whether a local git
3116
3196
  clone is up to date
3117
3197
  - Correctly handle explicit '=' dependencies with gems
data/bundler.gemspec CHANGED
@@ -34,13 +34,12 @@ Gem::Specification.new do |s|
34
34
  s.required_ruby_version = ">= 2.3.0"
35
35
  s.required_rubygems_version = ">= 2.5.2"
36
36
 
37
- s.files = Dir.glob("{lib,exe}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
37
+ s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
38
38
 
39
- # Include the CHANGELOG.md, LICENSE.md, README.md manually
40
- s.files += %w[CHANGELOG.md LICENSE.md README.md]
41
39
  # include the gemspec itself because warbler breaks w/o it
42
40
  s.files += %w[bundler.gemspec]
43
41
 
42
+ s.files += %w[CHANGELOG.md LICENSE.md README.md]
44
43
  s.bindir = "exe"
45
44
  s.executables = %w[bundle bundler]
46
45
  s.require_paths = ["lib"]
data/lib/bundler.rb CHANGED
@@ -69,6 +69,7 @@ module Bundler
69
69
  autoload :SharedHelpers, File.expand_path("bundler/shared_helpers", __dir__)
70
70
  autoload :Source, File.expand_path("bundler/source", __dir__)
71
71
  autoload :SourceList, File.expand_path("bundler/source_list", __dir__)
72
+ autoload :SourceMap, File.expand_path("bundler/source_map", __dir__)
72
73
  autoload :SpecSet, File.expand_path("bundler/spec_set", __dir__)
73
74
  autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
74
75
  autoload :UI, File.expand_path("bundler/ui", __dir__)
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2021-03-19".freeze
8
- @git_commit_sha = "3dbcc68293".freeze
7
+ @built_at = "2021-06-11".freeze
8
+ @git_commit_sha = "4c510a34a4".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
data/lib/bundler/cli.rb CHANGED
@@ -308,39 +308,19 @@ module Bundler
308
308
  end
309
309
  end
310
310
 
311
- unless Bundler.feature_flag.bundler_3_mode?
312
- desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
313
- long_desc <<-D
314
- Show lists the names and versions of all gems that are required by your Gemfile.
315
- Calling show with [GEM] will list the exact location of that gem on your machine.
316
- D
317
- method_option "paths", :type => :boolean,
318
- :banner => "List the paths of all gems that are required by your Gemfile."
319
- method_option "outdated", :type => :boolean,
320
- :banner => "Show verbose output including whether gems are outdated."
321
- def show(gem_name = nil)
322
- if ARGV[0] == "show"
323
- rest = ARGV[1..-1]
324
-
325
- if flag = rest.find{|arg| ["--verbose", "--outdated"].include?(arg) }
326
- Bundler::SharedHelpers.major_deprecation(2, "the `#{flag}` flag to `bundle show` was undocumented and will be removed without replacement")
327
- else
328
- new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list"
329
-
330
- new_arguments = rest.map do |arg|
331
- next arg if arg != "--paths"
332
- next "--path" if new_command == "info"
333
- end
334
-
335
- old_argv = ARGV.join(" ")
336
- new_argv = [new_command, *new_arguments.compact].join(" ")
337
-
338
- Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
339
- end
340
- end
341
- require_relative "cli/show"
342
- Show.new(options, gem_name).run
343
- end
311
+ desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
312
+ long_desc <<-D
313
+ Show lists the names and versions of all gems that are required by your Gemfile.
314
+ Calling show with [GEM] will list the exact location of that gem on your machine.
315
+ D
316
+ method_option "paths", :type => :boolean,
317
+ :banner => "List the paths of all gems that are required by your Gemfile."
318
+ method_option "outdated", :type => :boolean,
319
+ :banner => "Show verbose output including whether gems are outdated."
320
+ def show(gem_name = nil)
321
+ SharedHelpers.major_deprecation(2, "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") if ARGV.include?("--outdated")
322
+ require_relative "cli/show"
323
+ Show.new(options, gem_name).run
344
324
  end
345
325
 
346
326
  desc "list", "List all gems in the bundle"
@@ -504,8 +484,8 @@ module Bundler
504
484
  By default, setting a configuration value sets it for all projects
505
485
  on the machine.
506
486
 
507
- If a global setting is superceded by local configuration, this command
508
- will show the current value, as well as any superceded values and
487
+ If a global setting is superseded by local configuration, this command
488
+ will show the current value, as well as any superseded values and
509
489
  where they were specified.
510
490
  D
511
491
  require_relative "cli/config"
@@ -591,6 +571,7 @@ module Bundler
591
571
  :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)`."
592
572
  method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
593
573
  :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)`"
574
+ 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>`."
594
575
 
595
576
  def gem(name)
596
577
  end
@@ -11,9 +11,11 @@ module Bundler
11
11
  def run
12
12
  Bundler.settings.set_command_option_if_given :path, options[:path]
13
13
 
14
+ definition = Bundler.definition
15
+ definition.validate_runtime!
16
+
14
17
  begin
15
- definition = Bundler.definition
16
- definition.validate_runtime!
18
+ definition.resolve_only_locally!
17
19
  not_installed = definition.missing_specs
18
20
  rescue GemNotFound, VersionConflict
19
21
  Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
@@ -36,10 +36,15 @@ module Bundler
36
36
  def self.without_groups_message(command)
37
37
  command_in_past_tense = command == :install ? "installed" : "updated"
38
38
  groups = Bundler.settings[:without]
39
+ "Gems in the #{verbalize_groups(groups)} were not #{command_in_past_tense}."
40
+ end
41
+
42
+ def self.verbalize_groups(groups)
43
+ groups.map!{|g| "'#{g}'" }
39
44
  group_list = [groups[0...-1].join(", "), groups[-1..-1]].
40
45
  reject {|s| s.to_s.empty? }.join(" and ")
41
46
  group_str = groups.size == 1 ? "group" : "groups"
42
- "Gems in the #{group_str} #{group_list} were not #{command_in_past_tense}."
47
+ "#{group_str} #{group_list}"
43
48
  end
44
49
 
45
50
  def self.select_spec(name, regex_match = nil)
@@ -53,7 +58,13 @@ module Bundler
53
58
 
54
59
  case specs.count
55
60
  when 0
56
- raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
61
+ dep_in_other_group = Bundler.definition.current_dependencies.find {|dep|dep.name == name }
62
+
63
+ if dep_in_other_group
64
+ raise GemNotFound, "Could not find gem '#{name}', because it's in the #{verbalize_groups(dep_in_other_group.groups)}, configured to be ignored."
65
+ else
66
+ raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
67
+ end
57
68
  when 1
58
69
  specs.first
59
70
  else
@@ -83,6 +94,8 @@ module Bundler
83
94
  end
84
95
 
85
96
  def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
97
+ return unless locked_gems
98
+
86
99
  locked_names = locked_gems.specs.map(&:name).uniq
87
100
  names.-(locked_names).each do |g|
88
101
  raise GemNotFound, gem_not_found_message(g, locked_names)
@@ -42,9 +42,17 @@ module Bundler
42
42
  use_git = Bundler.git_present? && options[:git]
43
43
 
44
44
  git_author_name = use_git ? `git config user.name`.chomp : ""
45
- github_username = use_git ? `git config github.user`.chomp : ""
45
+ git_username = use_git ? `git config github.user`.chomp : ""
46
46
  git_user_email = use_git ? `git config user.email`.chomp : ""
47
47
 
48
+ github_username = if options[:github_username].nil?
49
+ git_username
50
+ elsif options[:github_username] == false
51
+ ""
52
+ else
53
+ options[:github_username]
54
+ end
55
+
48
56
  config = {
49
57
  :name => name,
50
58
  :underscored_name => underscored_name,
@@ -72,7 +72,7 @@ module Bundler
72
72
  gemfile_specs + dependency_specs
73
73
  end
74
74
 
75
- specs.sort_by(&:name).each do |current_spec|
75
+ specs.sort_by(&:name).uniq(&:name).each do |current_spec|
76
76
  next unless gems.empty? || gems.include?(current_spec.name)
77
77
 
78
78
  active_spec = retrieve_active_spec(definition, current_spec)
@@ -146,17 +146,16 @@ module Bundler
146
146
  end
147
147
 
148
148
  def retrieve_active_spec(definition, current_spec)
149
- if strict
150
- active_spec = definition.find_resolved_spec(current_spec)
151
- else
152
- active_specs = definition.find_indexed_specs(current_spec)
153
- if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
154
- active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
155
- end
156
- active_spec = active_specs.last
157
- end
149
+ active_spec = definition.resolve.find_by_name_and_platform(current_spec.name, current_spec.platform)
150
+ return unless active_spec
158
151
 
159
- active_spec
152
+ return active_spec if strict
153
+
154
+ active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
155
+ if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
156
+ active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
157
+ end
158
+ active_specs.last
160
159
  end
161
160
 
162
161
  def print_gems(gems_list)
@@ -50,16 +50,20 @@ module Bundler
50
50
 
51
51
  content = response.body
52
52
 
53
- SharedHelpers.filesystem_access(local_temp_path) do
53
+ etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
54
+ correct_response = SharedHelpers.filesystem_access(local_temp_path) do
54
55
  if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
55
56
  local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
57
+
58
+ etag_for(local_temp_path) == etag
56
59
  else
57
60
  local_temp_path.open("wb") {|f| f << content }
61
+
62
+ etag.length.zero? || etag_for(local_temp_path) == etag
58
63
  end
59
64
  end
60
65
 
61
- etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
62
- if etag.length.zero? || etag_for(local_temp_path) == etag
66
+ if correct_response
63
67
  SharedHelpers.filesystem_access(local_path) do
64
68
  FileUtils.mv(local_temp_path, local_path)
65
69
  end
@@ -92,11 +96,11 @@ module Bundler
92
96
 
93
97
  def checksum_for_file(path)
94
98
  return nil unless path.file?
95
- # This must use IO.read instead of Digest.file().hexdigest
99
+ # This must use File.read instead of Digest.file().hexdigest
96
100
  # because we need to preserve \n line endings on windows when calculating
97
101
  # the checksum
98
102
  SharedHelpers.filesystem_access(path, :read) do
99
- SharedHelpers.digest(:MD5).hexdigest(IO.read(path))
103
+ SharedHelpers.digest(:MD5).hexdigest(File.read(path))
100
104
  end
101
105
  end
102
106
  end
@@ -20,6 +20,7 @@ module Bundler
20
20
  2.5
21
21
  2.6
22
22
  2.7
23
+ 3.0
23
24
  ].freeze
24
25
 
25
26
  KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
@@ -160,17 +160,21 @@ module Bundler
160
160
  @disable_multisource
161
161
  end
162
162
 
163
+ def resolve_only_locally!
164
+ @remote = false
165
+ sources.local_only!
166
+ resolve
167
+ end
168
+
163
169
  def resolve_with_cache!
164
- raise "Specs already loaded" if @specs
165
170
  sources.cached!
166
- specs
171
+ resolve
167
172
  end
168
173
 
169
174
  def resolve_remotely!
170
- return if @specs
171
175
  @remote = true
172
176
  sources.remote!
173
- specs
177
+ resolve
174
178
  end
175
179
 
176
180
  # For given dependency list returns a SpecSet with Gemspec of all the required
@@ -187,10 +191,10 @@ module Bundler
187
191
  gem_name, gem_version = extract_gem_info(e)
188
192
  locked_gem = @locked_specs[gem_name].last
189
193
  raise if locked_gem.nil? || locked_gem.version.to_s != gem_version || !@remote
190
- raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
191
- "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
192
- "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
193
- "to a version other than #{locked_gem} that hasn't been removed in order to install."
194
+ raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
195
+ "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
196
+ "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
197
+ "removed in order to install."
194
198
  end
195
199
  unless specs["bundler"].any?
196
200
  bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
@@ -221,7 +225,6 @@ module Bundler
221
225
  Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
222
226
  true
223
227
  rescue BundlerError => e
224
- @index = nil
225
228
  @resolve = nil
226
229
  @specs = nil
227
230
  @gem_version_promoter = nil
@@ -284,50 +287,6 @@ module Bundler
284
287
  end
285
288
  end
286
289
 
287
- def index
288
- @index ||= Index.build do |idx|
289
- dependency_names = @dependencies.map(&:name)
290
-
291
- sources.all_sources.each do |source|
292
- source.dependency_names = dependency_names - pinned_spec_names(source)
293
- idx.add_source source.specs
294
- dependency_names.concat(source.unmet_deps).uniq!
295
- end
296
-
297
- double_check_for_index(idx, dependency_names)
298
- end
299
- end
300
-
301
- # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
302
- # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
303
- # but will not have found any versions of Bar from source B, which is a problem if the requested version
304
- # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
305
- # each spec we found, we add all possible versions from all sources to the index.
306
- def double_check_for_index(idx, dependency_names)
307
- pinned_names = pinned_spec_names
308
- loop do
309
- idxcount = idx.size
310
-
311
- names = :names # do this so we only have to traverse to get dependency_names from the index once
312
- unmet_dependency_names = lambda do
313
- return names unless names == :names
314
- new_names = sources.all_sources.map(&:dependency_names_to_double_check)
315
- return names = nil if new_names.compact!
316
- names = new_names.flatten(1).concat(dependency_names)
317
- names.uniq!
318
- names -= pinned_names
319
- names
320
- end
321
-
322
- sources.all_sources.each do |source|
323
- source.double_check_for(unmet_dependency_names)
324
- end
325
-
326
- break if idxcount == idx.size
327
- end
328
- end
329
- private :double_check_for_index
330
-
331
290
  def has_rubygems_remotes?
332
291
  sources.rubygems_sources.any? {|s| s.remotes.any? }
333
292
  end
@@ -534,14 +493,6 @@ module Bundler
534
493
  end
535
494
  end
536
495
 
537
- def find_resolved_spec(current_spec)
538
- specs.find_by_name_and_platform(current_spec.name, current_spec.platform)
539
- end
540
-
541
- def find_indexed_specs(current_spec)
542
- index[current_spec.name].select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
543
- end
544
-
545
496
  attr_reader :sources
546
497
  private :sources
547
498
 
@@ -558,6 +509,10 @@ module Bundler
558
509
 
559
510
  private
560
511
 
512
+ def precompute_source_requirements_for_indirect_dependencies?
513
+ sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && sources.no_aggregate_global_source?
514
+ end
515
+
561
516
  def current_ruby_platform_locked?
562
517
  return false unless generic_local_platform == Gem::Platform::RUBY
563
518
 
@@ -683,9 +638,9 @@ module Bundler
683
638
  changes = false
684
639
 
685
640
  # If there is a RubyGems source in both
686
- locked_gem_sources.each do |locked_gem|
641
+ locked_gem_sources.each do |locked_gem_source|
687
642
  # Merge the remotes from the Gemfile into the Gemfile.lock
688
- changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
643
+ changes |= locked_gem_source.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
689
644
  end
690
645
 
691
646
  changes
@@ -904,26 +859,22 @@ module Bundler
904
859
  end
905
860
 
906
861
  def source_requirements
907
- # Load all specs from remote sources
908
- index
909
-
910
862
  # Record the specs available in each gem's source, so that those
911
863
  # specs will be available later when the resolver knows where to
912
864
  # look for that gemspec (or its dependencies)
913
- source_requirements = { :default => sources.default_source }.merge(dependency_source_requirements)
865
+ source_requirements = if precompute_source_requirements_for_indirect_dependencies?
866
+ { :default => sources.default_source }.merge(source_map.all_requirements)
867
+ else
868
+ { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
869
+ end
914
870
  metadata_dependencies.each do |dep|
915
871
  source_requirements[dep.name] = sources.metadata_source
916
872
  end
917
- source_requirements[:global] = index unless Bundler.feature_flag.disable_multisource?
918
- source_requirements[:default_bundler] = source_requirements["bundler"] || source_requirements[:default]
873
+ source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
919
874
  source_requirements["bundler"] = sources.metadata_source # needs to come last to override
920
875
  source_requirements
921
876
  end
922
877
 
923
- def pinned_spec_names(skip = nil)
924
- dependency_source_requirements.reject {|_, source| source == skip }.keys
925
- end
926
-
927
878
  def requested_groups
928
879
  groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
929
880
  end
@@ -959,7 +910,7 @@ module Bundler
959
910
  end
960
911
 
961
912
  def additional_base_requirements_for_resolve
962
- return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
913
+ return [] unless @locked_gems
963
914
  dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
964
915
  @locked_gems.specs.reduce({}) do |requirements, locked_spec|
965
916
  name = locked_spec.name
@@ -979,16 +930,8 @@ module Bundler
979
930
  Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
980
931
  end
981
932
 
982
- def dependency_source_requirements
983
- @dependency_source_requirements ||= begin
984
- source_requirements = {}
985
- default = sources.default_source
986
- dependencies.each do |dep|
987
- dep_source = dep.source || default
988
- source_requirements[dep.name] = dep_source
989
- end
990
- source_requirements
991
- end
933
+ def source_map
934
+ @source_map ||= SourceMap.new(sources, dependencies)
992
935
  end
993
936
  end
994
937
  end