bundler 2.4.12 → 2.4.20

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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +117 -0
  3. data/exe/bundle +5 -13
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli/binstubs.rb +1 -1
  6. data/lib/bundler/cli/info.rb +1 -1
  7. data/lib/bundler/cli/install.rb +1 -1
  8. data/lib/bundler/cli/outdated.rb +1 -1
  9. data/lib/bundler/cli/platform.rb +7 -5
  10. data/lib/bundler/cli/update.rb +1 -0
  11. data/lib/bundler/definition.rb +97 -59
  12. data/lib/bundler/dsl.rb +1 -1
  13. data/lib/bundler/env.rb +1 -1
  14. data/lib/bundler/feature_flag.rb +0 -1
  15. data/lib/bundler/fetcher/base.rb +2 -2
  16. data/lib/bundler/fetcher/compact_index.rb +4 -8
  17. data/lib/bundler/fetcher/dependency.rb +1 -1
  18. data/lib/bundler/fetcher/downloader.rb +2 -0
  19. data/lib/bundler/fetcher/index.rb +1 -2
  20. data/lib/bundler/fetcher.rb +42 -31
  21. data/lib/bundler/friendly_errors.rb +1 -1
  22. data/lib/bundler/gem_helper.rb +3 -4
  23. data/lib/bundler/index.rb +62 -31
  24. data/lib/bundler/installer/parallel_installer.rb +1 -1
  25. data/lib/bundler/installer/standalone.rb +8 -1
  26. data/lib/bundler/installer.rb +1 -1
  27. data/lib/bundler/lockfile_generator.rb +1 -1
  28. data/lib/bundler/lockfile_parser.rb +4 -15
  29. data/lib/bundler/man/bundle-add.1 +1 -1
  30. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  31. data/lib/bundler/man/bundle-cache.1 +3 -3
  32. data/lib/bundler/man/bundle-cache.1.ronn +2 -2
  33. data/lib/bundler/man/bundle-check.1 +1 -1
  34. data/lib/bundler/man/bundle-clean.1 +1 -1
  35. data/lib/bundler/man/bundle-config.1 +1 -4
  36. data/lib/bundler/man/bundle-config.1.ronn +0 -3
  37. data/lib/bundler/man/bundle-console.1 +1 -1
  38. data/lib/bundler/man/bundle-doctor.1 +1 -1
  39. data/lib/bundler/man/bundle-exec.1 +1 -1
  40. data/lib/bundler/man/bundle-gem.1 +1 -1
  41. data/lib/bundler/man/bundle-help.1 +1 -1
  42. data/lib/bundler/man/bundle-info.1 +3 -3
  43. data/lib/bundler/man/bundle-info.1.ronn +3 -3
  44. data/lib/bundler/man/bundle-init.1 +1 -1
  45. data/lib/bundler/man/bundle-inject.1 +1 -1
  46. data/lib/bundler/man/bundle-install.1 +1 -1
  47. data/lib/bundler/man/bundle-list.1 +1 -1
  48. data/lib/bundler/man/bundle-lock.1 +1 -1
  49. data/lib/bundler/man/bundle-open.1 +1 -1
  50. data/lib/bundler/man/bundle-outdated.1 +13 -9
  51. data/lib/bundler/man/bundle-outdated.1.ronn +12 -9
  52. data/lib/bundler/man/bundle-platform.1 +1 -1
  53. data/lib/bundler/man/bundle-plugin.1 +1 -1
  54. data/lib/bundler/man/bundle-pristine.1 +1 -1
  55. data/lib/bundler/man/bundle-remove.1 +1 -1
  56. data/lib/bundler/man/bundle-show.1 +1 -1
  57. data/lib/bundler/man/bundle-update.1 +1 -1
  58. data/lib/bundler/man/bundle-version.1 +1 -1
  59. data/lib/bundler/man/bundle-viz.1 +1 -1
  60. data/lib/bundler/man/bundle.1 +1 -1
  61. data/lib/bundler/man/gemfile.5 +26 -2
  62. data/lib/bundler/man/gemfile.5.ronn +11 -1
  63. data/lib/bundler/plugin/index.rb +1 -1
  64. data/lib/bundler/plugin.rb +1 -1
  65. data/lib/bundler/resolver.rb +34 -5
  66. data/lib/bundler/retry.rb +1 -1
  67. data/lib/bundler/ruby_dsl.rb +27 -0
  68. data/lib/bundler/ruby_version.rb +2 -2
  69. data/lib/bundler/rubygems_integration.rb +1 -1
  70. data/lib/bundler/runtime.rb +1 -1
  71. data/lib/bundler/safe_marshal.rb +31 -0
  72. data/lib/bundler/self_manager.rb +2 -0
  73. data/lib/bundler/settings.rb +40 -16
  74. data/lib/bundler/source/git/git_proxy.rb +45 -15
  75. data/lib/bundler/source/git.rb +40 -14
  76. data/lib/bundler/source/rubygems.rb +30 -30
  77. data/lib/bundler/source.rb +1 -1
  78. data/lib/bundler/source_list.rb +0 -4
  79. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  80. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +4 -4
  81. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +1 -1
  82. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -1
  83. data/lib/bundler/ui/rg_proxy.rb +1 -1
  84. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1 -1
  85. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +9 -4
  86. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +2 -2
  87. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -1
  88. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  89. data/lib/bundler/version.rb +1 -1
  90. data/lib/bundler.rb +7 -15
  91. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6d97506b32368d35025b0ded439395a4f24b4d4f3936452d913a931d673f037
4
- data.tar.gz: 68f38a2de9040263c34db373ad83127a4209d62933d53a034422ce0db90cc611
3
+ metadata.gz: 6276990d50143a594e7e8625034add1d1168df511587dd82c74f7b93a7e66bdc
4
+ data.tar.gz: cca71ac6a7840814e8a7178ca795ed379684658b25c320e8bb67f2c022d3f2e8
5
5
  SHA512:
6
- metadata.gz: 3da71fe39f4a4876346b73bcbb156223a6e21ce5445b797484dee2996753915b9960628b5fdaaadc357c51436e693b490092d9554a1c74906f69832b56bede2e
7
- data.tar.gz: 7646526addcdf4e8eea5cbfda0469bc609f1342a97653ded6dd245c0d1b5f434d2788ad9ad05e3e0fde5e80c02d3ed180a6e71d4c9093fd8b7fa068db47055b9
6
+ metadata.gz: 5162fc140937170d6c3a58e7f9097cbffbcda5fa8edc96a22a14fa5c1ed548cebb8d45fc9ae9901078f4dd1ff99e6f9892f832c2b6a1f598cd34f5163e80b282
7
+ data.tar.gz: 0aea59def565fa9dc8172659891fe2e6ce7b20a033f5197e1679536c91d1102a170a3784d7a05da0255662d6d342b2d1972a437fcad919756f50321b0a6801df
data/CHANGELOG.md CHANGED
@@ -1,3 +1,120 @@
1
+ # 2.4.20 (September 27, 2023)
2
+
3
+ ## Enhancements:
4
+
5
+ - Bump actions/checkout to v4 in bundler gem template [#6966](https://github.com/rubygems/rubygems/pull/6966)
6
+ - Add support for the `ruby-3.2.2` format in the `ruby file:` Gemfile directive, and explicitly test the `3.2.2@gemset` format as rejected [#6954](https://github.com/rubygems/rubygems/pull/6954)
7
+ - Support `ruby file: ".tool-versions"` in Gemfile [#6898](https://github.com/rubygems/rubygems/pull/6898)
8
+ - Unify LockfileParser loading of SPECS section [#6933](https://github.com/rubygems/rubygems/pull/6933)
9
+ - Only check circular deps when dependency api is available, not on full index sources [#6919](https://github.com/rubygems/rubygems/pull/6919)
10
+
11
+ ## Bug fixes:
12
+
13
+ - Allow standalone mode to work on a Windows edge case [#6989](https://github.com/rubygems/rubygems/pull/6989)
14
+ - Fix `bundle outdated` crashing when both `ref` and `branch` specified for a git gem in Gemfile [#6959](https://github.com/rubygems/rubygems/pull/6959)
15
+ - Fix `bundle update --redownload` [#6924](https://github.com/rubygems/rubygems/pull/6924)
16
+ - Fixed malformed bundler version in lockfile making Bundler crash [#6920](https://github.com/rubygems/rubygems/pull/6920)
17
+ - Fix standalone install crashing when using legacy gemfiles with multiple global sources [#6918](https://github.com/rubygems/rubygems/pull/6918)
18
+ - Resolve ruby version file relative to bundle root [#6892](https://github.com/rubygems/rubygems/pull/6892)
19
+
20
+ ## Performance:
21
+
22
+ - Lazily construct fetcher debug messages [#6973](https://github.com/rubygems/rubygems/pull/6973)
23
+ - Avoid allocating empty hashes in Index [#6962](https://github.com/rubygems/rubygems/pull/6962)
24
+ - Stop allocating the same settings keys repeatedly [#6963](https://github.com/rubygems/rubygems/pull/6963)
25
+ - Improve `Bundler::Index` efficiency by removing unnecessary creation and dups [#6931](https://github.com/rubygems/rubygems/pull/6931)
26
+ - (Further) Improve Bundler::Settings#[] performance and memory usage [#6923](https://github.com/rubygems/rubygems/pull/6923)
27
+ - Don't use full indexes unnecessarily on legacy Gemfiles [#6916](https://github.com/rubygems/rubygems/pull/6916)
28
+ - Improve memory usage in Bundler::Settings, and thus improve boot time [#6884](https://github.com/rubygems/rubygems/pull/6884)
29
+
30
+ # 2.4.19 (August 17, 2023)
31
+
32
+ ## Enhancements:
33
+
34
+ - Add `file` option to `ruby` method in Gemfile [#6876](https://github.com/rubygems/rubygems/pull/6876)
35
+ - Show better error when PAT can't authenticate to a private server [#6871](https://github.com/rubygems/rubygems/pull/6871)
36
+ - Don't fallback to old dependency API when bad credentials are configured [#6869](https://github.com/rubygems/rubygems/pull/6869)
37
+
38
+ ## Bug fixes:
39
+
40
+ - Fix git source conservativeness [#6850](https://github.com/rubygems/rubygems/pull/6850)
41
+
42
+ ## Documentation:
43
+
44
+ - Clarify that `bundle info` takes a gem name [#6875](https://github.com/rubygems/rubygems/pull/6875)
45
+
46
+ # 2.4.18 (August 2, 2023)
47
+
48
+ ## Security:
49
+
50
+ - Merge URI-0.12.2 for Bundler [#6779](https://github.com/rubygems/rubygems/pull/6779)
51
+
52
+ ## Enhancements:
53
+
54
+ - Update Magnus version in Rust extension gem template [#6843](https://github.com/rubygems/rubygems/pull/6843)
55
+
56
+ ## Documentation:
57
+
58
+ - Update bundle-outdated(1) man to use table output [#6833](https://github.com/rubygems/rubygems/pull/6833)
59
+
60
+ # 2.4.17 (July 14, 2023)
61
+
62
+ ## Enhancements:
63
+
64
+ - Avoid printing "Using ..." messages when version has not changed [#6804](https://github.com/rubygems/rubygems/pull/6804)
65
+
66
+ ## Bug fixes:
67
+
68
+ - Fix `bundler/setup` unintendedly writing to the filesystem [#6814](https://github.com/rubygems/rubygems/pull/6814)
69
+
70
+ # 2.4.16 (July 10, 2023)
71
+
72
+ ## Bug fixes:
73
+
74
+ - Exclude Bundler from missing locked dependencies check [#6792](https://github.com/rubygems/rubygems/pull/6792)
75
+ - Fix another incorrect removal of "ruby" platform from lockfile when changing path sources [#6784](https://github.com/rubygems/rubygems/pull/6784)
76
+ - Fix git source lockfile instability [#6786](https://github.com/rubygems/rubygems/pull/6786)
77
+
78
+ ## Documentation:
79
+
80
+ - `gemfile.5`: Code format the default glob to escape Markdown [#6790](https://github.com/rubygems/rubygems/pull/6790)
81
+
82
+ # 2.4.15 (June 29, 2023)
83
+
84
+ ## Enhancements:
85
+
86
+ - Improve edge case error message [#6733](https://github.com/rubygems/rubygems/pull/6733)
87
+
88
+ ## Bug fixes:
89
+
90
+ - Fix `bundle lock --update --bundler` [#6213](https://github.com/rubygems/rubygems/pull/6213)
91
+
92
+ # 2.4.14 (June 12, 2023)
93
+
94
+ ## Enhancements:
95
+
96
+ - Stop publishing Gemfile in default gem template [#6723](https://github.com/rubygems/rubygems/pull/6723)
97
+ - Avoid infinite loops when hitting resolution bugs [#6722](https://github.com/rubygems/rubygems/pull/6722)
98
+ - Make `LockfileParser` usable with just a lockfile [#6694](https://github.com/rubygems/rubygems/pull/6694)
99
+ - Always rely on `$LOAD_PATH` when jumping from `exe/` to `lib/` [#6702](https://github.com/rubygems/rubygems/pull/6702)
100
+ - Make `frozen` setting take precedence over `deployment` setting [#6685](https://github.com/rubygems/rubygems/pull/6685)
101
+ - Show an error when trying to update bundler in frozen mode [#6684](https://github.com/rubygems/rubygems/pull/6684)
102
+
103
+ ## Bug fixes:
104
+
105
+ - Fix `deployment` vs `path` precedence [#6703](https://github.com/rubygems/rubygems/pull/6703)
106
+ - Fix inline mode with multiple sources [#6699](https://github.com/rubygems/rubygems/pull/6699)
107
+
108
+ # 2.4.13 (May 9, 2023)
109
+
110
+ ## Bug fixes:
111
+
112
+ - Fix unexpected fallbacks to full index by adding FalseClass and Time to the SafeMarshal list [#6655](https://github.com/rubygems/rubygems/pull/6655)
113
+
114
+ ## Documentation:
115
+
116
+ - Fix broken hyperlinks in bundle cache documentation [#6606](https://github.com/rubygems/rubygems/pull/6606)
117
+
1
118
  # 2.4.12 (April 11, 2023)
2
119
 
3
120
  ## Enhancements:
data/exe/bundle CHANGED
@@ -10,11 +10,11 @@ end
10
10
  base_path = File.expand_path("../lib", __dir__)
11
11
 
12
12
  if File.exist?(base_path)
13
- require_relative "../lib/bundler"
14
- else
15
- require "bundler"
13
+ $LOAD_PATH.unshift(base_path)
16
14
  end
17
15
 
16
+ require "bundler"
17
+
18
18
  if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("2.7.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
19
19
  Bundler.ui.warn \
20
20
  "Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \
@@ -24,18 +24,10 @@ if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::V
24
24
  "and silence this warning by running `gem update --system 3.2.3`"
25
25
  end
26
26
 
27
- if File.exist?(base_path)
28
- require_relative "../lib/bundler/friendly_errors"
29
- else
30
- require "bundler/friendly_errors"
31
- end
27
+ require "bundler/friendly_errors"
32
28
 
33
29
  Bundler.with_friendly_errors do
34
- if File.exist?(base_path)
35
- require_relative "../lib/bundler/cli"
36
- else
37
- require "bundler/cli"
38
- end
30
+ require "bundler/cli"
39
31
 
40
32
  # Allow any command to use --help flag to show help for that command
41
33
  help_flags = %w[--help -h]
@@ -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 = "2023-04-11".freeze
8
- @git_commit_sha = "e2cf278db1".freeze
7
+ @built_at = "2023-09-27".freeze
8
+ @git_commit_sha = "de20c7e7b".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -11,7 +11,7 @@ module Bundler
11
11
  def run
12
12
  Bundler.definition.validate_runtime!
13
13
  path_option = options["path"]
14
- path_option = nil if path_option && path_option.empty?
14
+ path_option = nil if path_option&.empty?
15
15
  Bundler.settings.set_command_option :bin, path_option if options["path"]
16
16
  Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
17
17
  installer = Installer.new(Bundler.root, Bundler.definition)
@@ -33,7 +33,7 @@ module Bundler
33
33
  def default_gem_spec(gem_name)
34
34
  return unless Gem::Specification.respond_to?(:find_all_by_name)
35
35
  gem_spec = Gem::Specification.find_all_by_name(gem_name).last
36
- return gem_spec if gem_spec && gem_spec.respond_to?(:default_gem?) && gem_spec.default_gem?
36
+ gem_spec if gem_spec&.default_gem?
37
37
  end
38
38
 
39
39
  def spec_not_found(gem_name)
@@ -154,7 +154,7 @@ module Bundler
154
154
  end
155
155
 
156
156
  bin_option = options["binstubs"]
157
- bin_option = nil if bin_option && bin_option.empty?
157
+ bin_option = nil if bin_option&.empty?
158
158
  Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]
159
159
 
160
160
  Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
@@ -194,7 +194,7 @@ module Bundler
194
194
  end
195
195
  current_version = "#{current_spec.version}#{current_spec.git_version}"
196
196
 
197
- if dependency && dependency.specific?
197
+ if dependency&.specific?
198
198
  dependency_version = %(, requested #{dependency.requirement})
199
199
  end
200
200
 
@@ -8,12 +8,12 @@ module Bundler
8
8
  end
9
9
 
10
10
  def run
11
- platforms, ruby_version = Bundler.ui.silence do
12
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
13
- gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
14
- [Bundler.definition.platforms.map {|p| "* #{p}" },
15
- locked_ruby_version || gemfile_ruby_version]
11
+ ruby_version = if Bundler.locked_gems
12
+ Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
13
+ else
14
+ Bundler.definition.ruby_version&.single_version_string
16
15
  end
16
+
17
17
  output = []
18
18
 
19
19
  if options[:ruby]
@@ -23,6 +23,8 @@ module Bundler
23
23
  output << "No ruby version specified"
24
24
  end
25
25
  else
26
+ platforms = Bundler.definition.platforms.map {|p| "* #{p}" }
27
+
26
28
  output << "Your platform is: #{Gem::Platform.local}"
27
29
  output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
28
30
 
@@ -63,6 +63,7 @@ module Bundler
63
63
  opts = options.dup
64
64
  opts["update"] = true
65
65
  opts["local"] = options[:local]
66
+ opts["force"] = options[:redownload]
66
67
 
67
68
  Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
68
69
 
@@ -76,8 +76,11 @@ module Bundler
76
76
 
77
77
  @lockfile = lockfile
78
78
  @lockfile_contents = String.new
79
+
79
80
  @locked_bundler_version = nil
80
- @locked_ruby_version = nil
81
+ @resolved_bundler_version = nil
82
+
83
+ @locked_ruby_version = nil
81
84
  @new_platform = nil
82
85
  @removed_platform = nil
83
86
 
@@ -146,7 +149,7 @@ module Bundler
146
149
  @dependency_changes = converge_dependencies
147
150
  @local_changes = converge_locals
148
151
 
149
- @incomplete_lockfile = check_missing_lockfile_specs
152
+ @missing_lockfile_dep = check_missing_lockfile_dep
150
153
  end
151
154
 
152
155
  def gem_version_promoter
@@ -217,6 +220,7 @@ module Bundler
217
220
  rescue BundlerError => e
218
221
  @resolve = nil
219
222
  @resolver = nil
223
+ @resolution_packages = nil
220
224
  @specs = nil
221
225
  @gem_version_promoter = nil
222
226
 
@@ -233,6 +237,14 @@ module Bundler
233
237
  end
234
238
 
235
239
  def current_dependencies
240
+ filter_relevant(dependencies)
241
+ end
242
+
243
+ def current_locked_dependencies
244
+ filter_relevant(locked_dependencies)
245
+ end
246
+
247
+ def filter_relevant(dependencies)
236
248
  dependencies.select do |d|
237
249
  d.should_include? && !d.gem_platforms([generic_local_platform]).empty?
238
250
  end
@@ -272,7 +284,7 @@ module Bundler
272
284
  @resolve ||= if Bundler.frozen_bundle?
273
285
  Bundler.ui.debug "Frozen, using resolution from the lockfile"
274
286
  @locked_specs
275
- elsif !unlocking? && nothing_changed?
287
+ elsif no_resolve_needed?
276
288
  if deleted_deps.any?
277
289
  Bundler.ui.debug "Some dependencies were deleted, using a subset of the resolution from the lockfile"
278
290
  SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
@@ -309,7 +321,7 @@ module Bundler
309
321
 
310
322
  if @locked_bundler_version
311
323
  locked_major = @locked_bundler_version.segments.first
312
- current_major = Bundler.gem_version.segments.first
324
+ current_major = bundler_version_to_lock.segments.first
313
325
 
314
326
  updating_major = locked_major < current_major
315
327
  end
@@ -349,27 +361,16 @@ module Bundler
349
361
  end
350
362
  end
351
363
 
364
+ def bundler_version_to_lock
365
+ @resolved_bundler_version || Bundler.gem_version
366
+ end
367
+
352
368
  def to_lock
353
369
  require_relative "lockfile_generator"
354
370
  LockfileGenerator.generate(self)
355
371
  end
356
372
 
357
373
  def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
358
- msg = String.new
359
- msg << "You are trying to install in deployment mode after changing\n" \
360
- "your Gemfile. Run `bundle install` elsewhere and add the\n" \
361
- "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
362
-
363
- unless explicit_flag
364
- suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
365
- "bundle config unset frozen"
366
- elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
367
- "bundle config unset deployment"
368
- end
369
- msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
370
- "freeze \nby running `#{suggested_command}`." if suggested_command
371
- end
372
-
373
374
  added = []
374
375
  deleted = []
375
376
  changed = []
@@ -383,32 +384,36 @@ module Bundler
383
384
  deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
384
385
 
385
386
  both_sources = Hash.new {|h, k| h[k] = [] }
386
- @dependencies.each {|d| both_sources[d.name][0] = d }
387
-
388
- locked_dependencies.each do |d|
389
- next if !Bundler.feature_flag.bundler_3_mode? && @locked_specs[d.name].empty?
390
-
391
- both_sources[d.name][1] = d
392
- end
387
+ current_dependencies.each {|d| both_sources[d.name][0] = d }
388
+ current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
393
389
 
394
390
  both_sources.each do |name, (dep, lock_dep)|
395
391
  next if dep.nil? || lock_dep.nil?
396
392
 
397
- gemfile_source = dep.source || sources.default_source
398
- lock_source = lock_dep.source || sources.default_source
393
+ gemfile_source = dep.source || default_source
394
+ lock_source = lock_dep.source || default_source
399
395
  next if lock_source.include?(gemfile_source)
400
396
 
401
- gemfile_source_name = dep.source ? gemfile_source.identifier : "no specified source"
402
- lockfile_source_name = lock_dep.source ? lock_source.identifier : "no specified source"
397
+ gemfile_source_name = dep.source ? gemfile_source.to_gemfile : "no specified source"
398
+ lockfile_source_name = lock_dep.source ? lock_source.to_gemfile : "no specified source"
403
399
  changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
404
400
  end
405
401
 
406
402
  reason = change_reason
407
- msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" unless reason.strip.empty?
403
+ msg = String.new
404
+ msg << "#{reason.capitalize.strip}, but the lockfile can't be updated because frozen mode is set"
408
405
  msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
409
406
  msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
410
407
  msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
411
- msg << "\n"
408
+ msg << "\n\nRun `bundle install` elsewhere and add the updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control.\n"
409
+
410
+ unless explicit_flag
411
+ suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
412
+ "bundle config set frozen false"
413
+ end
414
+ msg << "If this is a development machine, remove the #{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)} " \
415
+ "freeze by running `#{suggested_command}`." if suggested_command
416
+ end
412
417
 
413
418
  raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed?
414
419
  end
@@ -473,7 +478,11 @@ module Bundler
473
478
  private :sources
474
479
 
475
480
  def nothing_changed?
476
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@incomplete_lockfile
481
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@missing_lockfile_dep && !@unlocking_bundler
482
+ end
483
+
484
+ def no_resolve_needed?
485
+ !unlocking? && nothing_changed?
477
486
  end
478
487
 
479
488
  def unlocking?
@@ -487,7 +496,14 @@ module Bundler
487
496
  end
488
497
 
489
498
  def expanded_dependencies
490
- dependencies + metadata_dependencies
499
+ dependencies_with_bundler + metadata_dependencies
500
+ end
501
+
502
+ def dependencies_with_bundler
503
+ return dependencies unless @unlocking_bundler
504
+ return dependencies if dependencies.map(&:name).include?("bundler")
505
+
506
+ [Dependency.new("bundler", @unlocking_bundler)] + dependencies
491
507
  end
492
508
 
493
509
  def resolution_packages
@@ -553,6 +569,8 @@ module Bundler
553
569
  def start_resolution
554
570
  result = resolver.start
555
571
 
572
+ @resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
573
+
556
574
  SpecSet.new(SpecSet.new(result).for(dependencies, false, @platforms))
557
575
  end
558
576
 
@@ -610,7 +628,8 @@ module Bundler
610
628
  [@new_platform, "you added a new platform to your gemfile"],
611
629
  [@path_changes, "the gemspecs for path gems changed"],
612
630
  [@local_changes, "the gemspecs for git local gems changed"],
613
- [@incomplete_lockfile, "your lock file is missing some gems"],
631
+ [@missing_lockfile_dep, "your lock file is missing \"#{@missing_lockfile_dep}\""],
632
+ [@unlocking_bundler, "an update to the version of Bundler itself was requested"],
614
633
  ].select(&:first).map(&:last).join(", ")
615
634
  end
616
635
 
@@ -652,8 +671,8 @@ module Bundler
652
671
 
653
672
  Bundler.settings.local_overrides.map do |k, v|
654
673
  spec = @dependencies.find {|s| s.name == k }
655
- source = spec && spec.source
656
- if source && source.respond_to?(:local_override!)
674
+ source = spec&.source
675
+ if source&.respond_to?(:local_override!)
657
676
  source.unlock! if @unlock[:gems].include?(spec.name)
658
677
  locals << [source, source.local_override!(v)]
659
678
  end
@@ -665,7 +684,7 @@ module Bundler
665
684
  !sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
666
685
  end
667
686
 
668
- def check_missing_lockfile_specs
687
+ def check_missing_lockfile_dep
669
688
  all_locked_specs = @locked_specs.map(&:name) << "bundler"
670
689
 
671
690
  missing = @locked_specs.select do |s|
@@ -675,10 +694,14 @@ module Bundler
675
694
  if missing.any?
676
695
  @locked_specs.delete(missing)
677
696
 
678
- true
679
- else
680
- false
697
+ return missing.first.name
681
698
  end
699
+
700
+ return if @dependency_changes
701
+
702
+ current_dependencies.find do |d|
703
+ @locked_specs[d.name].empty? && d.name != "bundler"
704
+ end&.name
682
705
  end
683
706
 
684
707
  def converge_paths
@@ -782,26 +805,27 @@ module Bundler
782
805
 
783
806
  def converge_specs(specs)
784
807
  converged = []
785
-
786
- deps = @dependencies.select do |dep|
787
- specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
788
- end
808
+ deps = []
789
809
 
790
810
  @specs_that_changed_sources = []
791
811
 
792
812
  specs.each do |s|
813
+ name = s.name
793
814
  dep = @dependencies.find {|d| s.satisfies?(d) }
815
+ lockfile_source = s.source
794
816
 
795
- # Replace the locked dependency's source with the equivalent source from the Gemfile
796
- s.source = if dep && dep.source
797
- gemfile_source = dep.source
798
- lockfile_source = s.source
817
+ if dep
818
+ gemfile_source = dep.source || default_source
799
819
 
800
820
  @specs_that_changed_sources << s if gemfile_source != lockfile_source
821
+ deps << dep if !dep.source || lockfile_source.include?(dep.source)
822
+ @unlock[:gems] << name if lockfile_source.include?(dep.source) && lockfile_source != gemfile_source
801
823
 
802
- gemfile_source
824
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
825
+ s.source = gemfile_source
803
826
  else
804
- sources.get_with_fallback(s.source)
827
+ # Replace the locked dependency's source with the default source, if the locked source is no longer in the Gemfile
828
+ s.source = default_source unless sources.get(lockfile_source)
805
829
  end
806
830
 
807
831
  next if @unlock[:sources].include?(s.source.name)
@@ -810,9 +834,9 @@ module Bundler
810
834
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
811
835
  new_specs = begin
812
836
  s.source.specs
813
- rescue PathError, GitError
837
+ rescue PathError
814
838
  # if we won't need the source (according to the lockfile),
815
- # don't error if the path/git source isn't available
839
+ # don't error if the path source isn't available
816
840
  next if specs.
817
841
  for(requested_dependencies, false).
818
842
  none? {|locked_spec| locked_spec.source == s.source }
@@ -826,11 +850,11 @@ module Bundler
826
850
  else
827
851
  # If the spec is no longer in the path source, unlock it. This
828
852
  # commonly happens if the version changed in the gemspec
829
- @unlock[:gems] << s.name
853
+ @unlock[:gems] << name
830
854
  end
831
855
  end
832
856
 
833
- if dep.nil? && requested_dependencies.find {|d| s.name == d.name }
857
+ if dep.nil? && requested_dependencies.find {|d| name == d.name }
834
858
  @unlock[:gems] << s.name
835
859
  else
836
860
  converged << s
@@ -854,7 +878,7 @@ module Bundler
854
878
  source_requirements = if precompute_source_requirements_for_indirect_dependencies?
855
879
  all_requirements = source_map.all_requirements
856
880
  all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
857
- { :default => sources.default_source }.merge(all_requirements)
881
+ { :default => default_source }.merge(all_requirements)
858
882
  else
859
883
  { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
860
884
  end
@@ -862,12 +886,24 @@ module Bundler
862
886
  metadata_dependencies.each do |dep|
863
887
  source_requirements[dep.name] = sources.metadata_source
864
888
  end
865
- source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
866
- source_requirements["bundler"] = sources.metadata_source # needs to come last to override
889
+
890
+ default_bundler_source = source_requirements["bundler"] || default_source
891
+
892
+ if @unlocking_bundler
893
+ default_bundler_source.add_dependency_names("bundler")
894
+ else
895
+ source_requirements[:default_bundler] = default_bundler_source
896
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
897
+ end
898
+
867
899
  verify_changed_sources!
868
900
  source_requirements
869
901
  end
870
902
 
903
+ def default_source
904
+ sources.default_source
905
+ end
906
+
871
907
  def verify_changed_sources!
872
908
  @specs_that_changed_sources.each do |s|
873
909
  if s.source.specs.search(s.name).empty?
@@ -886,7 +922,8 @@ module Bundler
886
922
  if preserve_unknown_sections
887
923
  sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
888
924
  sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
889
- sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
925
+ sections_to_ignore << LockfileParser::RUBY
926
+ sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
890
927
  pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
891
928
  whitespace_cleanup = /\n{2,}/
892
929
  current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
@@ -909,6 +946,7 @@ module Bundler
909
946
  Bundler.local_platform == Gem::Platform::RUBY ||
910
947
  !platforms.include?(Gem::Platform::RUBY) ||
911
948
  (@new_platform && platforms.last == Gem::Platform::RUBY) ||
949
+ @path_changes ||
912
950
  @dependency_changes ||
913
951
  !@originally_locked_specs.incomplete_ruby_specs?(dependencies)
914
952
 
data/lib/bundler/dsl.rb CHANGED
@@ -41,7 +41,7 @@ module Bundler
41
41
  end
42
42
 
43
43
  def eval_gemfile(gemfile, contents = nil)
44
- expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile && @gemfile.parent)
44
+ expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
45
45
  original_gemfile = @gemfile
46
46
  @gemfile = expanded_gemfile_path
47
47
  @gemfiles << expanded_gemfile_path
data/lib/bundler/env.rb CHANGED
@@ -122,7 +122,7 @@ module Bundler
122
122
  specs = Bundler.rubygems.find_name(name)
123
123
  out << [" #{name}", "(#{specs.map(&:version).join(",")})"] unless specs.empty?
124
124
  end
125
- if (exe = caller.last.split(":").first) && exe =~ %r{(exe|bin)/bundler?\z}
125
+ if (exe = caller.last.split(":").first)&.match? %r{(exe|bin)/bundler?\z}
126
126
  shebang = File.read(exe).lines.first
127
127
  shebang.sub!(/^#!\s*/, "")
128
128
  unless shebang.start_with?(Gem.ruby, "/usr/bin/env ruby")
@@ -37,7 +37,6 @@ module Bundler
37
37
  settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
38
38
  settings_flag(:print_only_version_number) { bundler_3_mode? }
39
39
  settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
40
- settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
41
40
  settings_flag(:update_requires_all_flag) { bundler_4_mode? }
42
41
 
43
42
  settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
@@ -38,9 +38,9 @@ module Bundler
38
38
 
39
39
  private
40
40
 
41
- def log_specs(debug_msg)
41
+ def log_specs(&block)
42
42
  if Bundler.ui.debug?
43
- Bundler.ui.debug debug_msg
43
+ Bundler.ui.debug yield
44
44
  else
45
45
  Bundler.ui.info ".", false
46
46
  end