bundler 2.3.19 → 2.3.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/bundler.gemspec +6 -8
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli/install.rb +5 -2
  6. data/lib/bundler/cli/outdated.rb +12 -3
  7. data/lib/bundler/cli/platform.rb +1 -1
  8. data/lib/bundler/cli.rb +7 -4
  9. data/lib/bundler/current_ruby.rb +14 -5
  10. data/lib/bundler/definition.rb +85 -33
  11. data/lib/bundler/dependency.rb +18 -85
  12. data/lib/bundler/endpoint_specification.rb +2 -13
  13. data/lib/bundler/feature_flag.rb +0 -1
  14. data/lib/bundler/fetcher.rb +6 -6
  15. data/lib/bundler/gem_helpers.rb +7 -1
  16. data/lib/bundler/gem_version_promoter.rb +8 -18
  17. data/lib/bundler/injector.rb +2 -1
  18. data/lib/bundler/inline.rb +1 -1
  19. data/lib/bundler/installer/standalone.rb +1 -1
  20. data/lib/bundler/installer.rb +14 -12
  21. data/lib/bundler/lazy_specification.rb +23 -25
  22. data/lib/bundler/lockfile_generator.rb +1 -1
  23. data/lib/bundler/man/bundle-add.1 +6 -2
  24. data/lib/bundler/man/bundle-add.1.ronn +4 -1
  25. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  26. data/lib/bundler/man/bundle-cache.1 +7 -1
  27. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  28. data/lib/bundler/man/bundle-check.1 +1 -1
  29. data/lib/bundler/man/bundle-clean.1 +1 -1
  30. data/lib/bundler/man/bundle-config.1 +13 -4
  31. data/lib/bundler/man/bundle-config.1.ronn +7 -4
  32. data/lib/bundler/man/bundle-console.1 +53 -0
  33. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  34. data/lib/bundler/man/bundle-doctor.1 +1 -1
  35. data/lib/bundler/man/bundle-exec.1 +1 -1
  36. data/lib/bundler/man/bundle-gem.1 +1 -1
  37. data/lib/bundler/man/bundle-help.1 +13 -0
  38. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  39. data/lib/bundler/man/bundle-info.1 +1 -1
  40. data/lib/bundler/man/bundle-init.1 +1 -1
  41. data/lib/bundler/man/bundle-inject.1 +1 -1
  42. data/lib/bundler/man/bundle-install.1 +5 -1
  43. data/lib/bundler/man/bundle-install.1.ronn +6 -0
  44. data/lib/bundler/man/bundle-list.1 +1 -1
  45. data/lib/bundler/man/bundle-lock.1 +1 -1
  46. data/lib/bundler/man/bundle-open.1 +1 -1
  47. data/lib/bundler/man/bundle-outdated.1 +1 -1
  48. data/lib/bundler/man/bundle-platform.1 +16 -6
  49. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  50. data/lib/bundler/man/bundle-plugin.1 +81 -0
  51. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  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-version.1 +35 -0
  57. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  58. data/lib/bundler/man/bundle-viz.1 +1 -1
  59. data/lib/bundler/man/bundle.1 +13 -8
  60. data/lib/bundler/man/bundle.1.ronn +10 -5
  61. data/lib/bundler/man/gemfile.5 +8 -38
  62. data/lib/bundler/man/gemfile.5.ronn +9 -27
  63. data/lib/bundler/man/index.txt +4 -0
  64. data/lib/bundler/match_metadata.rb +13 -0
  65. data/lib/bundler/match_remote_metadata.rb +29 -0
  66. data/lib/bundler/plugin.rb +2 -0
  67. data/lib/bundler/remote_specification.rb +1 -7
  68. data/lib/bundler/resolver/base.rb +50 -0
  69. data/lib/bundler/resolver/spec_group.rb +11 -8
  70. data/lib/bundler/resolver.rb +94 -88
  71. data/lib/bundler/ruby_dsl.rb +1 -1
  72. data/lib/bundler/ruby_version.rb +5 -5
  73. data/lib/bundler/rubygems_ext.rb +52 -1
  74. data/lib/bundler/settings.rb +0 -1
  75. data/lib/bundler/source/metadata.rb +1 -1
  76. data/lib/bundler/source_list.rb +4 -0
  77. data/lib/bundler/spec_set.rb +41 -34
  78. data/lib/bundler/version.rb +1 -1
  79. data/lib/bundler.rb +3 -4
  80. metadata +15 -5
  81. data/lib/bundler/incomplete_specification.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a381dcda0446bc5d93d2a6c1b16dcb28c53b151df2a3e9a9ed656f9e35bea2e
4
- data.tar.gz: dd05bd4717edec09127afc27ff6f62473353a17b51df25feb3a7e637e86eb6a7
3
+ metadata.gz: 57a888ea873d637d14016b9e9ba7aab35e1421c3f24b9c1b024ccab52c8137eb
4
+ data.tar.gz: 767816ae891334d340fadfcce3984622b7b80706b6a46a9e389ac1998a53e825
5
5
  SHA512:
6
- metadata.gz: 8dd22b1e85f5d0b785467676913165987430edced38c5683a6bc4c782180e74f383807fc784b4db8fcfbb28d0e9b685312395319776fb1db3a873420dbad17ee
7
- data.tar.gz: dbf44b39dbafd1699ece2f9a0d656bc6a5ddd3070ca8884db61548701afa3ee57c1ef3ab639f724f721ee195e1ede80e9323c6d52fe3041457faca89aed682b0
6
+ metadata.gz: f70a84e9f3fa6d2e0b88a18b1c66907817e9806e40fc28cb96838e5f07d83176333ce66ba3a03d3a0e5516e03e256fcf520de33a89dceb99080e521cecb853f2
7
+ data.tar.gz: 014bf59ac564877632a885c2c6c197bb71d16fdff3e1c5f81c8e3716b940b11def6b77de85b2acde7174425fd6439ddfefab73c661f7d8ff8398bbe483fd6b7a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,74 @@
1
+ # 2.3.22 (September 7, 2022)
2
+
3
+ ## Enhancements:
4
+
5
+ - Use a more accurate source code uri in gemspec [#5896](https://github.com/rubygems/rubygems/pull/5896)
6
+ - Support `--path` option in `bundle add` [#5897](https://github.com/rubygems/rubygems/pull/5897)
7
+ - Improve lockfile dependency unlocking [#5881](https://github.com/rubygems/rubygems/pull/5881)
8
+ - Add platform alias `:windows` to Gemfile DSL [#5650](https://github.com/rubygems/rubygems/pull/5650)
9
+ - Make `#to_lock` consistent between `Gem::Dependency` and `Bundler::Dependency` [#5872](https://github.com/rubygems/rubygems/pull/5872)
10
+ - Support marshaled index specifications with `nil` required ruby version [#5824](https://github.com/rubygems/rubygems/pull/5824)
11
+
12
+ ## Bug fixes:
13
+
14
+ - Fix resolution hanging on musl platforms [#5875](https://github.com/rubygems/rubygems/pull/5875)
15
+ - Fix another regression affecting the sorbet family of gems [#5874](https://github.com/rubygems/rubygems/pull/5874)
16
+
17
+ ## Documentation:
18
+
19
+ - Introduce bundle-console(1) man [#5901](https://github.com/rubygems/rubygems/pull/5901)
20
+ - Introduce bundle-version(1) man [#5895](https://github.com/rubygems/rubygems/pull/5895)
21
+ - Introduce bundle-help(1) man [#5886](https://github.com/rubygems/rubygems/pull/5886)
22
+
23
+ # 2.3.21 (August 24, 2022)
24
+
25
+ ## Enhancements:
26
+
27
+ - Backport non gnu libc linux support from RubyGems [#4488](https://github.com/rubygems/rubygems/pull/4488)
28
+ - Improve `Bundler.rm_rf` error message [#5861](https://github.com/rubygems/rubygems/pull/5861)
29
+ - Disallow both `--branch` and `--ref` at the same time in bundle-plugin [#5855](https://github.com/rubygems/rubygems/pull/5855)
30
+ - Restore previous performance of private RubyGems servers [#5826](https://github.com/rubygems/rubygems/pull/5826)
31
+
32
+ ## Bug fixes:
33
+
34
+ - Fix conservative update downgrading top level gems [#5847](https://github.com/rubygems/rubygems/pull/5847)
35
+ - Fix edge case where `bundler/inline` unintentionally skips install [#5848](https://github.com/rubygems/rubygems/pull/5848)
36
+ - Fix `bundle platform` crash when there's a lockfile with no Ruby locked [#5850](https://github.com/rubygems/rubygems/pull/5850)
37
+ - Fix crash when incomplete locked specifications are found in transitive dependencies [#5840](https://github.com/rubygems/rubygems/pull/5840)
38
+ - Fix Ruby platform incorrectly removed on `bundle update` [#5832](https://github.com/rubygems/rubygems/pull/5832)
39
+
40
+ ## Documentation:
41
+
42
+ - Explain cancelled CLI deprecations clearly [#5864](https://github.com/rubygems/rubygems/pull/5864)
43
+ - Improve `bundle config` command synopsis [#5854](https://github.com/rubygems/rubygems/pull/5854)
44
+ - Introduce bundle-plugin(1) man [#5853](https://github.com/rubygems/rubygems/pull/5853)
45
+
46
+ # 2.3.20 (August 10, 2022)
47
+
48
+ ## Enhancements:
49
+
50
+ - Consistently ignore patchlevel when reporting `bundle platform --ruby` [#5793](https://github.com/rubygems/rubygems/pull/5793)
51
+ - Make `--standalone` play nice with `--local` [#5762](https://github.com/rubygems/rubygems/pull/5762)
52
+ - Implement `bundle install --prefer-local` [#5761](https://github.com/rubygems/rubygems/pull/5761)
53
+
54
+ ## Bug fixes:
55
+
56
+ - Fix regression where yanked gems are now unintentionally updated when other gems are unlocked [#5812](https://github.com/rubygems/rubygems/pull/5812)
57
+ - Automatically remove "ruby" from lockfile if incomplete [#5807](https://github.com/rubygems/rubygems/pull/5807)
58
+ - Fix `bundle outdated --strict` showing too many outdated gems [#5798](https://github.com/rubygems/rubygems/pull/5798)
59
+ - Don't discard candidates matching Ruby metadata [#5784](https://github.com/rubygems/rubygems/pull/5784)
60
+ - Fix `bundle outdated` crash in debug mode [#5796](https://github.com/rubygems/rubygems/pull/5796)
61
+ - Fix `ruby` DSL requirement matching for head and prerelease rubies [#5766](https://github.com/rubygems/rubygems/pull/5766)
62
+
63
+ ## Documentation:
64
+
65
+ - Update Bundler support policies to match what we do these days [#5813](https://github.com/rubygems/rubygems/pull/5813)
66
+ - Fix arguments for bundle-config(1) docs [#5804](https://github.com/rubygems/rubygems/pull/5804)
67
+ - Improve `bundle platform` man page [#5788](https://github.com/rubygems/rubygems/pull/5788)
68
+ - Remove `bundle cache` from deprecated commands list, and consistently link to `bundle cache` in man pages [#5783](https://github.com/rubygems/rubygems/pull/5783)
69
+ - Add package/pack aliases to man pages for cache [#5785](https://github.com/rubygems/rubygems/pull/5785)
70
+ - Add deprecation notice of bundle console [#5775](https://github.com/rubygems/rubygems/pull/5775)
71
+
1
72
  # 2.3.19 (July 27, 2022)
2
73
 
3
74
  ## Enhancements:
data/bundler.gemspec CHANGED
@@ -22,14 +22,12 @@ Gem::Specification.new do |s|
22
22
  s.summary = "The best way to manage your application's dependencies"
23
23
  s.description = "Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably"
24
24
 
25
- if s.respond_to?(:metadata=)
26
- s.metadata = {
27
- "bug_tracker_uri" => "https://github.com/rubygems/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
28
- "changelog_uri" => "https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md",
29
- "homepage_uri" => "https://bundler.io/",
30
- "source_code_uri" => "https://github.com/rubygems/rubygems/",
31
- }
32
- end
25
+ s.metadata = {
26
+ "bug_tracker_uri" => "https://github.com/rubygems/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
27
+ "changelog_uri" => "https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md",
28
+ "homepage_uri" => "https://bundler.io/",
29
+ "source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler",
30
+ }
33
31
 
34
32
  s.required_ruby_version = ">= 2.3.0"
35
33
  s.required_rubygems_version = ">= 2.5.2"
@@ -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 = "2022-07-27".freeze
8
- @git_commit_sha = "4f496f93e6".freeze
7
+ @built_at = "2022-09-07".freeze
8
+ @git_commit_sha = "44fb4c9ef5".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -147,8 +147,11 @@ module Bundler
147
147
  def normalize_settings
148
148
  Bundler.settings.set_command_option :path, nil if options[:system]
149
149
  Bundler.settings.set_command_option_if_given :path, options[:path]
150
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
151
- 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
152
155
  end
153
156
 
154
157
  bin_option = options["binstubs"]
@@ -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]
data/lib/bundler/cli.rb CHANGED
@@ -218,6 +218,8 @@ module Bundler
218
218
  "Specify the number of jobs to run in parallel"
219
219
  method_option "local", :type => :boolean, :banner =>
220
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"
221
223
  method_option "no-cache", :type => :boolean, :banner =>
222
224
  "Don't update the existing gem cache."
223
225
  method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
@@ -236,7 +238,7 @@ module Bundler
236
238
  "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
237
239
  method_option "trust-policy", :alias => "P", :type => :string, :banner =>
238
240
  "Gem trust policy (like gem install -P). Must be one of " +
239
- Bundler.rubygems.security_policy_keys.join("|")
241
+ Bundler.rubygems.security_policy_keys.join("|")
240
242
  method_option "without", :type => :array, :banner =>
241
243
  "Exclude gems that are part of the specified named group."
242
244
  method_option "with", :type => :array, :banner =>
@@ -370,6 +372,7 @@ module Bundler
370
372
  method_option "group", :aliases => "-g", :type => :string
371
373
  method_option "source", :aliases => "-s", :type => :string
372
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
373
376
  method_option "git", :type => :string
374
377
  method_option "github", :type => :string
375
378
  method_option "branch", :type => :string
@@ -399,9 +402,9 @@ module Bundler
399
402
  "Do not attempt to fetch gems remotely and use the gem cache instead"
400
403
  method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
401
404
  method_option "source", :type => :array, :banner => "Check against a specific source"
402
- method_option "filter-strict", :type => :boolean, :banner =>
405
+ method_option "filter-strict", :type => :boolean, :aliases => "--strict", :banner =>
403
406
  "Only list newer versions allowed by your Gemfile requirements"
404
- method_option "strict", :type => :boolean, :aliases => "--update-strict", :banner =>
407
+ method_option "update-strict", :type => :boolean, :banner =>
405
408
  "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
406
409
  method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
407
410
  method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
@@ -514,7 +517,7 @@ module Bundler
514
517
  end
515
518
  end
516
519
 
517
- desc "version", "Prints the bundler's version information"
520
+ desc "version", "Prints Bundler version information"
518
521
  def version
519
522
  cli_help = current_command.name == "cli_help"
520
523
  if cli_help || ARGV.include?("version")
@@ -36,17 +36,18 @@ module Bundler
36
36
  rbx
37
37
  ruby
38
38
  truffleruby
39
+ windows
39
40
  x64_mingw
40
41
  ].freeze
41
42
 
42
43
  def ruby?
43
44
  return true if Bundler::GemHelpers.generic_local_platform == Gem::Platform::RUBY
44
45
 
45
- !mswin? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
46
+ !windows? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
46
47
  end
47
48
 
48
49
  def mri?
49
- !mswin? && RUBY_ENGINE == "ruby"
50
+ !windows? && RUBY_ENGINE == "ruby"
50
51
  end
51
52
 
52
53
  def rbx?
@@ -65,16 +66,24 @@ module Bundler
65
66
  RUBY_ENGINE == "truffleruby"
66
67
  end
67
68
 
68
- def mswin?
69
+ def windows?
69
70
  Gem.win_platform?
70
71
  end
71
72
 
73
+ def mswin?
74
+ # For backwards compatibility
75
+ windows?
76
+
77
+ # TODO: This should correctly be:
78
+ # windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin32" && Bundler.local_platform.cpu == "x86"
79
+ end
80
+
72
81
  def mswin64?
73
- Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
82
+ windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
74
83
  end
75
84
 
76
85
  def mingw?
77
- Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
86
+ windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
78
87
  end
79
88
 
80
89
  def x64_mingw?
@@ -70,6 +70,7 @@ module Bundler
70
70
  @unlock = unlock
71
71
  @optional_groups = optional_groups
72
72
  @remote = false
73
+ @prefer_local = false
73
74
  @specs = nil
74
75
  @ruby_version = ruby_version
75
76
  @gemfiles = gemfiles
@@ -144,8 +145,6 @@ module Bundler
144
145
  @dependency_changes = converge_dependencies
145
146
  @local_changes = converge_locals
146
147
 
147
- @reresolve = nil
148
-
149
148
  @requires = compute_requires
150
149
  end
151
150
 
@@ -170,6 +169,13 @@ module Bundler
170
169
  resolve
171
170
  end
172
171
 
172
+ def resolve_prefering_local!
173
+ @prefer_local = true
174
+ @remote = true
175
+ sources.remote!
176
+ resolve
177
+ end
178
+
173
179
  def resolve_with_cache!
174
180
  sources.cached!
175
181
  resolve
@@ -210,6 +216,7 @@ module Bundler
210
216
  true
211
217
  rescue BundlerError => e
212
218
  @resolve = nil
219
+ @resolver = nil
213
220
  @specs = nil
214
221
  @gem_version_promoter = nil
215
222
 
@@ -280,7 +287,7 @@ module Bundler
280
287
  end
281
288
  else
282
289
  Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
283
- @reresolve = reresolve
290
+ resolver.start(expanded_dependencies)
284
291
  end
285
292
  end
286
293
 
@@ -474,10 +481,16 @@ module Bundler
474
481
 
475
482
  private
476
483
 
477
- def reresolve
478
- last_resolve = converge_locked_specs
479
- expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
480
- Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
484
+ def resolver
485
+ @resolver ||= begin
486
+ last_resolve = converge_locked_specs
487
+ remove_ruby_from_platforms_if_necessary!(dependencies)
488
+ Resolver.new(source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve(last_resolve), platforms)
489
+ end
490
+ end
491
+
492
+ def expanded_dependencies
493
+ @expanded_dependencies ||= expand_dependencies(dependencies + metadata_dependencies, true)
481
494
  end
482
495
 
483
496
  def filter_specs(specs, deps)
@@ -505,21 +518,17 @@ module Bundler
505
518
  raise GemNotFound, "Could not find #{missing_specs_list.join(" nor ")}"
506
519
  end
507
520
 
508
- if @reresolve.nil?
521
+ loop do
509
522
  incomplete_specs = specs.incomplete_specs
523
+ break if incomplete_specs.empty?
510
524
 
511
- if incomplete_specs.any?
512
- Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
513
- @unlock[:gems].concat(incomplete_specs.map(&:name))
514
- @resolve = reresolve
515
- specs = resolve.materialize(dependencies)
516
- end
525
+ Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
526
+ @resolve = resolver.start(expanded_dependencies, :exclude_specs => incomplete_specs)
527
+ specs = resolve.materialize(dependencies)
517
528
  end
518
529
 
519
- unless specs["bundler"].any?
520
- bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
521
- specs["bundler"] = bundler
522
- end
530
+ bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
531
+ specs["bundler"] = bundler
523
532
 
524
533
  specs
525
534
  end
@@ -528,6 +537,19 @@ module Bundler
528
537
  @remote && sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
529
538
  end
530
539
 
540
+ def pin_locally_available_names(source_requirements)
541
+ source_requirements.each_with_object({}) do |(name, original_source), new_source_requirements|
542
+ local_source = original_source.dup
543
+ local_source.local_only!
544
+
545
+ new_source_requirements[name] = if local_source.specs.search(name).any?
546
+ local_source
547
+ else
548
+ original_source
549
+ end
550
+ end
551
+ end
552
+
531
553
  def current_ruby_platform_locked?
532
554
  return false unless generic_local_platform == Gem::Platform::RUBY
533
555
  return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
@@ -695,7 +717,9 @@ module Bundler
695
717
  # commonly happen if the Gemfile has changed since the lockfile was last
696
718
  # generated
697
719
  def converge_locked_specs
698
- resolve = converge_specs(@locked_specs)
720
+ converged = converge_specs(@locked_specs)
721
+
722
+ resolve = SpecSet.new(converged.reject {|s| @unlock[:gems].include?(s.name) })
699
723
 
700
724
  diff = nil
701
725
 
@@ -719,16 +743,24 @@ module Bundler
719
743
  specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
720
744
  end
721
745
 
746
+ @specs_that_changed_sources = []
747
+
722
748
  specs.each do |s|
723
- # Replace the locked dependency's source with the equivalent source from the Gemfile
724
749
  dep = @dependencies.find {|d| s.satisfies?(d) }
725
750
 
726
- s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source
751
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
752
+ s.source = if dep && dep.source
753
+ gemfile_source = dep.source
754
+ lockfile_source = s.source
727
755
 
728
- next if @unlock[:sources].include?(s.source.name)
756
+ @specs_that_changed_sources << s if gemfile_source != lockfile_source
729
757
 
730
- # If the spec is from a path source and it doesn't exist anymore
731
- # then we unlock it.
758
+ gemfile_source
759
+ else
760
+ sources.get_with_fallback(s.source)
761
+ end
762
+
763
+ next if @unlock[:sources].include?(s.source.name)
732
764
 
733
765
  # Path sources have special logic
734
766
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
@@ -760,12 +792,12 @@ module Bundler
760
792
  end
761
793
  end
762
794
 
763
- SpecSet.new(filter_specs(converged, deps).reject {|s| @unlock[:gems].include?(s.name) })
795
+ filter_specs(converged, deps)
764
796
  end
765
797
 
766
798
  def metadata_dependencies
767
799
  @metadata_dependencies ||= [
768
- Dependency.new("Ruby\0", RubyVersion.system.gem_version),
800
+ Dependency.new("Ruby\0", Gem.ruby_version),
769
801
  Dependency.new("RubyGems\0", Gem::VERSION),
770
802
  ]
771
803
  end
@@ -792,7 +824,9 @@ module Bundler
792
824
  # specs will be available later when the resolver knows where to
793
825
  # look for that gemspec (or its dependencies)
794
826
  source_requirements = if precompute_source_requirements_for_indirect_dependencies?
795
- { :default => sources.default_source }.merge(source_map.all_requirements)
827
+ all_requirements = source_map.all_requirements
828
+ all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
829
+ { :default => sources.default_source }.merge(all_requirements)
796
830
  else
797
831
  { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
798
832
  end
@@ -802,9 +836,18 @@ module Bundler
802
836
  end
803
837
  source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
804
838
  source_requirements["bundler"] = sources.metadata_source # needs to come last to override
839
+ verify_changed_sources!
805
840
  source_requirements
806
841
  end
807
842
 
843
+ def verify_changed_sources!
844
+ @specs_that_changed_sources.each do |s|
845
+ if s.source.specs.search(s.name).empty?
846
+ raise GemNotFound, "Could not find gem '#{s.name}' in #{s.source}"
847
+ end
848
+ end
849
+ end
850
+
808
851
  def requested_groups
809
852
  values = groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
810
853
  values &= Bundler.settings[:only] unless Bundler.settings[:only].empty?
@@ -835,13 +878,22 @@ module Bundler
835
878
  end
836
879
  end
837
880
 
838
- def additional_base_requirements_for_resolve
881
+ def additional_base_requirements_for_resolve(last_resolve)
839
882
  return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
840
- converge_specs(@originally_locked_specs).map do |locked_spec|
841
- name = locked_spec.name
842
- dep = Dependency.new(name, ">= #{locked_spec.version}")
843
- DepProxy.get_proxy(dep, locked_spec.platform)
844
- end
883
+ converge_specs(@originally_locked_specs - last_resolve).map do |locked_spec|
884
+ Dependency.new(locked_spec.name, ">= #{locked_spec.version}")
885
+ end.uniq
886
+ end
887
+
888
+ def remove_ruby_from_platforms_if_necessary!(dependencies)
889
+ return if Bundler.frozen_bundle? ||
890
+ Bundler.local_platform == Gem::Platform::RUBY ||
891
+ !platforms.include?(Gem::Platform::RUBY) ||
892
+ (@new_platform && platforms.last == Gem::Platform::RUBY) ||
893
+ !@originally_locked_specs.incomplete_ruby_specs?(expand_dependencies(dependencies))
894
+
895
+ remove_platform(Gem::Platform::RUBY)
896
+ add_current_platform
845
897
  end
846
898
 
847
899
  def source_map
@@ -7,92 +7,24 @@ require_relative "rubygems_ext"
7
7
  module Bundler
8
8
  class Dependency < Gem::Dependency
9
9
  attr_reader :autorequire
10
- attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref, :force_ruby_platform
10
+ attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :force_ruby_platform
11
11
 
12
- # rubocop:disable Naming/VariableNumber
12
+ ALL_RUBY_VERSIONS = ((18..27).to_a + (30..31).to_a).freeze
13
13
  PLATFORM_MAP = {
14
- :ruby => Gem::Platform::RUBY,
15
- :ruby_18 => Gem::Platform::RUBY,
16
- :ruby_19 => Gem::Platform::RUBY,
17
- :ruby_20 => Gem::Platform::RUBY,
18
- :ruby_21 => Gem::Platform::RUBY,
19
- :ruby_22 => Gem::Platform::RUBY,
20
- :ruby_23 => Gem::Platform::RUBY,
21
- :ruby_24 => Gem::Platform::RUBY,
22
- :ruby_25 => Gem::Platform::RUBY,
23
- :ruby_26 => Gem::Platform::RUBY,
24
- :ruby_27 => Gem::Platform::RUBY,
25
- :ruby_30 => Gem::Platform::RUBY,
26
- :ruby_31 => Gem::Platform::RUBY,
27
- :mri => Gem::Platform::RUBY,
28
- :mri_18 => Gem::Platform::RUBY,
29
- :mri_19 => Gem::Platform::RUBY,
30
- :mri_20 => Gem::Platform::RUBY,
31
- :mri_21 => Gem::Platform::RUBY,
32
- :mri_22 => Gem::Platform::RUBY,
33
- :mri_23 => Gem::Platform::RUBY,
34
- :mri_24 => Gem::Platform::RUBY,
35
- :mri_25 => Gem::Platform::RUBY,
36
- :mri_26 => Gem::Platform::RUBY,
37
- :mri_27 => Gem::Platform::RUBY,
38
- :mri_30 => Gem::Platform::RUBY,
39
- :mri_31 => Gem::Platform::RUBY,
40
- :rbx => Gem::Platform::RUBY,
41
- :truffleruby => Gem::Platform::RUBY,
42
- :jruby => Gem::Platform::JAVA,
43
- :jruby_18 => Gem::Platform::JAVA,
44
- :jruby_19 => Gem::Platform::JAVA,
45
- :mswin => Gem::Platform::MSWIN,
46
- :mswin_18 => Gem::Platform::MSWIN,
47
- :mswin_19 => Gem::Platform::MSWIN,
48
- :mswin_20 => Gem::Platform::MSWIN,
49
- :mswin_21 => Gem::Platform::MSWIN,
50
- :mswin_22 => Gem::Platform::MSWIN,
51
- :mswin_23 => Gem::Platform::MSWIN,
52
- :mswin_24 => Gem::Platform::MSWIN,
53
- :mswin_25 => Gem::Platform::MSWIN,
54
- :mswin_26 => Gem::Platform::MSWIN,
55
- :mswin_27 => Gem::Platform::MSWIN,
56
- :mswin_30 => Gem::Platform::MSWIN,
57
- :mswin_31 => Gem::Platform::MSWIN,
58
- :mswin64 => Gem::Platform::MSWIN64,
59
- :mswin64_19 => Gem::Platform::MSWIN64,
60
- :mswin64_20 => Gem::Platform::MSWIN64,
61
- :mswin64_21 => Gem::Platform::MSWIN64,
62
- :mswin64_22 => Gem::Platform::MSWIN64,
63
- :mswin64_23 => Gem::Platform::MSWIN64,
64
- :mswin64_24 => Gem::Platform::MSWIN64,
65
- :mswin64_25 => Gem::Platform::MSWIN64,
66
- :mswin64_26 => Gem::Platform::MSWIN64,
67
- :mswin64_27 => Gem::Platform::MSWIN64,
68
- :mswin64_30 => Gem::Platform::MSWIN64,
69
- :mswin64_31 => Gem::Platform::MSWIN64,
70
- :mingw => Gem::Platform::MINGW,
71
- :mingw_18 => Gem::Platform::MINGW,
72
- :mingw_19 => Gem::Platform::MINGW,
73
- :mingw_20 => Gem::Platform::MINGW,
74
- :mingw_21 => Gem::Platform::MINGW,
75
- :mingw_22 => Gem::Platform::MINGW,
76
- :mingw_23 => Gem::Platform::MINGW,
77
- :mingw_24 => Gem::Platform::MINGW,
78
- :mingw_25 => Gem::Platform::MINGW,
79
- :mingw_26 => Gem::Platform::MINGW,
80
- :mingw_27 => Gem::Platform::MINGW,
81
- :mingw_30 => Gem::Platform::MINGW,
82
- :mingw_31 => Gem::Platform::MINGW,
83
- :x64_mingw => Gem::Platform::X64_MINGW,
84
- :x64_mingw_20 => Gem::Platform::X64_MINGW,
85
- :x64_mingw_21 => Gem::Platform::X64_MINGW,
86
- :x64_mingw_22 => Gem::Platform::X64_MINGW,
87
- :x64_mingw_23 => Gem::Platform::X64_MINGW,
88
- :x64_mingw_24 => Gem::Platform::X64_MINGW,
89
- :x64_mingw_25 => Gem::Platform::X64_MINGW,
90
- :x64_mingw_26 => Gem::Platform::X64_MINGW,
91
- :x64_mingw_27 => Gem::Platform::X64_MINGW,
92
- :x64_mingw_30 => Gem::Platform::X64_MINGW,
93
- :x64_mingw_31 => Gem::Platform::X64_MINGW,
94
- }.freeze
95
- # rubocop:enable Naming/VariableNumber
14
+ :ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
15
+ :mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
16
+ :rbx => [Gem::Platform::RUBY],
17
+ :truffleruby => [Gem::Platform::RUBY],
18
+ :jruby => [Gem::Platform::JAVA, [18, 19]],
19
+ :windows => [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS],
20
+ :mswin => [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS],
21
+ :mswin64 => [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]],
22
+ :mingw => [Gem::Platform::MINGW, ALL_RUBY_VERSIONS],
23
+ :x64_mingw => [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]],
24
+ }.each_with_object({}) do |(platform, spec), hash|
25
+ hash[platform] = spec[0]
26
+ spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }
27
+ end.freeze
96
28
 
97
29
  def initialize(name, version, options = {}, &blk)
98
30
  type = options["type"] || :runtime
@@ -101,6 +33,7 @@ module Bundler
101
33
  @autorequire = nil
102
34
  @groups = Array(options["group"] || :default).map(&:to_sym)
103
35
  @source = options["source"]
36
+ @path = options["path"]
104
37
  @git = options["git"]
105
38
  @github = options["github"]
106
39
  @branch = options["branch"]
@@ -151,7 +84,7 @@ module Bundler
151
84
  def to_lock
152
85
  out = super
153
86
  out << "!" if source
154
- out << "\n"
87
+ out
155
88
  end
156
89
 
157
90
  def specific?