Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge RubyGems-3.4.10 and Bundler-2.4.10 #7479

Merged
merged 5 commits into from Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/bundler.rb
Expand Up @@ -39,8 +39,8 @@ module Bundler
environment_preserver.replace_with_backup
SUDO_MUTEX = Thread::Mutex.new

SAFE_MARSHAL_CLASSES = [Symbol, TrueClass, String, Array, Hash].freeze
SAFE_MARSHAL_ERROR = "Unexpected class %s present in marshaled data. Only %s are allowed.".freeze
SAFE_MARSHAL_CLASSES = [Symbol, TrueClass, String, Array, Hash, Gem::Version, Gem::Specification].freeze
SAFE_MARSHAL_ERROR = "Unexpected class %s present in marshaled data. Only %s are allowed."
SAFE_MARSHAL_PROC = proc do |object|
object.tap do
unless SAFE_MARSHAL_CLASSES.include?(object.class)
Expand Down Expand Up @@ -85,6 +85,7 @@ module Bundler
autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
autoload :UI, File.expand_path("bundler/ui", __dir__)
autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
autoload :URINormalizer, File.expand_path("bundler/uri_normalizer", __dir__)

class << self
def configure
Expand Down Expand Up @@ -506,7 +507,7 @@ def which(executable)
if File.file?(executable) && File.executable?(executable)
executable
elsif paths = ENV["PATH"]
quote = '"'.freeze
quote = '"'
paths.split(File::PATH_SEPARATOR).find do |path|
path = path[1..-2] if path.start_with?(quote) && path.end_with?(quote)
executable_path = File.expand_path(executable, path)
Expand All @@ -525,12 +526,6 @@ def safe_load_marshal(data)
load_marshal(data, :marshal_proc => SAFE_MARSHAL_PROC)
end

def load_marshal(data, marshal_proc: nil)
Marshal.load(data, marshal_proc)
rescue TypeError => e
raise MarshalError, "#{e.class}: #{e.message}"
end

def load_gemspec(file, validate = false)
@gemspec_cache ||= {}
key = File.expand_path(file)
Expand Down Expand Up @@ -619,6 +614,12 @@ def self_manager

private

def load_marshal(data, marshal_proc: nil)
Marshal.load(data, marshal_proc)
rescue TypeError => e
raise MarshalError, "#{e.class}: #{e.message}"
end

def eval_yaml_gemspec(path, contents)
Kernel.require "psych"

Expand Down
1 change: 1 addition & 0 deletions lib/bundler/cli.rb
Expand Up @@ -156,6 +156,7 @@ def self.handle_no_command_error(command, has_namespace = $thor_runner)
dependency listed in the gemspec file to the newly created Gemfile.
D
method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
method_option "gemfile", :type => :string, :banner => "Use the specified name for the gemfile instead of 'Gemfile'"
def init
require_relative "cli/init"
Init.new(options.dup).run
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/cli/init.rb
Expand Up @@ -32,7 +32,7 @@ def run
file << spec.to_gemfile
end
else
File.open(File.expand_path("../templates/#{gemfile}", __dir__), "r") do |template|
File.open(File.expand_path("../templates/Gemfile", __dir__), "r") do |template|
File.open(gemfile, "wb") do |destination|
IO.copy_stream(template, destination)
end
Expand All @@ -45,7 +45,7 @@ def run
private

def gemfile
@gemfile ||= Bundler.preferred_gemfile_name
@gemfile ||= options[:gemfile] || Bundler.preferred_gemfile_name
end
end
end
2 changes: 2 additions & 0 deletions lib/bundler/current_ruby.rb
Expand Up @@ -22,6 +22,8 @@ class CurrentRuby
2.7
3.0
3.1
3.2
3.3
].freeze

KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
Expand Down
6 changes: 5 additions & 1 deletion lib/bundler/definition.rb
Expand Up @@ -726,6 +726,8 @@ def converge_dependencies
dep.source = sources.get(dep.source)
end

next if unlocking?

unless locked_dep = @locked_deps[dep.name]
changes = true
next
Expand Down Expand Up @@ -886,8 +888,9 @@ def lockfiles_equal?(current, proposed, preserve_unknown_sections)
end

def additional_base_requirements_for_resolve(resolution_packages, last_resolve)
return resolution_packages unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
return resolution_packages unless @locked_gems && !sources.expired_sources?(@locked_gems.sources)
converge_specs(@originally_locked_specs - last_resolve).each do |locked_spec|
next if locked_spec.source.is_a?(Source::Path)
resolution_packages.base_requirements[locked_spec.name] = Gem::Requirement.new(">= #{locked_spec.version}")
end
resolution_packages
Expand All @@ -898,6 +901,7 @@ def remove_ruby_from_platforms_if_necessary!(dependencies)
Bundler.local_platform == Gem::Platform::RUBY ||
!platforms.include?(Gem::Platform::RUBY) ||
(@new_platform && platforms.last == Gem::Platform::RUBY) ||
@dependency_changes ||
!@originally_locked_specs.incomplete_ruby_specs?(dependencies)

remove_platform(Gem::Platform::RUBY)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/dependency.rb
Expand Up @@ -9,7 +9,7 @@ class Dependency < Gem::Dependency
attr_reader :autorequire
attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref

ALL_RUBY_VERSIONS = ((18..27).to_a + (30..31).to_a).freeze
ALL_RUBY_VERSIONS = ((18..27).to_a + (30..33).to_a).freeze
PLATFORM_MAP = {
:ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
:mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
Expand Down
4 changes: 0 additions & 4 deletions lib/bundler/endpoint_specification.rb
Expand Up @@ -26,10 +26,6 @@ def fetch_platform
@platform
end

def identifier
@__identifier ||= [name, version, platform.to_s]
end

# needed for standalone, load required_paths from local gemspec
# after the gem is installed
def require_paths
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/environment_preserver.rb
Expand Up @@ -2,7 +2,7 @@

module Bundler
class EnvironmentPreserver
INTENTIONALLY_NIL = "BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL".freeze
INTENTIONALLY_NIL = "BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL"
BUNDLER_KEYS = %w[
BUNDLE_BIN_PATH
BUNDLE_GEMFILE
Expand All @@ -16,7 +16,7 @@ class EnvironmentPreserver
RUBYLIB
RUBYOPT
].map(&:freeze).freeze
BUNDLER_PREFIX = "BUNDLER_ORIG_".freeze
BUNDLER_PREFIX = "BUNDLER_ORIG_"

def self.from_env
new(env_to_hash(ENV), BUNDLER_KEYS)
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/fetcher.rb
Expand Up @@ -102,11 +102,11 @@ def fetch_spec(spec)
uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
if uri.scheme == "file"
path = Bundler.rubygems.correct_for_windows_path(uri.path)
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
Bundler.safe_load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)
else
Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
Bundler.safe_load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
end
rescue MarshalError
raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
Expand Down
6 changes: 1 addition & 5 deletions lib/bundler/fetcher/dependency.rb
Expand Up @@ -34,14 +34,10 @@ def specs(gem_names, full_dependency_list = [], last_spec_list = [])

returned_gems = spec_list.map(&:first).uniq
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
rescue MarshalError
rescue MarshalError, HTTPError, GemspecError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
nil
rescue HTTPError, GemspecError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
nil
end

def dependency_specs(gem_names)
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/index.rb
Expand Up @@ -13,8 +13,8 @@ def self.build
attr_reader :specs, :all_specs, :sources
protected :specs, :all_specs

RUBY = "ruby".freeze
NULL = "\0".freeze
RUBY = "ruby"
NULL = "\0"

def initialize
@sources = []
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/injector.rb
Expand Up @@ -2,7 +2,7 @@

module Bundler
class Injector
INJECTED_GEMS = "injected gems".freeze
INJECTED_GEMS = "injected gems"

def self.inject(new_deps, options = {})
injector = new(new_deps, options)
Expand Down
5 changes: 3 additions & 2 deletions lib/bundler/installer/parallel_installer.rb
Expand Up @@ -110,12 +110,13 @@ def check_for_unmet_dependencies

warning = []
warning << "Your lockfile doesn't include a valid resolution."
warning << "You can fix this by regenerating your lockfile or trying to manually editing the bad locked gems to a version that satisfies all dependencies."
warning << "You can fix this by regenerating your lockfile or manually editing the bad locked gems to a version that satisfies all dependencies."
warning << "The unmet dependencies are:"

unmet_dependencies.each do |spec, unmet_spec_dependencies|
unmet_spec_dependencies.each do |unmet_spec_dependency|
warning << "* #{unmet_spec_dependency}, depended upon #{spec.full_name}, unsatisfied by #{@specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }.full_name}"
found = @specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }
warning << "* #{unmet_spec_dependency}, dependency of #{spec.full_name}, unsatisfied by #{found.full_name}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/installer/standalone.rb
Expand Up @@ -52,7 +52,7 @@ def bundler_path

def gem_path(path, spec)
full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
if spec.source.instance_of?(Source::Path)
if spec.source.instance_of?(Source::Path) && spec.source.path.absolute?
full_path
else
Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
Expand Down
12 changes: 4 additions & 8 deletions lib/bundler/lazy_specification.rb
Expand Up @@ -20,23 +20,23 @@ def initialize(name, version, platform, source = nil)
end

def full_name
if platform == Gem::Platform::RUBY
@full_name ||= if platform == Gem::Platform::RUBY
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{platform}"
end
end

def ==(other)
identifier == other.identifier
full_name == other.full_name
end

def eql?(other)
identifier.eql?(other.identifier)
full_name.eql?(other.full_name)
end

def hash
identifier.hash
full_name.hash
end

##
Expand Down Expand Up @@ -129,10 +129,6 @@ def to_s
end
end

def identifier
@__identifier ||= [name, version, platform.to_s]
end

def git_version
return unless source.is_a?(Bundler::Source::Git)
" #{source.revision[0..6]}"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/lockfile_generator.rb
Expand Up @@ -45,7 +45,7 @@ def add_specs(specs)
# gems with the same name, but different platform
# are ordered consistently
specs.sort_by(&:full_name).each do |spec|
next if spec.name == "bundler".freeze
next if spec.name == "bundler"
out << spec.to_lock
end
end
Expand Down
22 changes: 11 additions & 11 deletions lib/bundler/lockfile_parser.rb
Expand Up @@ -4,15 +4,15 @@ module Bundler
class LockfileParser
attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version

BUNDLED = "BUNDLED WITH".freeze
DEPENDENCIES = "DEPENDENCIES".freeze
PLATFORMS = "PLATFORMS".freeze
RUBY = "RUBY VERSION".freeze
GIT = "GIT".freeze
GEM = "GEM".freeze
PATH = "PATH".freeze
PLUGIN = "PLUGIN SOURCE".freeze
SPECS = " specs:".freeze
BUNDLED = "BUNDLED WITH"
DEPENDENCIES = "DEPENDENCIES"
PLATFORMS = "PLATFORMS"
RUBY = "RUBY VERSION"
GIT = "GIT"
GEM = "GEM"
PATH = "PATH"
PLUGIN = "PLUGIN SOURCE"
SPECS = " specs:"
OPTIONS = /^ ([a-z]+): (.*)$/i.freeze
SOURCE = [GIT, GEM, PATH, PLUGIN].freeze

Expand Down Expand Up @@ -86,7 +86,7 @@ def initialize(lockfile)
send("parse_#{@state}", line)
end
end
@specs = @specs.values.sort_by(&:identifier)
@specs = @specs.values.sort_by(&:full_name)
rescue ArgumentError => e
Bundler.ui.debug(e)
raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
Expand Down Expand Up @@ -199,7 +199,7 @@ def parse_spec(line)
@current_spec.source = @current_source
@current_source.add_dependency_names(name)

@specs[@current_spec.identifier] = @current_spec
@specs[@current_spec.full_name] = @current_spec
elsif spaces.size == 6
version = version.split(",").map(&:strip) if version
dep = Gem::Dependency.new(name, version)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-add.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-ADD" "1" "January 2023" "" ""
.TH "BUNDLE\-ADD" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-binstubs.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-BINSTUBS" "1" "January 2023" "" ""
.TH "BUNDLE\-BINSTUBS" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-cache.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-CACHE" "1" "January 2023" "" ""
.TH "BUNDLE\-CACHE" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-check.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-CHECK" "1" "January 2023" "" ""
.TH "BUNDLE\-CHECK" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-clean.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-CLEAN" "1" "January 2023" "" ""
.TH "BUNDLE\-CLEAN" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-config.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-CONFIG" "1" "January 2023" "" ""
.TH "BUNDLE\-CONFIG" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-console.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-CONSOLE" "1" "January 2023" "" ""
.TH "BUNDLE\-CONSOLE" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-console\fR \- Deprecated way to open an IRB session with the bundle pre\-loaded
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-doctor.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BUNDLE\-DOCTOR" "1" "January 2023" "" ""
.TH "BUNDLE\-DOCTOR" "1" "February 2023" "" ""
.
.SH "NAME"
\fBbundle\-doctor\fR \- Checks the bundle for common problems
Expand Down