bundler 2.3.18 → 2.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -0
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/common.rb +1 -0
  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 +5 -3
  9. data/lib/bundler/definition.rb +103 -29
  10. data/lib/bundler/dsl.rb +2 -2
  11. data/lib/bundler/endpoint_specification.rb +1 -12
  12. data/lib/bundler/fetcher.rb +6 -6
  13. data/lib/bundler/gem_helpers.rb +7 -1
  14. data/lib/bundler/gem_version_promoter.rb +4 -0
  15. data/lib/bundler/index.rb +10 -12
  16. data/lib/bundler/inline.rb +1 -1
  17. data/lib/bundler/installer/standalone.rb +1 -1
  18. data/lib/bundler/installer.rb +14 -12
  19. data/lib/bundler/lazy_specification.rb +30 -23
  20. data/lib/bundler/man/bundle-add.1 +1 -1
  21. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  22. data/lib/bundler/man/bundle-cache.1 +7 -1
  23. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  24. data/lib/bundler/man/bundle-check.1 +1 -1
  25. data/lib/bundler/man/bundle-clean.1 +1 -1
  26. data/lib/bundler/man/bundle-config.1 +25 -6
  27. data/lib/bundler/man/bundle-config.1.ronn +16 -6
  28. data/lib/bundler/man/bundle-doctor.1 +1 -1
  29. data/lib/bundler/man/bundle-exec.1 +2 -2
  30. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  31. data/lib/bundler/man/bundle-gem.1 +1 -1
  32. data/lib/bundler/man/bundle-info.1 +1 -1
  33. data/lib/bundler/man/bundle-init.1 +1 -1
  34. data/lib/bundler/man/bundle-inject.1 +5 -2
  35. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  36. data/lib/bundler/man/bundle-install.1 +5 -1
  37. data/lib/bundler/man/bundle-install.1.ronn +6 -0
  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 +16 -6
  43. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  44. data/lib/bundler/man/bundle-plugin.1 +81 -0
  45. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  46. data/lib/bundler/man/bundle-pristine.1 +1 -1
  47. data/lib/bundler/man/bundle-remove.1 +1 -1
  48. data/lib/bundler/man/bundle-show.1 +1 -1
  49. data/lib/bundler/man/bundle-update.1 +1 -1
  50. data/lib/bundler/man/bundle-viz.1 +4 -1
  51. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  52. data/lib/bundler/man/bundle.1 +10 -9
  53. data/lib/bundler/man/bundle.1.ronn +8 -6
  54. data/lib/bundler/man/gemfile.5 +16 -10
  55. data/lib/bundler/man/gemfile.5.ronn +23 -16
  56. data/lib/bundler/man/index.txt +1 -0
  57. data/lib/bundler/match_metadata.rb +13 -0
  58. data/lib/bundler/match_remote_metadata.rb +26 -0
  59. data/lib/bundler/plugin.rb +2 -0
  60. data/lib/bundler/remote_specification.rb +6 -11
  61. data/lib/bundler/resolver/spec_group.rb +11 -8
  62. data/lib/bundler/resolver.rb +40 -18
  63. data/lib/bundler/ruby_dsl.rb +1 -1
  64. data/lib/bundler/ruby_version.rb +5 -5
  65. data/lib/bundler/rubygems_ext.rb +41 -0
  66. data/lib/bundler/rubygems_gem_installer.rb +19 -12
  67. data/lib/bundler/settings.rb +1 -0
  68. data/lib/bundler/source/metadata.rb +1 -1
  69. data/lib/bundler/source_list.rb +4 -0
  70. data/lib/bundler/spec_set.rb +38 -33
  71. data/lib/bundler/version.rb +1 -1
  72. data/lib/bundler.rb +3 -3
  73. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 677949dc949f82b847c011ee0a401b180743c294d2ea7cc62d1d969483289a59
4
- data.tar.gz: 4ad73bf323c1b3fe9370af0b853992249126ce54624fb97ea5e454f15dbb1e3f
3
+ metadata.gz: 06eb5dcedd936231226213f5eeca20b368e575d153efa728a27ecb0912c41386
4
+ data.tar.gz: 60cfd094b573635123576691ceb73b62d297698b217cc68933e0ad4b293ce7b9
5
5
  SHA512:
6
- metadata.gz: 83b95a19fc8a0077e2660776321547d1b33a83fde01a60819d624b1a5df19e825cd6173d07f595b050f4b6686d82587a886bd5c1f88629b77538d24df65e09d3
7
- data.tar.gz: c29b1d158826b44d561a3dc3484f4a498bbfb9dd2d764160cbb16e5d84e78d7ef3098ce4b67a275f3d5622f94f0739cdf8f599d2e1bb17a20cc88137f82fa190
6
+ metadata.gz: 04ec1c67333ae78914e6076b6b68024d9c8d57199a7d1a3898a44e643c4f91d5132351ee48590dc9c8167a64a9c838906683ac9b09255394c425193b9741ca34
7
+ data.tar.gz: aa077c408592fe31ed5102e8d4b0a5f8f103691236fe71ee40e8461d926047e2e4c65e600557a8addca192e7ad4c8d71c69a34b4ded4bd06d8427f7d437a5d9c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,81 @@
1
+ # 2.3.21 (August 24, 2022)
2
+
3
+ ## Enhancements:
4
+
5
+ - Backport non gnu libc linux support from RubyGems [#4488](https://github.com/rubygems/rubygems/pull/4488)
6
+ - Improve `Bundler.rm_rf` error message [#5861](https://github.com/rubygems/rubygems/pull/5861)
7
+ - Disallow both `--branch` and `--ref` at the same time in bundle-plugin [#5855](https://github.com/rubygems/rubygems/pull/5855)
8
+ - Restore previous performance of private RubyGems servers [#5826](https://github.com/rubygems/rubygems/pull/5826)
9
+
10
+ ## Bug fixes:
11
+
12
+ - Fix conservative update downgrading top level gems [#5847](https://github.com/rubygems/rubygems/pull/5847)
13
+ - Fix edge case where `bundler/inline` unintentionally skips install [#5848](https://github.com/rubygems/rubygems/pull/5848)
14
+ - Fix `bundle platform` crash when there's a lockfile with no Ruby locked [#5850](https://github.com/rubygems/rubygems/pull/5850)
15
+ - Fix crash when incomplete locked specifications are found in transitive dependencies [#5840](https://github.com/rubygems/rubygems/pull/5840)
16
+ - Fix Ruby platform incorrectly removed on `bundle update` [#5832](https://github.com/rubygems/rubygems/pull/5832)
17
+
18
+ ## Documentation:
19
+
20
+ - Explain cancelled CLI deprecations clearly [#5864](https://github.com/rubygems/rubygems/pull/5864)
21
+ - Improve `bundle config` command synopsis [#5854](https://github.com/rubygems/rubygems/pull/5854)
22
+ - Introduce bundle-plugin(1) man [#5853](https://github.com/rubygems/rubygems/pull/5853)
23
+
24
+ # 2.3.20 (August 10, 2022)
25
+
26
+ ## Enhancements:
27
+
28
+ - Consistently ignore patchlevel when reporting `bundle platform --ruby` [#5793](https://github.com/rubygems/rubygems/pull/5793)
29
+ - Make `--standalone` play nice with `--local` [#5762](https://github.com/rubygems/rubygems/pull/5762)
30
+ - Implement `bundle install --prefer-local` [#5761](https://github.com/rubygems/rubygems/pull/5761)
31
+
32
+ ## Bug fixes:
33
+
34
+ - Fix regression where yanked gems are now unintentionally updated when other gems are unlocked [#5812](https://github.com/rubygems/rubygems/pull/5812)
35
+ - Automatically remove "ruby" from lockfile if incomplete [#5807](https://github.com/rubygems/rubygems/pull/5807)
36
+ - Fix `bundle outdated --strict` showing too many outdated gems [#5798](https://github.com/rubygems/rubygems/pull/5798)
37
+ - Don't discard candidates matching Ruby metadata [#5784](https://github.com/rubygems/rubygems/pull/5784)
38
+ - Fix `bundle outdated` crash in debug mode [#5796](https://github.com/rubygems/rubygems/pull/5796)
39
+ - Fix `ruby` DSL requirement matching for head and prerelease rubies [#5766](https://github.com/rubygems/rubygems/pull/5766)
40
+
41
+ ## Documentation:
42
+
43
+ - Update Bundler support policies to match what we do these days [#5813](https://github.com/rubygems/rubygems/pull/5813)
44
+ - Fix arguments for bundle-config(1) docs [#5804](https://github.com/rubygems/rubygems/pull/5804)
45
+ - Improve `bundle platform` man page [#5788](https://github.com/rubygems/rubygems/pull/5788)
46
+ - Remove `bundle cache` from deprecated commands list, and consistently link to `bundle cache` in man pages [#5783](https://github.com/rubygems/rubygems/pull/5783)
47
+ - Add package/pack aliases to man pages for cache [#5785](https://github.com/rubygems/rubygems/pull/5785)
48
+ - Add deprecation notice of bundle console [#5775](https://github.com/rubygems/rubygems/pull/5775)
49
+
50
+ # 2.3.19 (July 27, 2022)
51
+
52
+ ## Enhancements:
53
+
54
+ - Add `Bundler.settings[:only]` to install gems of the specified groups [#5759](https://github.com/rubygems/rubygems/pull/5759)
55
+ - Add `ignore_funding_requests` config flag [#5767](https://github.com/rubygems/rubygems/pull/5767)
56
+ - Prevent random crash when autoloading `Pathname` [#5769](https://github.com/rubygems/rubygems/pull/5769)
57
+ - Don't corrupt lockfile when user moves a gem that's already in the lockfile to an incorrect source by mistake [#5070](https://github.com/rubygems/rubygems/pull/5070)
58
+ - Reconcile error/warning message for multiple global sources with documentation [#5741](https://github.com/rubygems/rubygems/pull/5741)
59
+ - Improve error message when gems cannot be found to include the source for each gem [#5729](https://github.com/rubygems/rubygems/pull/5729)
60
+
61
+ ## Bug fixes:
62
+
63
+ - Fix yet another TruffleRuby platform selection regression [#5746](https://github.com/rubygems/rubygems/pull/5746)
64
+ - Show a proper error if extension dir is not writable [#5726](https://github.com/rubygems/rubygems/pull/5726)
65
+
66
+ ## Performance:
67
+
68
+ - Lazily check incomplete lockfile to improve performance [#5546](https://github.com/rubygems/rubygems/pull/5546)
69
+
70
+ ## Documentation:
71
+
72
+ - Add deprecation notice of bundle inject [#5776](https://github.com/rubygems/rubygems/pull/5776)
73
+ - Add deprecation notice of `bundle viz` to man pages [#5765](https://github.com/rubygems/rubygems/pull/5765)
74
+ - Update command example in `bundle exec` man page [#5754](https://github.com/rubygems/rubygems/pull/5754)
75
+ - Remove bundle show from obsolete commands [#5753](https://github.com/rubygems/rubygems/pull/5753)
76
+ - Improve global source(s) documentation [#5732](https://github.com/rubygems/rubygems/pull/5732)
77
+ - Use https protocol for URLs for config mirror in bundler man [#5722](https://github.com/rubygems/rubygems/pull/5722)
78
+
1
79
  # 2.3.18 (July 14, 2022)
2
80
 
3
81
  ## Enhancements:
@@ -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-14".freeze
8
- @git_commit_sha = "fc31b7f7d9".freeze
7
+ @built_at = "2022-08-24".freeze
8
+ @git_commit_sha = "d54be5fdd8".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -15,6 +15,7 @@ module Bundler
15
15
  end
16
16
 
17
17
  def self.output_fund_metadata_summary
18
+ return if Bundler.settings["ignore_funding_requests"]
18
19
  definition = Bundler.definition
19
20
  current_dependencies = definition.requested_dependencies
20
21
  current_specs = definition.specs
@@ -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 =>
@@ -399,9 +401,9 @@ module Bundler
399
401
  "Do not attempt to fetch gems remotely and use the gem cache instead"
400
402
  method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
401
403
  method_option "source", :type => :array, :banner => "Check against a specific source"
402
- method_option "filter-strict", :type => :boolean, :banner =>
404
+ method_option "filter-strict", :type => :boolean, :aliases => "--strict", :banner =>
403
405
  "Only list newer versions allowed by your Gemfile requirements"
404
- method_option "strict", :type => :boolean, :aliases => "--update-strict", :banner =>
406
+ method_option "update-strict", :type => :boolean, :banner =>
405
407
  "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
406
408
  method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
407
409
  method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
@@ -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
@@ -138,14 +139,12 @@ module Bundler
138
139
  @unlock[:gems] ||= @dependencies.map(&:name)
139
140
  else
140
141
  eager_unlock = expand_dependencies(@unlock[:gems] || [], true)
141
- @unlock[:gems] = @locked_specs.for(eager_unlock, false, false).map(&:name)
142
+ @unlock[:gems] = @locked_specs.for(eager_unlock, false, platforms).map(&:name)
142
143
  end
143
144
 
144
145
  @dependency_changes = converge_dependencies
145
146
  @local_changes = converge_locals
146
147
 
147
- @locked_specs_incomplete_for_platform = !@locked_specs.for(requested_dependencies & expand_dependencies(locked_dependencies), true, true)
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
 
@@ -279,11 +286,8 @@ module Bundler
279
286
  end
280
287
  end
281
288
  else
282
- last_resolve = converge_locked_specs
283
- # Run a resolve against the locally available gems
284
289
  Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
285
- expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
286
- Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
290
+ resolver.start(expanded_dependencies)
287
291
  end
288
292
  end
289
293
 
@@ -468,7 +472,7 @@ module Bundler
468
472
  private :sources
469
473
 
470
474
  def nothing_changed?
471
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform
475
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes
472
476
  end
473
477
 
474
478
  def unlocking?
@@ -477,8 +481,22 @@ module Bundler
477
481
 
478
482
  private
479
483
 
484
+ def resolver
485
+ @resolver ||= begin
486
+ last_resolve = converge_locked_specs
487
+ Resolver.new(source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
488
+ end
489
+ end
490
+
491
+ def expanded_dependencies
492
+ @expanded_dependencies ||= begin
493
+ remove_ruby_from_platforms_if_necessary!(dependencies)
494
+ expand_dependencies(dependencies + metadata_dependencies, true)
495
+ end
496
+ end
497
+
480
498
  def filter_specs(specs, deps)
481
- SpecSet.new(specs).for(expand_dependencies(deps, true), false, false)
499
+ SpecSet.new(specs).for(expand_dependencies(deps, true), false, platforms)
482
500
  end
483
501
 
484
502
  def materialize(dependencies)
@@ -495,14 +513,25 @@ module Bundler
495
513
  "removed in order to install."
496
514
  end
497
515
 
498
- raise GemNotFound, "Could not find #{missing_specs.map(&:full_name).join(", ")} in any of the sources"
516
+ missing_specs_list = missing_specs.group_by(&:source).map do |source, missing_specs_for_source|
517
+ "#{missing_specs_for_source.map(&:full_name).join(", ")} in #{source}"
518
+ end
519
+
520
+ raise GemNotFound, "Could not find #{missing_specs_list.join(" nor ")}"
499
521
  end
500
522
 
501
- unless specs["bundler"].any?
502
- bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
503
- specs["bundler"] = bundler
523
+ loop do
524
+ incomplete_specs = specs.incomplete_specs
525
+ break if incomplete_specs.empty?
526
+
527
+ Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
528
+ @resolve = resolver.start(expanded_dependencies, :exclude_specs => incomplete_specs)
529
+ specs = resolve.materialize(dependencies)
504
530
  end
505
531
 
532
+ bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
533
+ specs["bundler"] = bundler
534
+
506
535
  specs
507
536
  end
508
537
 
@@ -510,6 +539,19 @@ module Bundler
510
539
  @remote && sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
511
540
  end
512
541
 
542
+ def pin_locally_available_names(source_requirements)
543
+ source_requirements.each_with_object({}) do |(name, original_source), new_source_requirements|
544
+ local_source = original_source.dup
545
+ local_source.local_only!
546
+
547
+ new_source_requirements[name] = if local_source.specs.search(name).any?
548
+ local_source
549
+ else
550
+ original_source
551
+ end
552
+ end
553
+ end
554
+
513
555
  def current_ruby_platform_locked?
514
556
  return false unless generic_local_platform == Gem::Platform::RUBY
515
557
  return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
@@ -545,7 +587,6 @@ module Bundler
545
587
  [@new_platform, "you added a new platform to your gemfile"],
546
588
  [@path_changes, "the gemspecs for path gems changed"],
547
589
  [@local_changes, "the gemspecs for git local gems changed"],
548
- [@locked_specs_incomplete_for_platform, "the lockfile does not have all gems needed for the current platform"],
549
590
  ].select(&:first).map(&:last).join(", ")
550
591
  end
551
592
 
@@ -678,7 +719,9 @@ module Bundler
678
719
  # commonly happen if the Gemfile has changed since the lockfile was last
679
720
  # generated
680
721
  def converge_locked_specs
681
- resolve = converge_specs(@locked_specs)
722
+ converged = converge_specs(@locked_specs)
723
+
724
+ resolve = SpecSet.new(converged.reject {|s| @unlock[:gems].include?(s.name) })
682
725
 
683
726
  diff = nil
684
727
 
@@ -702,16 +745,24 @@ module Bundler
702
745
  specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
703
746
  end
704
747
 
748
+ @specs_that_changed_sources = []
749
+
705
750
  specs.each do |s|
706
- # Replace the locked dependency's source with the equivalent source from the Gemfile
707
751
  dep = @dependencies.find {|d| s.satisfies?(d) }
708
752
 
709
- s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source
753
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
754
+ s.source = if dep && dep.source
755
+ gemfile_source = dep.source
756
+ lockfile_source = s.source
710
757
 
711
- next if @unlock[:sources].include?(s.source.name)
758
+ @specs_that_changed_sources << s if gemfile_source != lockfile_source
759
+
760
+ gemfile_source
761
+ else
762
+ sources.get_with_fallback(s.source)
763
+ end
712
764
 
713
- # If the spec is from a path source and it doesn't exist anymore
714
- # then we unlock it.
765
+ next if @unlock[:sources].include?(s.source.name)
715
766
 
716
767
  # Path sources have special logic
717
768
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
@@ -721,7 +772,7 @@ module Bundler
721
772
  # if we won't need the source (according to the lockfile),
722
773
  # don't error if the path/git source isn't available
723
774
  next if specs.
724
- for(requested_dependencies, false, true).
775
+ for(requested_dependencies, false).
725
776
  none? {|locked_spec| locked_spec.source == s.source }
726
777
 
727
778
  raise
@@ -743,12 +794,12 @@ module Bundler
743
794
  end
744
795
  end
745
796
 
746
- SpecSet.new(filter_specs(converged, deps).reject {|s| @unlock[:gems].include?(s.name) })
797
+ filter_specs(converged, deps)
747
798
  end
748
799
 
749
800
  def metadata_dependencies
750
801
  @metadata_dependencies ||= [
751
- Dependency.new("Ruby\0", RubyVersion.system.gem_version),
802
+ Dependency.new("Ruby\0", Gem.ruby_version),
752
803
  Dependency.new("RubyGems\0", Gem::VERSION),
753
804
  ]
754
805
  end
@@ -775,7 +826,9 @@ module Bundler
775
826
  # specs will be available later when the resolver knows where to
776
827
  # look for that gemspec (or its dependencies)
777
828
  source_requirements = if precompute_source_requirements_for_indirect_dependencies?
778
- { :default => sources.default_source }.merge(source_map.all_requirements)
829
+ all_requirements = source_map.all_requirements
830
+ all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
831
+ { :default => sources.default_source }.merge(all_requirements)
779
832
  else
780
833
  { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
781
834
  end
@@ -785,11 +838,22 @@ module Bundler
785
838
  end
786
839
  source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
787
840
  source_requirements["bundler"] = sources.metadata_source # needs to come last to override
841
+ verify_changed_sources!
788
842
  source_requirements
789
843
  end
790
844
 
845
+ def verify_changed_sources!
846
+ @specs_that_changed_sources.each do |s|
847
+ if s.source.specs.search(s.name).empty?
848
+ raise GemNotFound, "Could not find gem '#{s.name}' in #{s.source}"
849
+ end
850
+ end
851
+ end
852
+
791
853
  def requested_groups
792
- groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
854
+ values = groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
855
+ values &= Bundler.settings[:only] unless Bundler.settings[:only].empty?
856
+ values
793
857
  end
794
858
 
795
859
  def lockfiles_equal?(current, proposed, preserve_unknown_sections)
@@ -819,10 +883,20 @@ module Bundler
819
883
  def additional_base_requirements_for_resolve
820
884
  return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
821
885
  converge_specs(@originally_locked_specs).map do |locked_spec|
822
- name = locked_spec.name
823
- dep = Dependency.new(name, ">= #{locked_spec.version}")
824
- DepProxy.get_proxy(dep, locked_spec.platform)
825
- end
886
+ Dependency.new(locked_spec.name, ">= #{locked_spec.version}")
887
+ end.uniq
888
+ end
889
+
890
+ def remove_ruby_from_platforms_if_necessary!(dependencies)
891
+ return if Bundler.frozen_bundle? ||
892
+ Bundler.local_platform == Gem::Platform::RUBY ||
893
+ !platforms.include?(Gem::Platform::RUBY) ||
894
+ (@new_platform && platforms.last == Gem::Platform::RUBY) ||
895
+ !@originally_locked_specs.incomplete_ruby_specs?(expand_dependencies(dependencies))
896
+
897
+ remove_platform(Gem::Platform::RUBY)
898
+ add_current_platform
899
+ resolver.platforms = @platforms
826
900
  end
827
901
 
828
902
  def source_map
data/lib/bundler/dsl.rb CHANGED
@@ -465,12 +465,12 @@ module Bundler
465
465
 
466
466
  def multiple_global_source_warning
467
467
  if Bundler.feature_flag.bundler_3_mode?
468
- msg = "This Gemfile contains multiple primary sources. " \
468
+ msg = "This Gemfile contains multiple global sources. " \
469
469
  "Each source after the first must include a block to indicate which gems " \
470
470
  "should come from that source"
471
471
  raise GemfileEvalError, msg
472
472
  else
473
- Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
473
+ Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \
474
474
  "Using `source` more than once without a block is a security risk, and " \
475
475
  "may result in installing unexpected gems. To resolve this warning, use " \
476
476
  "a block to indicate which gems should come from the secondary source."
@@ -3,7 +3,7 @@
3
3
  module Bundler
4
4
  # used for Creating Specifications from the Gemcutter Endpoint
5
5
  class EndpointSpecification < Gem::Specification
6
- include MatchPlatform
6
+ include MatchRemoteMetadata
7
7
 
8
8
  attr_reader :name, :version, :platform, :checksum
9
9
  attr_accessor :source, :remote, :dependencies
@@ -22,17 +22,6 @@ module Bundler
22
22
  parse_metadata(metadata)
23
23
  end
24
24
 
25
- def required_ruby_version
26
- @required_ruby_version ||= _remote_specification.required_ruby_version
27
- end
28
-
29
- # A fallback is included because the original version of the specification
30
- # API didn't include that field, so some marshalled specs in the index have it
31
- # set to +nil+.
32
- def required_rubygems_version
33
- @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default
34
- end
35
-
36
25
  def fetch_platform
37
26
  @platform
38
27
  end
@@ -240,8 +240,8 @@ module Bundler
240
240
  def connection
241
241
  @connection ||= begin
242
242
  needs_ssl = remote_uri.scheme == "https" ||
243
- Bundler.settings[:ssl_verify_mode] ||
244
- Bundler.settings[:ssl_client_cert]
243
+ Bundler.settings[:ssl_verify_mode] ||
244
+ Bundler.settings[:ssl_client_cert]
245
245
  raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
246
246
 
247
247
  con = PersistentHTTP.new :name => "bundler", :proxy => :ENV
@@ -256,8 +256,8 @@ module Bundler
256
256
  end
257
257
 
258
258
  ssl_client_cert = Bundler.settings[:ssl_client_cert] ||
259
- (Gem.configuration.ssl_client_cert if
260
- Gem.configuration.respond_to?(:ssl_client_cert))
259
+ (Gem.configuration.ssl_client_cert if
260
+ Gem.configuration.respond_to?(:ssl_client_cert))
261
261
  if ssl_client_cert
262
262
  pem = File.read(ssl_client_cert)
263
263
  con.cert = OpenSSL::X509::Certificate.new(pem)
@@ -288,8 +288,8 @@ module Bundler
288
288
  def bundler_cert_store
289
289
  store = OpenSSL::X509::Store.new
290
290
  ssl_ca_cert = Bundler.settings[:ssl_ca_cert] ||
291
- (Gem.configuration.ssl_ca_cert if
292
- Gem.configuration.respond_to?(:ssl_ca_cert))
291
+ (Gem.configuration.ssl_ca_cert if
292
+ Gem.configuration.respond_to?(:ssl_ca_cert))
293
293
  if ssl_ca_cert
294
294
  if File.directory? ssl_ca_cert
295
295
  store.add_path ssl_ca_cert
@@ -44,6 +44,12 @@ module Bundler
44
44
 
45
45
  def select_best_platform_match(specs, platform)
46
46
  matching = specs.select {|spec| spec.match_platform(platform) }
47
+
48
+ sort_best_platform_match(matching, platform)
49
+ end
50
+ module_function :select_best_platform_match
51
+
52
+ def sort_best_platform_match(matching, platform)
47
53
  exact = matching.select {|spec| spec.platform == platform }
48
54
  return exact if exact.any?
49
55
 
@@ -52,7 +58,7 @@ module Bundler
52
58
 
53
59
  sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
54
60
  end
55
- module_function :select_best_platform_match
61
+ module_function :sort_best_platform_match
56
62
 
57
63
  class PlatformMatch
58
64
  def self.specificity_score(spec_platform, user_platform)
@@ -88,6 +88,10 @@ module Bundler
88
88
  end
89
89
  end
90
90
 
91
+ def reset
92
+ @sort_versions = {}
93
+ end
94
+
91
95
  # @return [bool] Convenience method for testing value of level variable.
92
96
  def major?
93
97
  level == :major
data/lib/bundler/index.rb CHANGED
@@ -56,17 +56,17 @@ module Bundler
56
56
 
57
57
  # Search this index's specs, and any source indexes that this index knows
58
58
  # about, returning all of the results.
59
- def search(query, base = nil)
60
- sort_specs(unsorted_search(query, base))
59
+ def search(query)
60
+ sort_specs(unsorted_search(query))
61
61
  end
62
62
 
63
- def unsorted_search(query, base)
64
- results = local_search(query, base)
63
+ def unsorted_search(query)
64
+ results = local_search(query)
65
65
 
66
66
  seen = results.map(&:full_name).uniq unless @sources.empty?
67
67
 
68
68
  @sources.each do |source|
69
- source.unsorted_search(query, base).each do |spec|
69
+ source.unsorted_search(query).each do |spec|
70
70
  next if seen.include?(spec.full_name)
71
71
 
72
72
  seen << spec.full_name
@@ -89,12 +89,12 @@ module Bundler
89
89
  self.class.sort_specs(specs)
90
90
  end
91
91
 
92
- def local_search(query, base = nil)
92
+ def local_search(query)
93
93
  case query
94
94
  when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
95
95
  when String then specs_by_name(query)
96
- when Gem::Dependency then search_by_dependency(query, base)
97
- when DepProxy then search_by_dependency(query.dep, base)
96
+ when Gem::Dependency then search_by_dependency(query)
97
+ when DepProxy then search_by_dependency(query.dep)
98
98
  else
99
99
  raise "You can't search for a #{query.inspect}."
100
100
  end
@@ -185,11 +185,9 @@ module Bundler
185
185
  @specs[name].values
186
186
  end
187
187
 
188
- def search_by_dependency(dependency, base = nil)
189
- @cache[base || false] ||= {}
190
- @cache[base || false][dependency] ||= begin
188
+ def search_by_dependency(dependency)
189
+ @cache[dependency] ||= begin
191
190
  specs = specs_by_name(dependency.name)
192
- specs += base if base
193
191
  found = specs.select do |spec|
194
192
  next true if spec.source.is_a?(Source::Gemspec)
195
193
  dependency.matches_spec?(spec)
@@ -54,7 +54,7 @@ def gemfile(install = false, options = {}, &gemfile)
54
54
 
55
55
  Bundler.ui = install ? ui : Bundler::UI::Silent.new
56
56
  if install || definition.missing_specs?
57
- Bundler.settings.temporary(:inline => true) do
57
+ Bundler.settings.temporary(:inline => true, :no_install => false) do
58
58
  installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
59
59
  installer.post_install_messages.each do |name, message|
60
60
  Bundler.ui.info "Post-install message from #{name}:\n#{message}"