Skip to content

Commit

Permalink
Merge RubyGems-3.5.11 and Bundler-2.5.11
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Jun 5, 2024
1 parent 5bd7e7d commit 8d95fa1
Show file tree
Hide file tree
Showing 87 changed files with 974 additions and 433 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run

Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed

Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?

# Disable color in deployment mode
Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
Expand Down
23 changes: 16 additions & 7 deletions lib/bundler/compact_index_client/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,9 @@ def versions_etag_path
end

def checksums
checksums = {}

lines(versions_path).each do |line|
name, _, checksum = line.split(" ", 3)
checksums[name] = checksum
lines(versions_path).each_with_object({}) do |line, checksums|
parse_version_checksum(line, checksums)
end

checksums
end

def dependencies(name)
Expand Down Expand Up @@ -106,6 +101,20 @@ def parse_gem(line)
@dependency_parser.parse(line)
end

# This is mostly the same as `split(" ", 3)` but it avoids allocating extra objects.
# This method gets called at least once for every gem when parsing versions.
def parse_version_checksum(line, checksums)
line.freeze # allows slicing into the string to not allocate a copy of the line
name_end = line.index(" ")
checksum_start = line.index(" ", name_end + 1) + 1
checksum_end = line.size - checksum_start
# freeze name since it is used as a hash key
# pre-freezing means a frozen copy isn't created
name = line[0, name_end].freeze
checksum = line[checksum_start, checksum_end]
checksums[name] = checksum
end

def info_roots
[
directory.join("info"),
Expand Down
9 changes: 8 additions & 1 deletion lib/bundler/constants.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# frozen_string_literal: true

require "rbconfig"

module Bundler
WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
deprecate_constant :WINDOWS

FREEBSD = RbConfig::CONFIG["host_os"].to_s.include?("bsd")
NULL = File::NULL
deprecate_constant :FREEBSD

NULL = File::NULL
deprecate_constant :NULL
end
39 changes: 15 additions & 24 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
@sources = sources
@unlock = unlock
@optional_groups = optional_groups
@remote = false
@prefer_local = false
@specs = nil
@ruby_version = ruby_version
Expand Down Expand Up @@ -164,37 +163,24 @@ def gem_version_promoter
end

def resolve_only_locally!
@remote = false
sources.local_only!
resolve
end

def resolve_with_cache!
sources.local!
sources.cached!
resolve
end

def resolve_remotely!
@remote = true
sources.cached!
sources.remote!
resolve
end

def resolution_mode=(options)
if options["local"]
@remote = false
else
@remote = true
@prefer_local = options["prefer-local"]
end
end

def setup_sources_for_resolve
if @remote == false
sources.cached!
else
sources.remote!
end
def prefer_local!
@prefer_local = true
end

# For given dependency list returns a SpecSet with Gemspec of all the required
Expand Down Expand Up @@ -310,7 +296,12 @@ def resolve
end
end
else
Bundler.ui.debug "Found changes from the lockfile, re-resolving dependencies because #{change_reason}"
if lockfile_exists?
Bundler.ui.debug "Found changes from the lockfile, re-resolving dependencies because #{change_reason}"
else
Bundler.ui.debug "Resolving dependencies because there's no lockfile"
end

start_resolution
end
end
Expand Down Expand Up @@ -483,6 +474,8 @@ def most_specific_locked_platform
private :sources

def nothing_changed?
return false unless lockfile_exists?

!@source_changes &&
!@dependency_changes &&
!@new_platform &&
Expand Down Expand Up @@ -587,7 +580,7 @@ def materialize(dependencies)
if missing_specs.any?
missing_specs.each do |s|
locked_gem = @locked_specs[s.name].last
next if locked_gem.nil? || locked_gem.version != s.version || !@remote
next if locked_gem.nil? || locked_gem.version != s.version || sources.local_mode?
raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
"no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
"You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
Expand All @@ -606,7 +599,7 @@ def materialize(dependencies)
break if incomplete_specs.empty?

Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
setup_sources_for_resolve
sources.remote!
resolution_packages.delete(incomplete_specs)
@resolve = start_resolution
specs = resolve.materialize(dependencies)
Expand Down Expand Up @@ -967,7 +960,7 @@ def source_requirements
else
{ default: Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
end
source_requirements.merge!(source_map.locked_requirements) unless @remote
source_requirements.merge!(source_map.locked_requirements) if nothing_changed?
metadata_dependencies.each do |dep|
source_requirements[dep.name] = sources.metadata_source
end
Expand Down Expand Up @@ -1038,8 +1031,6 @@ def additional_base_requirements_to_force_updates(resolution_packages)

def dup_for_full_unlock
unlocked_definition = self.class.new(@lockfile, @dependencies, @sources, true, @ruby_version, @optional_groups, @gemfiles)
unlocked_definition.resolution_mode = { "local" => !@remote }
unlocked_definition.setup_sources_for_resolve
unlocked_definition.gem_version_promoter.tap do |gvp|
gvp.level = gem_version_promoter.level
gvp.strict = gem_version_promoter.strict
Expand Down
14 changes: 14 additions & 0 deletions lib/bundler/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,18 @@ def message

status_code(38)
end

class CorruptBundlerInstallError < BundlerError
def initialize(loaded_spec)
@loaded_spec = loaded_spec
end

def message
"The running version of Bundler (#{Bundler::VERSION}) does not match the version of the specification installed for it (#{@loaded_spec.version}). " \
"This can be caused by reinstalling Ruby without removing previous installation, leaving around an upgraded default version of Bundler. " \
"Reinstalling Ruby from scratch should fix the problem."
end

status_code(39)
end
end
2 changes: 1 addition & 1 deletion lib/bundler/gem_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def install
built_gem_path = build_gem
end

desc "Generate SHA512 checksum if #{name}-#{version}.gem into the checksums directory."
desc "Generate SHA512 checksum of #{name}-#{version}.gem into the checksums directory."
task "build:checksum" => "build" do
build_checksum(built_gem_path)
end
Expand Down
16 changes: 8 additions & 8 deletions lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ def install_in_parallel(size, standalone, force = false)

# returns whether or not a re-resolve was needed
def resolve_if_needed(options)
@definition.resolution_mode = options

if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
return false if @definition.nothing_changed? && !@definition.missing_specs?
@definition.prefer_local! if options["prefer-local"]

if options["local"] || (@definition.no_resolve_needed? && !@definition.missing_specs?)
@definition.resolve_with_cache!
false
else
@definition.resolve_remotely!
true
end

@definition.setup_sources_for_resolve

true
end

def lock
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-add.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-ADD" "1" "April 2024" ""
.TH "BUNDLE\-ADD" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-binstubs.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-BINSTUBS" "1" "April 2024" ""
.TH "BUNDLE\-BINSTUBS" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-cache.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CACHE" "1" "April 2024" ""
.TH "BUNDLE\-CACHE" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-check.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CHECK" "1" "April 2024" ""
.TH "BUNDLE\-CHECK" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-clean.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CLEAN" "1" "April 2024" ""
.TH "BUNDLE\-CLEAN" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-config.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CONFIG" "1" "April 2024" ""
.TH "BUNDLE\-CONFIG" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-console.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CONSOLE" "1" "April 2024" ""
.TH "BUNDLE\-CONSOLE" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-console\fR \- Deprecated way to open an IRB session with the bundle pre\-loaded
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-doctor.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-DOCTOR" "1" "April 2024" ""
.TH "BUNDLE\-DOCTOR" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-doctor\fR \- Checks the bundle for common problems
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-exec.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-EXEC" "1" "April 2024" ""
.TH "BUNDLE\-EXEC" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-exec\fR \- Execute a command in the context of the bundle
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-gem.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-GEM" "1" "April 2024" ""
.TH "BUNDLE\-GEM" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-help.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-HELP" "1" "April 2024" ""
.TH "BUNDLE\-HELP" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-help\fR \- Displays detailed help for each subcommand
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-info.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INFO" "1" "April 2024" ""
.TH "BUNDLE\-INFO" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-info\fR \- Show information for the given gem in your bundle
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-init.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INIT" "1" "April 2024" ""
.TH "BUNDLE\-INIT" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-init\fR \- Generates a Gemfile into the current working directory
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-inject.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INJECT" "1" "April 2024" ""
.TH "BUNDLE\-INJECT" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-install.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INSTALL" "1" "April 2024" ""
.TH "BUNDLE\-INSTALL" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-install\fR \- Install the dependencies specified in your Gemfile
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-list.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-LIST" "1" "April 2024" ""
.TH "BUNDLE\-LIST" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-list\fR \- List all the gems in the bundle
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-lock.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-LOCK" "1" "April 2024" ""
.TH "BUNDLE\-LOCK" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-open.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-OPEN" "1" "April 2024" ""
.TH "BUNDLE\-OPEN" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-open\fR \- Opens the source directory for a gem in your bundle
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-outdated.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-OUTDATED" "1" "April 2024" ""
.TH "BUNDLE\-OUTDATED" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-outdated\fR \- List installed gems with newer versions available
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-platform.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-PLATFORM" "1" "April 2024" ""
.TH "BUNDLE\-PLATFORM" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-platform\fR \- Displays platform compatibility information
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-plugin.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-PLUGIN" "1" "April 2024" ""
.TH "BUNDLE\-PLUGIN" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-plugin\fR \- Manage Bundler plugins
.SH "SYNOPSIS"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-pristine.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-PRISTINE" "1" "April 2024" ""
.TH "BUNDLE\-PRISTINE" "1" "May 2024" ""
.SH "NAME"
\fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
.SH "SYNOPSIS"
Expand Down
Loading

0 comments on commit 8d95fa1

Please sign in to comment.