Skip to content

Commit db2bf9f

Browse files
hsbtk0kubun
authored andcommitted
Merge RubyGems-3.6.6 and Bundler-2.6.6
1 parent bbf5f12 commit db2bf9f

File tree

117 files changed

+987
-551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+987
-551
lines changed

lib/bundler/checksum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def initialize(type, location)
126126
end
127127

128128
def removable?
129-
type == :lock || type == :gem
129+
[:lock, :gem].include?(type)
130130
end
131131

132132
def ==(other)

lib/bundler/cli/doctor.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def run
9999
end
100100
end.sort.each {|m| message += m }
101101
raise ProductionError, message
102-
elsif !permissions_valid
102+
elsif permissions_valid
103103
Bundler.ui.info "No issues found with the installed bundle"
104104
end
105105
end
@@ -108,21 +108,21 @@ def run
108108

109109
def check_home_permissions
110110
require "find"
111-
files_not_readable_or_writable = []
112-
files_not_rw_and_owned_by_different_user = []
113-
files_not_owned_by_current_user_but_still_rw = []
111+
files_not_readable = []
112+
files_not_readable_and_owned_by_different_user = []
113+
files_not_owned_by_current_user_but_still_readable = []
114114
broken_symlinks = []
115115
Find.find(Bundler.bundle_path.to_s).each do |f|
116116
if !File.exist?(f)
117117
broken_symlinks << f
118-
elsif !File.writable?(f) || !File.readable?(f)
118+
elsif !File.readable?(f)
119119
if File.stat(f).uid != Process.uid
120-
files_not_rw_and_owned_by_different_user << f
120+
files_not_readable_and_owned_by_different_user << f
121121
else
122-
files_not_readable_or_writable << f
122+
files_not_readable << f
123123
end
124124
elsif File.stat(f).uid != Process.uid
125-
files_not_owned_by_current_user_but_still_rw << f
125+
files_not_owned_by_current_user_but_still_readable << f
126126
end
127127
end
128128

@@ -134,23 +134,23 @@ def check_home_permissions
134134
ok = false
135135
end
136136

137-
if files_not_owned_by_current_user_but_still_rw.any?
137+
if files_not_owned_by_current_user_but_still_readable.any?
138138
Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
139-
"user, but are still readable/writable. These files are:\n - #{files_not_owned_by_current_user_but_still_rw.join("\n - ")}"
139+
"user, but are still readable. These files are:\n - #{files_not_owned_by_current_user_but_still_readable.join("\n - ")}"
140140

141141
ok = false
142142
end
143143

144-
if files_not_rw_and_owned_by_different_user.any?
144+
if files_not_readable_and_owned_by_different_user.any?
145145
Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
146-
"user, and are not readable/writable. These files are:\n - #{files_not_rw_and_owned_by_different_user.join("\n - ")}"
146+
"user, and are not readable. These files are:\n - #{files_not_readable_and_owned_by_different_user.join("\n - ")}"
147147

148148
ok = false
149149
end
150150

151-
if files_not_readable_or_writable.any?
151+
if files_not_readable.any?
152152
Bundler.ui.warn "Files exist in the Bundler home that are not " \
153-
"readable/writable by the current user. These files are:\n - #{files_not_readable_or_writable.join("\n - ")}"
153+
"readable by the current user. These files are:\n - #{files_not_readable.join("\n - ")}"
154154

155155
ok = false
156156
end

lib/bundler/cli/inject.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def run
3535
Bundler.ui.confirm(added.map do |d|
3636
name = "'#{d.name}'"
3737
requirement = ", '#{d.requirement}'"
38-
group = ", :group => #{d.groups.inspect}" if d.groups != Array(:default)
39-
source = ", :source => '#{d.source}'" unless d.source.nil?
38+
group = ", group: #{d.groups.inspect}" if d.groups != Array(:default)
39+
source = ", source: '#{d.source}'" unless d.source.nil?
4040
%(gem #{name}#{requirement}#{group}#{source})
4141
end.join("\n"))
4242
else

lib/bundler/cli/lock.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def run
4444

4545
Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
4646

47-
options["remove-platform"].each do |platform|
47+
options["remove-platform"].each do |platform_string|
48+
platform = Gem::Platform.new(platform_string)
4849
definition.remove_platform(platform)
4950
end
5051

lib/bundler/compact_index_client/updater.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def append(remote_path, local_path, etag_path)
3737
file.digests = parse_digests(response)
3838
# server may ignore Range and return the full response
3939
if response.is_a?(Gem::Net::HTTPPartialContent)
40-
break false unless file.append(response.body.byteslice(1..-1))
40+
tail = response.body.byteslice(1..-1)
41+
break false unless tail && file.append(tail)
4142
else
4243
file.write(response.body)
4344
end

lib/bundler/definition.rb

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
9494

9595
@locked_ruby_version = nil
9696
@new_platforms = []
97-
@removed_platform = nil
97+
@removed_platforms = []
9898

9999
if lockfile_exists?
100100
@lockfile_contents = Bundler.read_file(lockfile)
@@ -330,7 +330,7 @@ def resolve
330330
SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
331331
else
332332
Bundler.ui.debug "Found no changes, using resolution from the lockfile"
333-
if @removed_platform || @locked_gems.may_include_redundant_platform_specific_gems?
333+
if @removed_platforms.any? || @locked_gems.may_include_redundant_platform_specific_gems?
334334
SpecSet.new(filter_specs(@locked_specs, @dependencies))
335335
else
336336
@locked_specs
@@ -412,41 +412,8 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
412412

413413
raise ProductionError, "Frozen mode is set, but there's no lockfile" unless lockfile_exists?
414414

415-
added = []
416-
deleted = []
417-
changed = []
418-
419-
new_platforms = @platforms - @locked_platforms
420-
deleted_platforms = @locked_platforms - @platforms
421-
added.concat new_platforms.map {|p| "* platform: #{p}" }
422-
deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
423-
424-
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
425-
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
426-
427-
both_sources = Hash.new {|h, k| h[k] = [] }
428-
current_dependencies.each {|d| both_sources[d.name][0] = d }
429-
current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
430-
431-
both_sources.each do |name, (dep, lock_dep)|
432-
next if dep.nil? || lock_dep.nil?
433-
434-
gemfile_source = dep.source || default_source
435-
lock_source = lock_dep.source || default_source
436-
next if lock_source.include?(gemfile_source)
437-
438-
gemfile_source_name = dep.source ? gemfile_source.to_gemfile : "no specified source"
439-
lockfile_source_name = lock_dep.source ? lock_source.to_gemfile : "no specified source"
440-
changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
441-
end
442-
443-
reason = resolve_needed? ? change_reason : "some dependencies were deleted from your gemfile"
444-
msg = String.new
445-
msg << "#{reason.capitalize.strip}, but the lockfile can't be updated because frozen mode is set"
446-
msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
447-
msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
448-
msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
449-
msg << "\n\nRun `bundle install` elsewhere and add the updated #{SharedHelpers.relative_gemfile_path} to version control.\n" unless unlocking?
415+
msg = lockfile_changes_summary("frozen mode is set")
416+
return unless msg
450417

451418
unless explicit_flag
452419
suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
@@ -456,7 +423,7 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
456423
"freeze by running `#{suggested_command}`." if suggested_command
457424
end
458425

459-
raise ProductionError, msg if added.any? || deleted.any? || changed.any? || resolve_needed?
426+
raise ProductionError, msg
460427
end
461428

462429
def validate_runtime!
@@ -511,10 +478,10 @@ def add_platform(platform)
511478
end
512479

513480
def remove_platform(platform)
514-
removed_platform = @platforms.delete(Gem::Platform.new(platform))
515-
@removed_platform ||= removed_platform
516-
return if removed_platform
517-
raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}"
481+
raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}" unless @platforms.include?(platform)
482+
483+
@removed_platforms << platform
484+
@platforms.delete(platform)
518485
end
519486

520487
def nothing_changed?
@@ -541,6 +508,46 @@ def add_checksums
541508

542509
private
543510

511+
def lockfile_changes_summary(update_refused_reason)
512+
added = []
513+
deleted = []
514+
changed = []
515+
516+
added.concat @new_platforms.map {|p| "* platform: #{p}" }
517+
deleted.concat @removed_platforms.map {|p| "* platform: #{p}" }
518+
519+
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
520+
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
521+
522+
both_sources = Hash.new {|h, k| h[k] = [] }
523+
current_dependencies.each {|d| both_sources[d.name][0] = d }
524+
current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
525+
526+
both_sources.each do |name, (dep, lock_dep)|
527+
next if dep.nil? || lock_dep.nil?
528+
529+
gemfile_source = dep.source || default_source
530+
lock_source = lock_dep.source || default_source
531+
next if lock_source.include?(gemfile_source)
532+
533+
gemfile_source_name = dep.source ? gemfile_source.to_gemfile : "no specified source"
534+
lockfile_source_name = lock_dep.source ? lock_source.to_gemfile : "no specified source"
535+
changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
536+
end
537+
538+
return unless added.any? || deleted.any? || changed.any? || resolve_needed?
539+
540+
reason = resolve_needed? ? change_reason : "some dependencies were deleted from your gemfile"
541+
542+
msg = String.new
543+
msg << "#{reason.capitalize.strip}, but the lockfile can't be updated because #{update_refused_reason}"
544+
msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
545+
msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
546+
msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
547+
msg << "\n\nRun `bundle install` elsewhere and add the updated #{SharedHelpers.relative_gemfile_path} to version control.\n" unless unlocking?
548+
msg
549+
end
550+
544551
def install_needed?
545552
resolve_needed? || missing_specs?
546553
end
@@ -601,8 +608,12 @@ def write_lock(file, preserve_unknown_sections)
601608
return
602609
end
603610

604-
SharedHelpers.filesystem_access(file) do |p|
605-
File.open(p, "wb") {|f| f.puts(contents) }
611+
begin
612+
SharedHelpers.filesystem_access(file) do |p|
613+
File.open(p, "wb") {|f| f.puts(contents) }
614+
end
615+
rescue ReadOnlyFileSystemError
616+
raise ProductionError, lockfile_changes_summary("file system is read-only")
606617
end
607618
end
608619

@@ -625,7 +636,8 @@ def resolution_packages
625636
@resolution_packages ||= begin
626637
last_resolve = converge_locked_specs
627638
remove_invalid_platforms!
628-
packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: @unlocking_all || @gems_to_unlock, prerelease: gem_version_promoter.pre?, prefer_local: @prefer_local, new_platforms: @new_platforms)
639+
new_resolution_platforms = @current_platform_missing ? @new_platforms + [local_platform] : @new_platforms
640+
packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: @unlocking_all || @gems_to_unlock, prerelease: gem_version_promoter.pre?, prefer_local: @prefer_local, new_platforms: new_resolution_platforms)
629641
packages = additional_base_requirements_to_prevent_downgrades(packages)
630642
packages = additional_base_requirements_to_force_updates(packages)
631643
packages
@@ -768,7 +780,6 @@ def add_current_platform
768780
@most_specific_non_local_locked_platform = find_most_specific_locked_platform
769781
return if @most_specific_non_local_locked_platform
770782

771-
@new_platforms << local_platform
772783
@platforms << local_platform
773784
true
774785
end
@@ -799,7 +810,7 @@ def change_reason
799810
[@source_changes, "the list of sources changed"],
800811
[@dependency_changes, "the dependencies in your gemfile changed"],
801812
[@current_platform_missing, "your lockfile does not include the current platform"],
802-
[@new_platforms.any?, "you added a new platform to your gemfile"],
813+
[@new_platforms.any?, "you are adding a new platform to your lockfile"],
803814
[@path_changes, "the gemspecs for path gems changed"],
804815
[@local_changes, "the gemspecs for git local gems changed"],
805816
[@missing_lockfile_dep, "your lock file is missing \"#{@missing_lockfile_dep}\""],

lib/bundler/errors.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,24 @@ def message
193193
status_code(31)
194194
end
195195

196+
class ReadOnlyFileSystemError < PermissionError
197+
def message
198+
"There was an error while trying to #{action} `#{@path}`. " \
199+
"File system is read-only."
200+
end
201+
202+
status_code(42)
203+
end
204+
205+
class OperationNotPermittedError < PermissionError
206+
def message
207+
"There was an error while trying to #{action} `#{@path}`. " \
208+
"Underlying OS system call raised an EPERM error."
209+
end
210+
211+
status_code(43)
212+
end
213+
196214
class GenericSystemCallError < BundlerError
197215
attr_reader :underlying_error
198216

lib/bundler/injector.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ def build_gem_lines(conservative_versioning)
108108
end
109109

110110
if d.groups != Array(:default)
111-
group = d.groups.size == 1 ? ", :group => #{d.groups.first.inspect}" : ", :groups => #{d.groups.inspect}"
111+
group = d.groups.size == 1 ? ", group: #{d.groups.first.inspect}" : ", groups: #{d.groups.inspect}"
112112
end
113113

114-
source = ", :source => \"#{d.source}\"" unless d.source.nil?
115-
path = ", :path => \"#{d.path}\"" unless d.path.nil?
116-
git = ", :git => \"#{d.git}\"" unless d.git.nil?
117-
github = ", :github => \"#{d.github}\"" unless d.github.nil?
118-
branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
119-
ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
120-
glob = ", :glob => \"#{d.glob}\"" unless d.glob.nil?
121-
require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
114+
source = ", source: \"#{d.source}\"" unless d.source.nil?
115+
path = ", path: \"#{d.path}\"" unless d.path.nil?
116+
git = ", git: \"#{d.git}\"" unless d.git.nil?
117+
github = ", github: \"#{d.github}\"" unless d.github.nil?
118+
branch = ", branch: \"#{d.branch}\"" unless d.branch.nil?
119+
ref = ", ref: \"#{d.ref}\"" unless d.ref.nil?
120+
glob = ", glob: \"#{d.glob}\"" unless d.glob.nil?
121+
require_path = ", require: #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
122122

123123
%(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{glob}#{require_path})
124124
end.join("\n")

lib/bundler/man/bundle-add.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" generated with Ronn-NG/v0.10.1
22
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3-
.TH "BUNDLE\-ADD" "1" "January 2025" ""
3+
.TH "BUNDLE\-ADD" "1" "March 2025" ""
44
.SH "NAME"
55
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
66
.SH "SYNOPSIS"

lib/bundler/man/bundle-binstubs.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" generated with Ronn-NG/v0.10.1
22
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3-
.TH "BUNDLE\-BINSTUBS" "1" "January 2025" ""
3+
.TH "BUNDLE\-BINSTUBS" "1" "March 2025" ""
44
.SH "NAME"
55
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
66
.SH "SYNOPSIS"

0 commit comments

Comments
 (0)