rubygems-update 3.5.18 → 3.5.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/Manifest.txt +10 -0
  4. data/bundler/CHANGELOG.md +41 -0
  5. data/bundler/lib/bundler/build_metadata.rb +2 -2
  6. data/bundler/lib/bundler/cli/add.rb +1 -1
  7. data/bundler/lib/bundler/cli/gem.rb +4 -1
  8. data/bundler/lib/bundler/cli/install.rb +5 -1
  9. data/bundler/lib/bundler/cli/lock.rb +5 -5
  10. data/bundler/lib/bundler/cli/outdated.rb +16 -18
  11. data/bundler/lib/bundler/definition.rb +4 -8
  12. data/bundler/lib/bundler/dsl.rb +27 -17
  13. data/bundler/lib/bundler/errors.rb +7 -5
  14. data/bundler/lib/bundler/fetcher.rb +2 -2
  15. data/bundler/lib/bundler/inline.rb +19 -4
  16. data/bundler/lib/bundler/installer/gem_installer.rb +4 -2
  17. data/bundler/lib/bundler/installer/parallel_installer.rb +3 -2
  18. data/bundler/lib/bundler/installer.rb +9 -11
  19. data/bundler/lib/bundler/man/bundle-add.1 +27 -16
  20. data/bundler/lib/bundler/man/bundle-add.1.ronn +37 -14
  21. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  22. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  23. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  24. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  25. data/bundler/lib/bundler/man/bundle-config.1 +1 -1
  26. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  27. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  28. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  29. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  33. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  34. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  40. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  46. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  47. data/bundler/lib/bundler/man/bundle.1 +1 -1
  48. data/bundler/lib/bundler/man/gemfile.5 +3 -1
  49. data/bundler/lib/bundler/man/gemfile.5.ronn +6 -0
  50. data/bundler/lib/bundler/retry.rb +1 -1
  51. data/bundler/lib/bundler/ruby_version.rb +7 -1
  52. data/bundler/lib/bundler/rubygems_ext.rb +43 -16
  53. data/bundler/lib/bundler/rubygems_gem_installer.rb +4 -3
  54. data/bundler/lib/bundler/self_manager.rb +4 -4
  55. data/bundler/lib/bundler/source/git.rb +15 -6
  56. data/bundler/lib/bundler/source/rubygems.rb +5 -12
  57. data/bundler/lib/bundler/ui/shell.rb +24 -2
  58. data/bundler/lib/bundler/ui/silent.rb +12 -1
  59. data/bundler/lib/bundler/vendor/securerandom/.document +1 -0
  60. data/bundler/lib/bundler/vendor/securerandom/LICENSE.txt +22 -0
  61. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +373 -0
  62. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +96 -0
  63. data/bundler/lib/bundler/vendored_securerandom.rb +14 -0
  64. data/bundler/lib/bundler/version.rb +1 -1
  65. data/bundler/lib/bundler.rb +1 -1
  66. data/lib/rubygems/commands/exec_command.rb +1 -6
  67. data/lib/rubygems/commands/fetch_command.rb +14 -0
  68. data/lib/rubygems/commands/install_command.rb +0 -4
  69. data/lib/rubygems/commands/setup_command.rb +2 -0
  70. data/lib/rubygems/exceptions.rb +2 -3
  71. data/lib/rubygems/installer.rb +1 -1
  72. data/lib/rubygems/remote_fetcher.rb +0 -1
  73. data/lib/rubygems/resolver/activation_request.rb +1 -1
  74. data/lib/rubygems/resolver/best_set.rb +2 -28
  75. data/lib/rubygems/source/git.rb +7 -5
  76. data/lib/rubygems/source/installed.rb +3 -1
  77. data/lib/rubygems/source/local.rb +8 -4
  78. data/lib/rubygems/source/specific_file.rb +5 -3
  79. data/lib/rubygems/source.rb +10 -8
  80. data/lib/rubygems/specification.rb +1 -1
  81. data/lib/rubygems/specification_policy.rb +1 -1
  82. data/lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb +1 -1
  83. data/lib/rubygems/vendor/net-http/lib/net/https.rb +1 -1
  84. data/lib/rubygems/vendor/optparse/lib/optparse.rb +1 -1
  85. data/lib/rubygems/vendor/resolv/lib/resolv.rb +71 -16
  86. data/lib/rubygems/vendor/securerandom/.document +1 -0
  87. data/lib/rubygems/vendor/securerandom/LICENSE.txt +22 -0
  88. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +373 -0
  89. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +96 -0
  90. data/lib/rubygems/vendored_securerandom.rb +4 -0
  91. data/lib/rubygems.rb +18 -15
  92. data/rubygems-update.gemspec +1 -1
  93. metadata +13 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3139eb9f0637a60e29d93dd00cfa4d2bd484a0901d919e9863f4d10ad0e8f3a
4
- data.tar.gz: e4ae59b74ee6faef499b282cbef49177f02aa0e7f6737ae844cf32d4543829d1
3
+ metadata.gz: 3b333e62d8d40ff14565906d7d6eeebc3528d75a867bb55976b8e0af689041de
4
+ data.tar.gz: b02067c1f5d373b50050680c8c5f30a37755687bcffbaf97af74ffa22ea2002b
5
5
  SHA512:
6
- metadata.gz: 5fa2a4b919ec4a16af6f6b4de687aa98fe16f3dadca6e96c530c5d2c1d53f4eed6ce9e5137b468271692fc35e3eb025f8a38559d3da599347374494278f176bb
7
- data.tar.gz: ffc9199f1fc3cf5023cf1344c3597ae1ce08b9a7ba817f4b4b082da5c0d92031085c1b62d2f0629e190297c7b9abcdbd53eb9eb99f6f4281ed9f5aff683e6a9f
6
+ metadata.gz: 301d3005afa49dc6123b57f592feb69ba519c5844794df524a2193a2cf9ee30e347ff0336063c20e945e96fa0aa04390790d1d166980dfc25deffc2fa8328ed5
7
+ data.tar.gz: 68bdf50470713768ff3baa8a9a9e13f249d6580d73d0cb95c63d2f791e0391eb9e5940c51c36262b852ed2f1f98b2784a5d724d98de2702b4433460acff542b8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,49 @@
1
+ # 3.5.20 / 2024-09-24
2
+
3
+ ## Enhancements:
4
+
5
+ * Installs bundler 2.5.20 as a default gem.
6
+
7
+ # 3.5.19 / 2024-09-18
8
+
9
+ ## Enhancements:
10
+
11
+ * Standardize pretty-print output for `Gem::Source` and subclasses. Pull
12
+ request [#7994](https://github.com/rubygems/rubygems/pull/7994) by
13
+ djberube
14
+ * Update vendored `molinillo` to master and vendored `resolv` to 0.4.0.
15
+ Pull request [#7521](https://github.com/rubygems/rubygems/pull/7521) by
16
+ hsbt
17
+ * Installs bundler 2.5.19 as a default gem.
18
+
19
+ ## Bug fixes:
20
+
21
+ * Fix `bundle exec rake install` failing when local gem has extensions.
22
+ Pull request [#7977](https://github.com/rubygems/rubygems/pull/7977) by
23
+ deivid-rodriguez
24
+ * Make `gem exec` use the standard GEM_HOME. Pull request
25
+ [#7982](https://github.com/rubygems/rubygems/pull/7982) by
26
+ deivid-rodriguez
27
+ * Fix `gem fetch` always exiting with zero status code. Pull request
28
+ [#8007](https://github.com/rubygems/rubygems/pull/8007) by
29
+ deivid-rodriguez
30
+ * Remove temporary `.lock` files unintentionally left around by gem
31
+ installer. Pull request
32
+ [#7939](https://github.com/rubygems/rubygems/pull/7939) by nobu
33
+ * Removed unused stringio. Pull request
34
+ [#8001](https://github.com/rubygems/rubygems/pull/8001) by hsbt
35
+ * Avoid another race condition of open mode. Pull request
36
+ [#7931](https://github.com/rubygems/rubygems/pull/7931) by nobu
37
+ * Fix `@license` typo preventing licenses from being correctly
38
+ unmarshalled. Pull request
39
+ [#7975](https://github.com/rubygems/rubygems/pull/7975) by djberube
40
+
41
+ ## Performance:
42
+
43
+ * Fix `gem install does-not-exist` being super slow. Pull request
44
+ [#8006](https://github.com/rubygems/rubygems/pull/8006) by
45
+ deivid-rodriguez
46
+
1
47
  # 3.5.18 / 2024-08-26
2
48
 
3
49
  ## Enhancements:
data/Manifest.txt CHANGED
@@ -283,6 +283,10 @@ bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb
283
283
  bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
284
284
  bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
285
285
  bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb
286
+ bundler/lib/bundler/vendor/securerandom/.document
287
+ bundler/lib/bundler/vendor/securerandom/LICENSE.txt
288
+ bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb
289
+ bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb
286
290
  bundler/lib/bundler/vendor/thor/.document
287
291
  bundler/lib/bundler/vendor/thor/LICENSE.md
288
292
  bundler/lib/bundler/vendor/thor/lib/thor.rb
@@ -344,6 +348,7 @@ bundler/lib/bundler/vendored_fileutils.rb
344
348
  bundler/lib/bundler/vendored_net_http.rb
345
349
  bundler/lib/bundler/vendored_persistent.rb
346
350
  bundler/lib/bundler/vendored_pub_grub.rb
351
+ bundler/lib/bundler/vendored_securerandom.rb
347
352
  bundler/lib/bundler/vendored_thor.rb
348
353
  bundler/lib/bundler/vendored_timeout.rb
349
354
  bundler/lib/bundler/vendored_tsort.rb
@@ -585,6 +590,10 @@ lib/rubygems/vendor/optparse/lib/optparse/version.rb
585
590
  lib/rubygems/vendor/resolv/.document
586
591
  lib/rubygems/vendor/resolv/LICENSE.txt
587
592
  lib/rubygems/vendor/resolv/lib/resolv.rb
593
+ lib/rubygems/vendor/securerandom/.document
594
+ lib/rubygems/vendor/securerandom/LICENSE.txt
595
+ lib/rubygems/vendor/securerandom/lib/random/formatter.rb
596
+ lib/rubygems/vendor/securerandom/lib/securerandom.rb
588
597
  lib/rubygems/vendor/timeout/.document
589
598
  lib/rubygems/vendor/timeout/LICENSE.txt
590
599
  lib/rubygems/vendor/timeout/lib/timeout.rb
@@ -611,6 +620,7 @@ lib/rubygems/vendor/uri/lib/uri/wss.rb
611
620
  lib/rubygems/vendored_molinillo.rb
612
621
  lib/rubygems/vendored_net_http.rb
613
622
  lib/rubygems/vendored_optparse.rb
623
+ lib/rubygems/vendored_securerandom.rb
614
624
  lib/rubygems/vendored_timeout.rb
615
625
  lib/rubygems/vendored_tsort.rb
616
626
  lib/rubygems/version.rb
data/bundler/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ # 2.5.20 (September 24, 2024)
2
+
3
+ ## Enhancements:
4
+
5
+ - Don't try to auto-install dev versions of Bundler not available remotely [#8045](https://github.com/rubygems/rubygems/pull/8045)
6
+ - Don't try to install locked bundler when `--local` is passed [#8041](https://github.com/rubygems/rubygems/pull/8041)
7
+
8
+ ## Bug fixes:
9
+
10
+ - Fix `bundler/inline` overwriting lockfiles [#8055](https://github.com/rubygems/rubygems/pull/8055)
11
+ - Ensure refs directory in cached git source [#8047](https://github.com/rubygems/rubygems/pull/8047)
12
+ - Fix `bundle outdated` with `--group` option [#8052](https://github.com/rubygems/rubygems/pull/8052)
13
+
14
+ # 2.5.19 (September 18, 2024)
15
+
16
+ ## Enhancements:
17
+
18
+ - Raise original errors when unexpected errors happen during Gemfile evaluation [#8003](https://github.com/rubygems/rubygems/pull/8003)
19
+ - Make an exe file executable when generating new gems [#8020](https://github.com/rubygems/rubygems/pull/8020)
20
+ - Gracefully handle gem activation conflicts in inline mode [#5535](https://github.com/rubygems/rubygems/pull/5535)
21
+ - Don't include hook templates in cached git source [#8013](https://github.com/rubygems/rubygems/pull/8013)
22
+ - Fix some errors about a previous installation folder that's unsafe to remove, when there's no need to remove it [#7985](https://github.com/rubygems/rubygems/pull/7985)
23
+ - Emit progress to stderr during `bundle outdated --parseable` [#7966](https://github.com/rubygems/rubygems/pull/7966)
24
+ - Reject unknown platforms when running `bundle lock --add-platform` [#7967](https://github.com/rubygems/rubygems/pull/7967)
25
+ - Emit progress to stderr when `--print` is passed to `bundle lock` [#7957](https://github.com/rubygems/rubygems/pull/7957)
26
+
27
+ ## Bug fixes:
28
+
29
+ - Fix `bundle install --local` hitting the network when default gems are included [#8027](https://github.com/rubygems/rubygems/pull/8027)
30
+ - Remove temporary `.lock` files unintentionally left around by gem installer [#8022](https://github.com/rubygems/rubygems/pull/8022)
31
+ - Fix `bundle exec rake install` failing when local gem has extensions [#7977](https://github.com/rubygems/rubygems/pull/7977)
32
+ - Load gemspecs in the context of its parent also when using local overrides [#7993](https://github.com/rubygems/rubygems/pull/7993)
33
+ - Fix `bundler/inline` failing in Ruby 3.2 due to conflicting `securerandom` versions [#7984](https://github.com/rubygems/rubygems/pull/7984)
34
+ - Don't blow up when explicit version is removed from some git sources [#7973](https://github.com/rubygems/rubygems/pull/7973)
35
+ - Fix `gem exec rails new project` failing on Ruby 3.2 [#7960](https://github.com/rubygems/rubygems/pull/7960)
36
+
37
+ ## Documentation:
38
+
39
+ - Improve `bundle add` man page [#5903](https://github.com/rubygems/rubygems/pull/5903)
40
+ - Add some documentation about backwards compatibility [#7964](https://github.com/rubygems/rubygems/pull/7964)
41
+
1
42
  # 2.5.18 (August 26, 2024)
2
43
 
3
44
  ## 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 = "2024-08-26".freeze
8
- @git_commit_sha = "c218aab519".freeze
7
+ @built_at = "2024-09-24".freeze
8
+ @git_commit_sha = "a0fc99594a".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -34,7 +34,7 @@ module Bundler
34
34
  end
35
35
 
36
36
  def validate_options!
37
- raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic]
37
+ raise InvalidOption, "You cannot specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic]
38
38
 
39
39
  # raise error when no gems are specified
40
40
  raise InvalidOption, "Please specify gems to add." if gems.empty?
@@ -191,7 +191,10 @@ module Bundler
191
191
  templates.merge!("standard.yml.tt" => ".standard.yml")
192
192
  end
193
193
 
194
- templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
194
+ if config[:exe]
195
+ templates.merge!("exe/newgem.tt" => "exe/#{name}")
196
+ executables.push("exe/#{name}")
197
+ end
195
198
 
196
199
  if extension == "c"
197
200
  templates.merge!(
@@ -12,7 +12,11 @@ module Bundler
12
12
 
13
13
  warn_if_root
14
14
 
15
- Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
15
+ if options[:local]
16
+ Bundler.self_manager.restart_with_locked_bundler_if_needed
17
+ else
18
+ Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
19
+ end
16
20
 
17
21
  Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?
18
22
 
@@ -15,8 +15,8 @@ module Bundler
15
15
  end
16
16
 
17
17
  print = options[:print]
18
- previous_ui_level = Bundler.ui.level
19
- Bundler.ui.level = "silent" if print
18
+ previous_output_stream = Bundler.ui.output_stream
19
+ Bundler.ui.output_stream = :stderr if print
20
20
 
21
21
  Bundler::Fetcher.disable_endpoint = options["full-index"]
22
22
 
@@ -48,8 +48,8 @@ module Bundler
48
48
  options["add-platform"].each do |platform_string|
49
49
  platform = Gem::Platform.new(platform_string)
50
50
  if platform.to_s == "unknown"
51
- Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
52
- "and adding it will likely lead to resolution errors"
51
+ Bundler.ui.error "The platform `#{platform_string}` is unknown to RubyGems and can't be added to the lockfile."
52
+ exit 1
53
53
  end
54
54
  definition.add_platform(platform)
55
55
  end
@@ -68,7 +68,7 @@ module Bundler
68
68
  end
69
69
  end
70
70
 
71
- Bundler.ui.level = previous_ui_level
71
+ Bundler.ui.output_stream = previous_output_stream
72
72
  end
73
73
  end
74
74
  end
@@ -54,7 +54,7 @@ module Bundler
54
54
  end
55
55
 
56
56
  if options[:parseable]
57
- Bundler.ui.silence(&definition_resolution)
57
+ Bundler.ui.progress(&definition_resolution)
58
58
  else
59
59
  definition_resolution.call
60
60
  end
@@ -97,28 +97,26 @@ module Bundler
97
97
  }
98
98
  end
99
99
 
100
- if outdated_gems.empty?
100
+ relevant_outdated_gems = if options_include_groups
101
+ outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
102
+ contains_group = groups.split(", ").include?(options[:group])
103
+ next unless options[:groups] || contains_group
104
+
105
+ gems
106
+ end.compact
107
+ else
108
+ outdated_gems
109
+ end
110
+
111
+ if relevant_outdated_gems.empty?
101
112
  unless options[:parseable]
102
113
  Bundler.ui.info(nothing_outdated_message)
103
114
  end
104
115
  else
105
- if options_include_groups
106
- relevant_outdated_gems = outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
107
- contains_group = groups.split(", ").include?(options[:group])
108
- next unless options[:groups] || contains_group
109
-
110
- gems
111
- end.compact
112
-
113
- if options[:parseable]
114
- print_gems(relevant_outdated_gems)
115
- else
116
- print_gems_table(relevant_outdated_gems)
117
- end
118
- elsif options[:parseable]
119
- print_gems(outdated_gems)
116
+ if options[:parseable]
117
+ print_gems(relevant_outdated_gems)
120
118
  else
121
- print_gems_table(outdated_gems)
119
+ print_gems_table(relevant_outdated_gems)
122
120
  end
123
121
 
124
122
  exit 1
@@ -317,7 +317,7 @@ module Bundler
317
317
 
318
318
  def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
319
319
  if [true, false, nil].include?(file_or_preserve_unknown_sections)
320
- target_lockfile = lockfile || Bundler.default_lockfile
320
+ target_lockfile = lockfile
321
321
  preserve_unknown_sections = file_or_preserve_unknown_sections
322
322
  else
323
323
  target_lockfile = file_or_preserve_unknown_sections
@@ -511,15 +511,11 @@ module Bundler
511
511
  end
512
512
 
513
513
  def lockfile_exists?
514
- file_exists?(lockfile)
515
- end
516
-
517
- def file_exists?(file)
518
- file && File.exist?(file)
514
+ lockfile && File.exist?(lockfile)
519
515
  end
520
516
 
521
517
  def write_lock(file, preserve_unknown_sections)
522
- return if Definition.no_lock
518
+ return if Definition.no_lock || file.nil?
523
519
 
524
520
  contents = to_lock
525
521
 
@@ -536,7 +532,7 @@ module Bundler
536
532
 
537
533
  preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
538
534
 
539
- if file_exists?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
535
+ if File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
540
536
  return if Bundler.frozen_bundle?
541
537
  SharedHelpers.filesystem_access(file) { FileUtils.touch(file) }
542
538
  return
@@ -42,20 +42,20 @@ module Bundler
42
42
  end
43
43
 
44
44
  def eval_gemfile(gemfile, contents = nil)
45
- expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
46
- original_gemfile = @gemfile
47
- @gemfile = expanded_gemfile_path
48
- @gemfiles << expanded_gemfile_path
49
- contents ||= Bundler.read_file(@gemfile.to_s)
50
- instance_eval(contents, @gemfile.to_s, 1)
51
- rescue Exception => e # rubocop:disable Lint/RescueException
52
- message = "There was an error " \
53
- "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
54
- "`#{File.basename gemfile.to_s}`: #{e.message}"
55
-
56
- raise DSLError.new(message, gemfile, e.backtrace, contents)
57
- ensure
58
- @gemfile = original_gemfile
45
+ with_gemfile(gemfile) do |current_gemfile|
46
+ contents ||= Bundler.read_file(current_gemfile)
47
+ instance_eval(contents, current_gemfile, 1)
48
+ rescue GemfileEvalError => e
49
+ message = "There was an error evaluating `#{File.basename current_gemfile}`: #{e.message}"
50
+ raise DSLError.new(message, current_gemfile, e.backtrace, contents)
51
+ rescue GemfileError, InvalidArgumentError, InvalidOption, DeprecatedError, ScriptError => e
52
+ message = "There was an error parsing `#{File.basename current_gemfile}`: #{e.message}"
53
+ raise DSLError.new(message, current_gemfile, e.backtrace, contents)
54
+ rescue StandardError => e
55
+ raise unless e.backtrace_locations.first.path == current_gemfile
56
+ message = "There was an error parsing `#{File.basename current_gemfile}`: #{e.message}"
57
+ raise DSLError.new(message, current_gemfile, e.backtrace, contents)
58
+ end
59
59
  end
60
60
 
61
61
  def gemspec(opts = nil)
@@ -219,7 +219,7 @@ module Bundler
219
219
  end
220
220
 
221
221
  def github(repo, options = {})
222
- raise ArgumentError, "GitHub sources require a block" unless block_given?
222
+ raise InvalidArgumentError, "GitHub sources require a block" unless block_given?
223
223
  github_uri = @git_sources["github"].call(repo)
224
224
  git_options = normalize_hash(options).merge("uri" => github_uri)
225
225
  git_source = @sources.add_git_source(git_options)
@@ -285,6 +285,16 @@ module Bundler
285
285
 
286
286
  private
287
287
 
288
+ def with_gemfile(gemfile)
289
+ expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
290
+ original_gemfile = @gemfile
291
+ @gemfile = expanded_gemfile_path
292
+ @gemfiles << expanded_gemfile_path
293
+ yield @gemfile.to_s
294
+ ensure
295
+ @gemfile = original_gemfile
296
+ end
297
+
288
298
  def add_git_sources
289
299
  git_source(:github) do |repo_name|
290
300
  if repo_name =~ GITHUB_PULL_REQUEST_URL
@@ -577,7 +587,7 @@ module Bundler
577
587
 
578
588
  return m unless backtrace && dsl_path && contents
579
589
 
580
- trace_line = backtrace.find {|l| l.include?(dsl_path.to_s) } || trace_line
590
+ trace_line = backtrace.find {|l| l.include?(dsl_path) } || trace_line
581
591
  return m unless trace_line
582
592
  line_numer = trace_line.split(":")[1].to_i - 1
583
593
  return m unless line_numer
@@ -603,7 +613,7 @@ module Bundler
603
613
 
604
614
  def parse_line_number_from_description
605
615
  description = self.description
606
- if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/
616
+ if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path}):\d+)/
607
617
  trace_line = Regexp.last_match[1]
608
618
  description = description.sub(/\n.*\n(\.\.\.)? *\^~+$/, "").sub(/#{Regexp.quote trace_line}:\s*/, "").sub("\n", " - ")
609
619
  end
@@ -217,15 +217,15 @@ module Bundler
217
217
  end
218
218
 
219
219
  class InsecureInstallPathError < BundlerError
220
- def initialize(path)
220
+ def initialize(name, path)
221
+ @name = name
221
222
  @path = path
222
223
  end
223
224
 
224
225
  def message
225
- "The installation path is insecure. Bundler cannot continue.\n" \
226
- "#{@path} is world-writable (without sticky bit).\n" \
227
- "Bundler cannot safely replace gems in world-writeable directories due to potential vulnerabilities.\n" \
228
- "Please change the permissions of this directory or choose a different install path."
226
+ "Bundler cannot reinstall #{@name} because there's a previous installation of it at #{@path} that is unsafe to remove.\n" \
227
+ "The parent of #{@path} is world-writable and does not have the sticky bit set, making it insecure to remove due to potential vulnerabilities.\n" \
228
+ "Please change the permissions of #{File.dirname(@path)} or choose a different install path."
229
229
  end
230
230
 
231
231
  status_code(38)
@@ -244,4 +244,6 @@ module Bundler
244
244
 
245
245
  status_code(39)
246
246
  end
247
+
248
+ class InvalidArgumentError < BundlerError; status_code(40); end
247
249
  end
@@ -3,7 +3,7 @@
3
3
  require_relative "vendored_persistent"
4
4
  require_relative "vendored_timeout"
5
5
  require "cgi"
6
- require "securerandom"
6
+ require_relative "vendored_securerandom"
7
7
  require "zlib"
8
8
 
9
9
  module Bundler
@@ -182,7 +182,7 @@ module Bundler
182
182
  agent << " ci/#{cis.join(",")}" if cis.any?
183
183
 
184
184
  # add a random ID so we can consolidate runs server-side
185
- agent << " " << SecureRandom.hex(8)
185
+ agent << " " << Gem::SecureRandom.hex(8)
186
186
 
187
187
  # add any user agent strings set in the config
188
188
  extra_ua = Bundler.settings[:user_agent]
@@ -46,11 +46,9 @@ def gemfile(install = false, options = {}, &gemfile)
46
46
  Bundler::Plugin.gemfile_install(&gemfile) if Bundler.feature_flag.plugins?
47
47
  builder = Bundler::Dsl.new
48
48
  builder.instance_eval(&gemfile)
49
- builder.check_primary_source_safety
50
49
 
51
50
  Bundler.settings.temporary(deployment: false, frozen: false) do
52
51
  definition = builder.to_definition(nil, true)
53
- def definition.lock(*); end
54
52
  definition.validate_runtime!
55
53
 
56
54
  if install || definition.missing_specs?
@@ -62,8 +60,25 @@ def gemfile(install = false, options = {}, &gemfile)
62
60
  end
63
61
  end
64
62
 
65
- runtime = Bundler::Runtime.new(nil, definition)
66
- runtime.setup.require
63
+ begin
64
+ runtime = Bundler::Runtime.new(nil, definition).setup
65
+ rescue Gem::LoadError => e
66
+ name = e.name
67
+ version = e.requirement.requirements.first[1]
68
+ activated_version = Gem.loaded_specs[name].version
69
+
70
+ Bundler.ui.info \
71
+ "The #{name} gem was resolved to #{version}, but #{activated_version} was activated by Bundler while installing it, causing a conflict. " \
72
+ "Bundler will now retry resolving with #{activated_version} instead."
73
+
74
+ builder.dependencies.delete_if {|d| d.name == name }
75
+ builder.instance_eval { gem name, activated_version }
76
+ definition = builder.to_definition(nil, true)
77
+
78
+ retry
79
+ end
80
+
81
+ runtime.require
67
82
  end
68
83
  end
69
84
 
@@ -2,14 +2,15 @@
2
2
 
3
3
  module Bundler
4
4
  class GemInstaller
5
- attr_reader :spec, :standalone, :worker, :force, :installer
5
+ attr_reader :spec, :standalone, :worker, :force, :local, :installer
6
6
 
7
- def initialize(spec, installer, standalone = false, worker = 0, force = false)
7
+ def initialize(spec, installer, standalone = false, worker = 0, force = false, local = false)
8
8
  @spec = spec
9
9
  @installer = installer
10
10
  @standalone = standalone
11
11
  @worker = worker
12
12
  @force = force
13
+ @local = local
13
14
  end
14
15
 
15
16
  def install_from_spec
@@ -54,6 +55,7 @@ module Bundler
54
55
  spec.source.install(
55
56
  spec,
56
57
  force: force,
58
+ local: local,
57
59
  build_args: Array(spec_settings),
58
60
  previous_spec: previous_spec,
59
61
  )
@@ -68,11 +68,12 @@ module Bundler
68
68
 
69
69
  attr_reader :size
70
70
 
71
- def initialize(installer, all_specs, size, standalone, force, skip: nil)
71
+ def initialize(installer, all_specs, size, standalone, force, local: false, skip: nil)
72
72
  @installer = installer
73
73
  @size = size
74
74
  @standalone = standalone
75
75
  @force = force
76
+ @local = local
76
77
  @specs = all_specs.map {|s| SpecInstallation.new(s) }
77
78
  @specs.each do |spec_install|
78
79
  spec_install.state = :installed if skip.include?(spec_install.name)
@@ -127,7 +128,7 @@ module Bundler
127
128
  def do_install(spec_install, worker_num)
128
129
  Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL, spec_install)
129
130
  gem_installer = Bundler::GemInstaller.new(
130
- spec_install.spec, @installer, @standalone, worker_num, @force
131
+ spec_install.spec, @installer, @standalone, worker_num, @force, @local
131
132
  )
132
133
  success, message = gem_installer.install_from_spec
133
134
  if success
@@ -194,9 +194,14 @@ module Bundler
194
194
  # that said, it's a rare situation (other than rake), and parallel
195
195
  # installation is SO MUCH FASTER. so we let people opt in.
196
196
  def install(options)
197
- force = options["force"]
197
+ standalone = options[:standalone]
198
+ force = options[:force]
199
+ local = options[:local]
198
200
  jobs = installation_parallelization(options)
199
- install_in_parallel jobs, options[:standalone], force
201
+ spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
202
+ spec_installations.each do |installation|
203
+ post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
204
+ end
200
205
  end
201
206
 
202
207
  def installation_parallelization(options)
@@ -238,18 +243,11 @@ module Bundler
238
243
  end
239
244
  end
240
245
 
241
- def install_in_parallel(size, standalone, force = false)
242
- spec_installations = ParallelInstaller.call(self, @definition.specs, size, standalone, force)
243
- spec_installations.each do |installation|
244
- post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
245
- end
246
- end
247
-
248
246
  # returns whether or not a re-resolve was needed
249
247
  def resolve_if_needed(options)
250
- @definition.prefer_local! if options["prefer-local"]
248
+ @definition.prefer_local! if options[:"prefer-local"]
251
249
 
252
- if options["local"] || (@definition.no_resolve_needed? && !@definition.missing_specs?)
250
+ if options[:local] || (@definition.no_resolve_needed? && !@definition.missing_specs?)
253
251
  @definition.resolve_with_cache!
254
252
  false
255
253
  else
@@ -1,24 +1,12 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-ADD" "1" "June 2024" ""
3
+ .TH "BUNDLE\-ADD" "1" "September 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
6
6
  .SH "SYNOPSIS"
7
- \fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
7
+ \fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT|\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict|\-\-optimistic]
8
8
  .SH "DESCRIPTION"
9
- Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
10
- .P
11
- Example:
12
- .P
13
- bundle add rails
14
- .P
15
- bundle add rails \-\-version "< 3\.0, > 1\.1"
16
- .P
17
- bundle add rails \-\-version "~> 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"
18
- .P
19
- bundle add rails \-\-skip\-install
20
- .P
21
- bundle add rails \-\-group "development, test"
9
+ Adds the named gem to the [\fBGemfile(5)\fR][Gemfile(5)] and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
22
10
  .SH "OPTIONS"
23
11
  .TP
24
12
  \fB\-\-version\fR, \fB\-v\fR
@@ -56,4 +44,27 @@ Adds optimistic declaration of version\.
56
44
  .TP
57
45
  \fB\-\-strict\fR
58
46
  Adds strict declaration of version\.
59
-
47
+ .SH "EXAMPLES"
48
+ .IP "1." 4
49
+ You can add the \fBrails\fR gem to the Gemfile without any version restriction\. The source of the gem will be the global source\.
50
+ .IP
51
+ \fBbundle add rails\fR
52
+ .IP "2." 4
53
+ You can add the \fBrails\fR gem with version greater than 1\.1 (not including 1\.1) and less than 3\.0\.
54
+ .IP
55
+ \fBbundle add rails \-\-version "> 1\.1, < 3\.0"\fR
56
+ .IP "3." 4
57
+ You can use the \fBhttps://gems\.example\.com\fR custom source and assign the gem to a group\.
58
+ .IP
59
+ \fBbundle add rails \-\-version "~> 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"\fR
60
+ .IP "4." 4
61
+ The following adds the \fBgem\fR entry to the Gemfile without installing the gem\. You can install gems later via \fBbundle install\fR\.
62
+ .IP
63
+ \fBbundle add rails \-\-skip\-install\fR
64
+ .IP "5." 4
65
+ You can assign the gem to more than one group\.
66
+ .IP
67
+ \fBbundle add rails \-\-group "development, test"\fR
68
+ .IP "" 0
69
+ .SH "SEE ALSO"
70
+ Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR, bundle\-remove(1) \fIbundle\-remove\.1\.html\fR