bundler 2.2.16 → 2.2.21

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +84 -6
  3. data/bundler.gemspec +2 -3
  4. data/lib/bundler.rb +2 -1
  5. data/lib/bundler/build_metadata.rb +2 -2
  6. data/lib/bundler/cli.rb +15 -35
  7. data/lib/bundler/cli/check.rb +4 -2
  8. data/lib/bundler/cli/common.rb +2 -0
  9. data/lib/bundler/cli/install.rb +6 -7
  10. data/lib/bundler/cli/outdated.rb +9 -10
  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 +31 -86
  14. data/lib/bundler/feature_flag.rb +0 -2
  15. data/lib/bundler/fetcher.rb +2 -1
  16. data/lib/bundler/fetcher/compact_index.rb +1 -1
  17. data/lib/bundler/fetcher/downloader.rb +8 -4
  18. data/lib/bundler/fetcher/index.rb +0 -1
  19. data/lib/bundler/friendly_errors.rb +2 -4
  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/installer.rb +1 -8
  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 +19 -8
  30. data/lib/bundler/man/bundle-config.1.ronn +18 -9
  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 +15 -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 +81 -12
  58. data/lib/bundler/source.rb +11 -0
  59. data/lib/bundler/source/rubygems.rb +26 -13
  60. data/lib/bundler/source/rubygems_aggregate.rb +64 -0
  61. data/lib/bundler/source_list.rb +35 -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/newgem.gemspec.tt +2 -2
  67. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  68. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +1 -1
  69. data/lib/bundler/version.rb +1 -1
  70. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34a58092b9b549641b8863aab3b4099e3d42261df0742be146b3dba6743f4039
4
- data.tar.gz: 7a478c44e3593798f018b8c1c654886935d028b26ce3deeafb23bb9c7b1bc85a
3
+ metadata.gz: 420be71d17b8361ff58b192c7d65aff87352858d123b6c30cbbc19eb582503b1
4
+ data.tar.gz: 8d1b50e3080888aee87a46a11511f144fc27c9767eae003e0b09fe6a5b5def50
5
5
  SHA512:
6
- metadata.gz: 2155925a4f2685e82fcb06f57ff8c2f2269cdfff211848e833e14b59e1b8377eb08c02dc4f2ebdd19be560d8080fd917e4e85e91d973453cb157ec215727eb51
7
- data.tar.gz: 809c8f54934d4fdc0dca809e22112befb3112f791fe87f2c9ee2adbd18d8119511fcabb5f893f6a40b82961075fc460d9be37df0b5e7a499248e03f9c91718c0
6
+ metadata.gz: a97c3dbb69d51982f210c6c78ea5a987bf4fa6439a2925769794c2fad30f42c35efc57d2f2713f37be84ee08050526513bc12a9fddd09763fb7f9748e7e4673b
7
+ data.tar.gz: 1faa09cb9aa4bcf42d15820bde1c0558e6b50709b7671750758f219d56058d02a57bb22f891b7d233941194ec2519d3c3dca193e5e07d1a9be8b22a4ae1a8d5f
data/CHANGELOG.md CHANGED
@@ -1,10 +1,88 @@
1
+ # 2.2.21 (June 23, 2021)
2
+
3
+ ## Security fixes:
4
+
5
+ - Auto-update insecure lockfile to split GEM source sections whenever possible [#4647](https://github.com/rubygems/rubygems/pull/4647)
6
+
7
+ ## Enhancements:
8
+
9
+ - Use a more limited number of threads when fetching in parallel from the Compact Index API [#4670](https://github.com/rubygems/rubygems/pull/4670)
10
+ - Update TODO link in bundle gem template to https [#4671](https://github.com/rubygems/rubygems/pull/4671)
11
+
12
+ ## Bug fixes:
13
+
14
+ - Fix `bundle install --local` hitting the network when `cache_all_platforms` configured [#4677](https://github.com/rubygems/rubygems/pull/4677)
15
+
16
+ # 2.2.20 (June 11, 2021)
17
+
18
+ ## Enhancements:
19
+
20
+ - Don't print bug report template on server side errors [#4663](https://github.com/rubygems/rubygems/pull/4663)
21
+ - Don't load `resolv` unnecessarily [#4640](https://github.com/rubygems/rubygems/pull/4640)
22
+
23
+ ## Bug fixes:
24
+
25
+ - Fix `bundle outdated` edge case [#4648](https://github.com/rubygems/rubygems/pull/4648)
26
+ - Fix `bundle check` with scoped rubygems sources [#4639](https://github.com/rubygems/rubygems/pull/4639)
27
+
28
+ ## Performance:
29
+
30
+ - 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)
31
+
32
+ # 2.2.19 (May 31, 2021)
33
+
34
+ ## Bug fixes:
35
+
36
+ - Restore support for configuration keys with dashes [#4582](https://github.com/rubygems/rubygems/pull/4582)
37
+ - Fix some cached gems being unintentionally ignored when using rubygems 3.2.18 [#4623](https://github.com/rubygems/rubygems/pull/4623)
38
+
39
+ # 2.2.18 (May 25, 2021)
40
+
41
+ ## Security fixes:
42
+
43
+ - Fix dependency confusion issues with implicit dependencies [#4609](https://github.com/rubygems/rubygems/pull/4609)
44
+
45
+ ## Enhancements:
46
+
47
+ - Use simpler notation for generated `required_ruby_version` [#4598](https://github.com/rubygems/rubygems/pull/4598)
48
+ - Undeprecate bundle show [#4586](https://github.com/rubygems/rubygems/pull/4586)
49
+ - Make sure link to new issue uses the proper template [#4592](https://github.com/rubygems/rubygems/pull/4592)
50
+
51
+ ## Bug fixes:
52
+
53
+ - Fix platform specific gems being removed from the lockfile [#4580](https://github.com/rubygems/rubygems/pull/4580)
54
+
55
+ # 2.2.17 (May 5, 2021)
56
+
57
+ ## Enhancements:
58
+
59
+ - Improve authentication required error message to include an alternative using `ENV` [#4565](https://github.com/rubygems/rubygems/pull/4565)
60
+ - Discard partial range responses without etag [#4563](https://github.com/rubygems/rubygems/pull/4563)
61
+ - Fix configuring ENV for a gem server with a name including dashes [#4571](https://github.com/rubygems/rubygems/pull/4571)
62
+ - Redact credentials from `bundle env` and `bundle config` [#4566](https://github.com/rubygems/rubygems/pull/4566)
63
+ - Redact all sources in verbose mode [#4564](https://github.com/rubygems/rubygems/pull/4564)
64
+ - Improve `bundle pristine` error if `BUNDLE_GEMFILE` does not exist [#4536](https://github.com/rubygems/rubygems/pull/4536)
65
+ - [CurrentRuby] Add 3.0 as a known minor [#4535](https://github.com/rubygems/rubygems/pull/4535)
66
+ - Prefer File.read instead of IO.read [#4530](https://github.com/rubygems/rubygems/pull/4530)
67
+ - Add space after open curly bracket in Gemfile and gems.rb template [#4518](https://github.com/rubygems/rubygems/pull/4518)
68
+
69
+ ## Bug fixes:
70
+
71
+ - Make sure specs are fetched from the right source when materializing [#4562](https://github.com/rubygems/rubygems/pull/4562)
72
+ - Fix `bundle cache` with an up-to-date lockfile and specs not already installed [#4554](https://github.com/rubygems/rubygems/pull/4554)
73
+ - Ignore `deployment` setting in inline mode [#4523](https://github.com/rubygems/rubygems/pull/4523)
74
+
75
+ ## Performance:
76
+
77
+ - Don't materialize resolutions when not necessary [#4556](https://github.com/rubygems/rubygems/pull/4556)
78
+
1
79
  # 2.2.16 (April 8, 2021)
2
80
 
3
81
  ## Enhancements:
4
82
 
5
83
  - Add `--github-username` option and config to `bundle gem` [#3687](https://github.com/rubygems/rubygems/pull/3687)
6
84
  - Bump vendored `tmpdir` library copy [#4506](https://github.com/rubygems/rubygems/pull/4506)
7
- - Add `rake build:checksum` task to build cheksums for a gem package [#4156](https://github.com/rubygems/rubygems/pull/4156)
85
+ - Add `rake build:checksum` task to build checksums for a gem package [#4156](https://github.com/rubygems/rubygems/pull/4156)
8
86
  - Enable bundler-cache for GitHub Actions template [#4498](https://github.com/rubygems/rubygems/pull/4498)
9
87
  - Improve `bundle info` error when gem is on a "disabled" group [#4492](https://github.com/rubygems/rubygems/pull/4492)
10
88
  - Small tweak to yank message [#4494](https://github.com/rubygems/rubygems/pull/4494)
@@ -472,7 +550,7 @@
472
550
  - Ignore `frozen` setting in inline mode ([#7125](https://github.com/rubygems/bundler/pull/7125))
473
551
  - 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))
474
552
  - Don't check for existence of a writable home directory if `BUNDLE_USER_HOME` is set ([#6885](https://github.com/rubygems/bundler/pull/6885))
475
- - Fix error message when server would respond to a bad username/password requiest with a 401 ([#6928](https://github.com/rubygems/bundler/pull/6928))
553
+ - Fix error message when server would respond to a bad username/password request with a 401 ([#6928](https://github.com/rubygems/bundler/pull/6928))
476
554
  - Fix `bundle outdated` pluralization when multiple groups are requested ([#7063](https://github.com/rubygems/bundler/pull/7063))
477
555
  - Fix `bundle install` not updating conservatively when gemspec is changed ([#7143](https://github.com/rubygems/bundler/pull/7143))
478
556
  - Fix `bundle exec` not respecting custom process titles inside scripts ([#7140](https://github.com/rubygems/bundler/pull/7140))
@@ -2117,7 +2195,7 @@ Changes
2117
2195
  - fix Bundler.which for directories ([#2697](https://github.com/rubygems/bundler/issues/2697), @rhysd)
2118
2196
  - properly require `Capistrano::Version` ([#2690](https://github.com/rubygems/bundler/issues/2690), @steveklabnik)
2119
2197
  - search for git.exe and git
2120
- - fix the bug that downloads every spec when API fetcher encouters an error
2198
+ - fix the bug that downloads every spec when API fetcher encounters an error
2121
2199
  - only retry network requests
2122
2200
 
2123
2201
  # 1.4.0.rc.1 (September 29, 2013)
@@ -2741,7 +2819,7 @@ Changes
2741
2819
 
2742
2820
  - Implement `to_ary` to avoid calls to method_missing (@tenderlove, [#1274](https://github.com/rubygems/bundler/issues/1274))
2743
2821
  - bundle clean removes old .gem files (@cldwalker, [#1293](https://github.com/rubygems/bundler/issues/1293))
2744
- - Correcly identify missing child dependency in error message
2822
+ - Correctly identify missing child dependency in error message
2745
2823
  - Run pre-install, post-build, and post-install gem hooks for git gems (@warhammerkid, [#1120](https://github.com/rubygems/bundler/issues/1120))
2746
2824
  - create Gemfile.lock for empty Gemfile ([#1218](https://github.com/rubygems/bundler/issues/1218))
2747
2825
 
@@ -2892,7 +2970,7 @@ Changes
2892
2970
 
2893
2971
  - Performance fix for MRI 1.9 (@efficientcloud, [#1288](https://github.com/rubygems/bundler/issues/1288))
2894
2972
  - Shortcuts (like `bundle i`) for all commands (@amatsuda)
2895
- - Correcly identify missing child dependency in error message
2973
+ - Correctly identify missing child dependency in error message
2896
2974
 
2897
2975
  ## Bug fixes:
2898
2976
 
@@ -3128,7 +3206,7 @@ Changes
3128
3206
 
3129
3207
  - Various bugfixes to the built-in rake helpers
3130
3208
  - Fix a bug where shortrefs weren't unique enough and were
3131
- therfore colliding
3209
+ therefore colliding
3132
3210
  - Fix a small bug involving checking whether a local git
3133
3211
  clone is up to date
3134
3212
  - 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__)
@@ -197,7 +198,7 @@ module Bundler
197
198
 
198
199
  def frozen_bundle?
199
200
  frozen = settings[:deployment]
200
- frozen ||= settings[:frozen] unless feature_flag.deployment_means_frozen?
201
+ frozen ||= settings[:frozen]
201
202
  frozen
202
203
  end
203
204
 
@@ -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-04-09".freeze
8
- @git_commit_sha = "3d7bfaff25".freeze
7
+ @built_at = "2021-06-23".freeze
8
+ @git_commit_sha = "0b5db72094".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"
@@ -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."
@@ -94,6 +94,8 @@ module Bundler
94
94
  end
95
95
 
96
96
  def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
97
+ return unless locked_gems
98
+
97
99
  locked_names = locked_gems.specs.map(&:name).uniq
98
100
  names.-(locked_names).each do |g|
99
101
  raise GemNotFound, gem_not_found_message(g, locked_names)
@@ -33,12 +33,8 @@ module Bundler
33
33
 
34
34
  options[:local] = true if Bundler.app_cache.exist?
35
35
 
36
- if Bundler.feature_flag.deployment_means_frozen?
37
- Bundler.settings.set_command_option :deployment, true
38
- else
39
- Bundler.settings.set_command_option :deployment, true if options[:deployment]
40
- Bundler.settings.set_command_option :frozen, true if options[:frozen]
41
- end
36
+ Bundler.settings.set_command_option :deployment, true if options[:deployment]
37
+ Bundler.settings.set_command_option :frozen, true if options[:frozen]
42
38
  end
43
39
 
44
40
  # When install is called with --no-deployment, disable deployment mode
@@ -62,7 +58,10 @@ module Bundler
62
58
  definition.validate_runtime!
63
59
 
64
60
  installer = Installer.install(Bundler.root, definition, options)
65
- Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
61
+
62
+ Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
63
+ Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
64
+ end
66
65
 
67
66
  Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
68
67
  Bundler::CLI::Common.output_without_groups_message(:install)
@@ -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
@@ -107,12 +107,14 @@ module Bundler
107
107
  end
108
108
 
109
109
  @locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
110
- @disable_multisource = @locked_gem_sources.all?(&:disable_multisource?)
110
+ @multisource_allowed = @locked_gem_sources.any?(&:multiple_remotes?) && (sources.aggregate_global_source? || Bundler.frozen_bundle?)
111
111
 
112
- unless @disable_multisource
113
- msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. You should run `bundle update` or generate your lockfile from scratch."
112
+ if @multisource_allowed
113
+ unless sources.aggregate_global_source?
114
+ msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure."
114
115
 
115
- Bundler::SharedHelpers.major_deprecation 2, msg
116
+ Bundler::SharedHelpers.major_deprecation 2, msg
117
+ end
116
118
 
117
119
  @sources.merged_gem_lockfile_sections!
118
120
  end
@@ -156,21 +158,25 @@ module Bundler
156
158
  end
157
159
  end
158
160
 
159
- def disable_multisource?
160
- @disable_multisource
161
+ def multisource_allowed?
162
+ @multisource_allowed
163
+ end
164
+
165
+ def resolve_only_locally!
166
+ @remote = false
167
+ sources.local_only!
168
+ resolve
161
169
  end
162
170
 
163
171
  def resolve_with_cache!
164
- raise "Specs already loaded" if @specs
165
172
  sources.cached!
166
- specs
173
+ resolve
167
174
  end
168
175
 
169
176
  def resolve_remotely!
170
- return if @specs
171
177
  @remote = true
172
178
  sources.remote!
173
- specs
179
+ resolve
174
180
  end
175
181
 
176
182
  # For given dependency list returns a SpecSet with Gemspec of all the required
@@ -221,7 +227,6 @@ module Bundler
221
227
  Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
222
228
  true
223
229
  rescue BundlerError => e
224
- @index = nil
225
230
  @resolve = nil
226
231
  @specs = nil
227
232
  @gem_version_promoter = nil
@@ -284,50 +289,6 @@ module Bundler
284
289
  end
285
290
  end
286
291
 
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
292
  def has_rubygems_remotes?
332
293
  sources.rubygems_sources.any? {|s| s.remotes.any? }
333
294
  end
@@ -534,14 +495,6 @@ module Bundler
534
495
  end
535
496
  end
536
497
 
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
498
  attr_reader :sources
546
499
  private :sources
547
500
 
@@ -558,6 +511,10 @@ module Bundler
558
511
 
559
512
  private
560
513
 
514
+ def precompute_source_requirements_for_indirect_dependencies?
515
+ sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
516
+ end
517
+
561
518
  def current_ruby_platform_locked?
562
519
  return false unless generic_local_platform == Gem::Platform::RUBY
563
520
 
@@ -672,7 +629,7 @@ module Bundler
672
629
  end
673
630
 
674
631
  def converge_rubygems_sources
675
- return false if disable_multisource?
632
+ return false unless multisource_allowed?
676
633
 
677
634
  return false if locked_gem_sources.empty?
678
635
 
@@ -683,9 +640,9 @@ module Bundler
683
640
  changes = false
684
641
 
685
642
  # If there is a RubyGems source in both
686
- locked_gem_sources.each do |locked_gem|
643
+ locked_gem_sources.each do |locked_gem_source|
687
644
  # 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])
645
+ changes |= locked_gem_source.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
689
646
  end
690
647
 
691
648
  changes
@@ -904,26 +861,22 @@ module Bundler
904
861
  end
905
862
 
906
863
  def source_requirements
907
- # Load all specs from remote sources
908
- index
909
-
910
864
  # Record the specs available in each gem's source, so that those
911
865
  # specs will be available later when the resolver knows where to
912
866
  # look for that gemspec (or its dependencies)
913
- source_requirements = { :default => sources.default_source }.merge(dependency_source_requirements)
867
+ source_requirements = if precompute_source_requirements_for_indirect_dependencies?
868
+ { :default => sources.default_source }.merge(source_map.all_requirements)
869
+ else
870
+ { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
871
+ end
914
872
  metadata_dependencies.each do |dep|
915
873
  source_requirements[dep.name] = sources.metadata_source
916
874
  end
917
- source_requirements[:global] = index unless Bundler.feature_flag.disable_multisource?
918
- source_requirements[:default_bundler] = source_requirements["bundler"] || source_requirements[:default]
875
+ source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
919
876
  source_requirements["bundler"] = sources.metadata_source # needs to come last to override
920
877
  source_requirements
921
878
  end
922
879
 
923
- def pinned_spec_names(skip = nil)
924
- dependency_source_requirements.reject {|_, source| source == skip }.keys
925
- end
926
-
927
880
  def requested_groups
928
881
  groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
929
882
  end
@@ -979,16 +932,8 @@ module Bundler
979
932
  Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
980
933
  end
981
934
 
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
935
+ def source_map
936
+ @source_map ||= SourceMap.new(sources, dependencies)
992
937
  end
993
938
  end
994
939
  end