Merge RubyGems-3.3.14 and Bundler-2.3.14

This commit is contained in:
Hiroshi SHIBATA 2022-07-13 14:36:57 +09:00 committed by nagachika
parent ffd3d83ea8
commit d7862a5de4
76 changed files with 245 additions and 153 deletions

View file

@ -19,7 +19,7 @@ require_relative "bundler/build_metadata"
# #
# Since Ruby 2.6, Bundler is a part of Ruby's standard library. # Since Ruby 2.6, Bundler is a part of Ruby's standard library.
# #
# Bunder is used by creating _gemfiles_ listing all the project dependencies # Bundler is used by creating _gemfiles_ listing all the project dependencies
# and (optionally) their versions and then using # and (optionally) their versions and then using
# #
# require 'bundler/setup' # require 'bundler/setup'

View file

@ -40,7 +40,7 @@ module Bundler
end end
def self.verbalize_groups(groups) def self.verbalize_groups(groups)
groups.map!{|g| "'#{g}'" } groups.map! {|g| "'#{g}'" }
group_list = [groups[0...-1].join(", "), groups[-1..-1]]. group_list = [groups[0...-1].join(", "), groups[-1..-1]].
reject {|s| s.to_s.empty? }.join(" and ") reject {|s| s.to_s.empty? }.join(" and ")
group_str = groups.size == 1 ? "group" : "groups" group_str = groups.size == 1 ? "group" : "groups"

View file

@ -261,7 +261,7 @@ module Bundler
@locked_specs @locked_specs
elsif !unlocking? && nothing_changed? elsif !unlocking? && nothing_changed?
Bundler.ui.debug("Found no changes, using resolution from the lockfile") Bundler.ui.debug("Found no changes, using resolution from the lockfile")
SpecSet.new(filter_specs(@locked_specs, @dependencies.select{|dep| @locked_specs[dep].any? })) SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
else else
last_resolve = converge_locked_specs last_resolve = converge_locked_specs
# Run a resolve against the locally available gems # Run a resolve against the locally available gems
@ -731,7 +731,7 @@ module Bundler
end end
end end
SpecSet.new(filter_specs(converged, deps).reject{|s| @unlock[:gems].include?(s.name) }) SpecSet.new(filter_specs(converged, deps).reject {|s| @unlock[:gems].include?(s.name) })
end end
def metadata_dependencies def metadata_dependencies

View file

@ -46,7 +46,7 @@ module Bundler
@gemfile = expanded_gemfile_path @gemfile = expanded_gemfile_path
@gemfiles << expanded_gemfile_path @gemfiles << expanded_gemfile_path
contents ||= Bundler.read_file(@gemfile.to_s) contents ||= Bundler.read_file(@gemfile.to_s)
instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1) instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
message = "There was an error " \ message = "There was an error " \
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \ "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \

View file

@ -48,7 +48,7 @@ module Bundler
sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) } sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
exemplary_spec = sorted_matching.first exemplary_spec = sorted_matching.first
sorted_matching.take_while{|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) } sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
end end
module_function :select_best_platform_match module_function :select_best_platform_match

View file

@ -13,7 +13,7 @@ module Bundler
Installer.ambiguous_gems = [] Installer.ambiguous_gems = []
end end
attr_reader :post_install_messages attr_reader :post_install_messages, :definition
# Begins the installation process for Bundler. # Begins the installation process for Bundler.
# For more information see the #run method on this class. # For more information see the #run method on this class.

View file

@ -51,7 +51,20 @@ module Bundler
end end
def install def install
spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => Array(spec_settings)) spec.source.install(
spec,
:force => force,
:ensure_builtin_gems_cached => standalone,
:build_args => Array(spec_settings),
:previous_spec => previous_spec,
)
end
def previous_spec
locked_gems = installer.definition.locked_gems
return unless locked_gems
locked_gems.specs.find {|s| s.name == spec.name }
end end
def out_of_space_message def out_of_space_message

View file

@ -94,7 +94,7 @@ module Bundler
(spec.required_ruby_version.satisfied_by?(Gem.ruby_version) && (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version)) spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
end end
search = installable_candidates.last search = installable_candidates.last || same_platform_candidates.last
search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification)) search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
search search
end end

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-ADD" "1" "March 2022" "" "" .TH "BUNDLE\-ADD" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
@ -45,6 +45,10 @@ Specify the group(s) for the added gem\. Multiple groups should be separated by
Specify the source for the added gem\. Specify the source for the added gem\.
. .
.TP .TP
\fB\-\-require\fR, \fB\-r\fR
Adds require path to gem\. Provide false, or a path as a string\.
.
.TP
\fB\-\-git\fR \fB\-\-git\fR
Specify the git source for the added gem\. Specify the git source for the added gem\.
. .
@ -66,9 +70,9 @@ Adds the gem to the Gemfile but does not install it\.
. .
.TP .TP
\fB\-\-optimistic\fR \fB\-\-optimistic\fR
Adds optimistic declaration of version Adds optimistic declaration of version\.
. .
.TP .TP
\fB\-\-strict\fR \fB\-\-strict\fR
Adds strict declaration of version Adds strict declaration of version\.

View file

@ -30,6 +30,9 @@ bundle add rails --group "development, test"
* `--source`, , `-s`: * `--source`, , `-s`:
Specify the source for the added gem. Specify the source for the added gem.
* `--require`, `-r`:
Adds require path to gem. Provide false, or a path as a string.
* `--git`: * `--git`:
Specify the git source for the added gem. Specify the git source for the added gem.
@ -46,7 +49,7 @@ bundle add rails --group "development, test"
Adds the gem to the Gemfile but does not install it. Adds the gem to the Gemfile but does not install it.
* `--optimistic`: * `--optimistic`:
Adds optimistic declaration of version Adds optimistic declaration of version.
* `--strict`: * `--strict`:
Adds strict declaration of version Adds strict declaration of version.

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-BINSTUBS" "1" "March 2022" "" "" .TH "BUNDLE\-BINSTUBS" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems \fBbundle\-binstubs\fR \- Install the binstubs of the listed gems

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-CACHE" "1" "March 2022" "" "" .TH "BUNDLE\-CACHE" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application \fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-CHECK" "1" "March 2022" "" "" .TH "BUNDLE\-CHECK" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems \fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-CLEAN" "1" "March 2022" "" "" .TH "BUNDLE\-CLEAN" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory \fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-CONFIG" "1" "March 2022" "" "" .TH "BUNDLE\-CONFIG" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options \fBbundle\-config\fR \- Set bundler configuration options

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-DOCTOR" "1" "March 2022" "" "" .TH "BUNDLE\-DOCTOR" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-doctor\fR \- Checks the bundle for common problems \fBbundle\-doctor\fR \- Checks the bundle for common problems

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-EXEC" "1" "March 2022" "" "" .TH "BUNDLE\-EXEC" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-exec\fR \- Execute a command in the context of the bundle \fBbundle\-exec\fR \- Execute a command in the context of the bundle

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-GEM" "1" "March 2022" "" "" .TH "BUNDLE\-GEM" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem \fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-INFO" "1" "March 2022" "" "" .TH "BUNDLE\-INFO" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-info\fR \- Show information for the given gem in your bundle \fBbundle\-info\fR \- Show information for the given gem in your bundle

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-INIT" "1" "March 2022" "" "" .TH "BUNDLE\-INIT" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-init\fR \- Generates a Gemfile into the current working directory \fBbundle\-init\fR \- Generates a Gemfile into the current working directory

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-INJECT" "1" "March 2022" "" "" .TH "BUNDLE\-INJECT" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile \fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-INSTALL" "1" "March 2022" "" "" .TH "BUNDLE\-INSTALL" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-install\fR \- Install the dependencies specified in your Gemfile \fBbundle\-install\fR \- Install the dependencies specified in your Gemfile

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-LIST" "1" "March 2022" "" "" .TH "BUNDLE\-LIST" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-list\fR \- List all the gems in the bundle \fBbundle\-list\fR \- List all the gems in the bundle

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-LOCK" "1" "March 2022" "" "" .TH "BUNDLE\-LOCK" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing \fBbundle\-lock\fR \- Creates / Updates a lockfile without installing

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-OPEN" "1" "March 2022" "" "" .TH "BUNDLE\-OPEN" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-open\fR \- Opens the source directory for a gem in your bundle \fBbundle\-open\fR \- Opens the source directory for a gem in your bundle

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-OUTDATED" "1" "March 2022" "" "" .TH "BUNDLE\-OUTDATED" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-outdated\fR \- List installed gems with newer versions available \fBbundle\-outdated\fR \- List installed gems with newer versions available

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-PLATFORM" "1" "March 2022" "" "" .TH "BUNDLE\-PLATFORM" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-platform\fR \- Displays platform compatibility information \fBbundle\-platform\fR \- Displays platform compatibility information

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-PRISTINE" "1" "March 2022" "" "" .TH "BUNDLE\-PRISTINE" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-pristine\fR \- Restores installed gems to their pristine condition \fBbundle\-pristine\fR \- Restores installed gems to their pristine condition

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-REMOVE" "1" "March 2022" "" "" .TH "BUNDLE\-REMOVE" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-remove\fR \- Removes gems from the Gemfile \fBbundle\-remove\fR \- Removes gems from the Gemfile

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-SHOW" "1" "March 2022" "" "" .TH "BUNDLE\-SHOW" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem \fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-UPDATE" "1" "March 2022" "" "" .TH "BUNDLE\-UPDATE" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-update\fR \- Update your gems to the latest available versions \fBbundle\-update\fR \- Update your gems to the latest available versions

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE\-VIZ" "1" "March 2022" "" "" .TH "BUNDLE\-VIZ" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile \fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE" "1" "March 2022" "" "" .TH "BUNDLE" "1" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\fR \- Ruby Dependency Management \fBbundle\fR \- Ruby Dependency Management

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "GEMFILE" "5" "March 2022" "" "" .TH "GEMFILE" "5" "May 2022" "" ""
. .
.SH "NAME" .SH "NAME"
\fBGemfile\fR \- A format for describing gem dependencies for Ruby programs \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs

View file

@ -20,10 +20,6 @@ module Bundler
end end
end end
def version_message(spec)
"#{spec.name} #{spec.version}"
end
def root def root
Plugin.root Plugin.root
end end

View file

@ -4,10 +4,6 @@ module Bundler
module Plugin module Plugin
class Installer class Installer
class Rubygems < Bundler::Source::Rubygems class Rubygems < Bundler::Source::Rubygems
def version_message(spec)
"#{spec.name} #{spec.version}"
end
private private
def requires_sudo? def requires_sudo?

View file

@ -21,7 +21,7 @@ module Bundler
base = SpecSet.new(base) unless base.is_a?(SpecSet) base = SpecSet.new(base) unless base.is_a?(SpecSet)
resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms) resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
result = resolver.start(requirements) result = resolver.start(requirements)
SpecSet.new(SpecSet.new(result).for(requirements.reject{|dep| dep.name.end_with?("\0") })) SpecSet.new(SpecSet.new(result).for(requirements.reject {|dep| dep.name.end_with?("\0") }))
end end
def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms) def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)

View file

@ -34,7 +34,7 @@ module Gem
def full_gem_path def full_gem_path
if source.respond_to?(:root) if source.respond_to?(:root)
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" } Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
else else
rg_full_gem_path rg_full_gem_path
end end

View file

@ -13,13 +13,13 @@ module Bundler
def root def root
gemfile = find_gemfile gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
end end
def default_gemfile def default_gemfile
gemfile = find_gemfile gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
end end
def default_lockfile def default_lockfile
@ -28,7 +28,7 @@ module Bundler
case gemfile.basename.to_s case gemfile.basename.to_s
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked")) when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
else Pathname.new("#{gemfile}.lock") else Pathname.new("#{gemfile}.lock")
end.tap{|x| x.untaint if RUBY_VERSION < "2.7" } end.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
end end
def default_bundle_dir def default_bundle_dir
@ -100,7 +100,7 @@ module Bundler
# #
# @see {Bundler::PermissionError} # @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block) def filesystem_access(path, action = :write, &block)
yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }) yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" })
rescue Errno::EACCES rescue Errno::EACCES
raise PermissionError.new(path, action) raise PermissionError.new(path, action)
rescue Errno::EAGAIN rescue Errno::EAGAIN
@ -236,7 +236,7 @@ module Bundler
def search_up(*names) def search_up(*names)
previous = nil previous = nil
current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" } current = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" }
until !File.directory?(current) || current == previous until !File.directory?(current) || current == previous
if ENV["BUNDLER_SPEC_RUN"] if ENV["BUNDLER_SPEC_RUN"]

View file

@ -15,13 +15,12 @@ module Bundler
specs.unmet_dependency_names specs.unmet_dependency_names
end end
def version_message(spec) def version_message(spec, locked_spec = nil)
message = "#{spec.name} #{spec.version}" message = "#{spec.name} #{spec.version}"
message += " (#{spec.platform})" if spec.platform != Gem::Platform::RUBY && !spec.platform.nil? message += " (#{spec.platform})" if spec.platform != Gem::Platform::RUBY && !spec.platform.nil?
if Bundler.locked_gems if locked_spec
locked_spec = Bundler.locked_gems.specs.find {|s| s.name == spec.name } locked_spec_version = locked_spec.version
locked_spec_version = locked_spec.version if locked_spec
if locked_spec_version && spec.version != locked_spec_version if locked_spec_version && spec.version != locked_spec_version
message += Bundler.ui.add_color(" (was #{locked_spec_version})", version_color(spec.version, locked_spec_version)) message += Bundler.ui.add_color(" (was #{locked_spec_version})", version_color(spec.version, locked_spec_version))
end end

View file

@ -181,7 +181,7 @@ module Bundler
def install(spec, options = {}) def install(spec, options = {})
force = options[:force] force = options[:force]
print_using_message "Using #{version_message(spec)} from #{self}" print_using_message "Using #{version_message(spec, options[:previous_spec])} from #{self}"
if (requires_checkout? && !@copied) || force if (requires_checkout? && !@copied) || force
Bundler.ui.debug " * Checking out revision: #{ref}" Bundler.ui.debug " * Checking out revision: #{ref}"
@ -336,7 +336,7 @@ module Bundler
def load_gemspec(file) def load_gemspec(file)
stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent) stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" } stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
StubSpecification.from_stub(stub) StubSpecification.from_stub(stub)
end end

View file

@ -82,7 +82,7 @@ module Bundler
end end
def install(spec, options = {}) def install(spec, options = {})
using_message = "Using #{version_message(spec)} from #{self}" using_message = "Using #{version_message(spec, options[:previous_spec])} from #{self}"
using_message += " and installing its executables" unless spec.executables.empty? using_message += " and installing its executables" unless spec.executables.empty?
print_using_message using_message print_using_message using_message
generate_bin(spec, :disable_extensions => true) generate_bin(spec, :disable_extensions => true)

View file

@ -135,9 +135,9 @@ module Bundler
end end
end end
def install(spec, opts = {}) def install(spec, options = {})
force = opts[:force] force = options[:force]
ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached] ensure_builtin_gems_cached = options[:ensure_builtin_gems_cached]
if ensure_builtin_gems_cached && spec.default_gem? if ensure_builtin_gems_cached && spec.default_gem?
if !cached_path(spec) if !cached_path(spec)
@ -162,7 +162,7 @@ module Bundler
uris.uniq! uris.uniq!
Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1 Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
path = fetch_gem(spec) path = fetch_gem(spec, options[:previous_spec])
begin begin
s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"]) s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
spec.__swap__(s) spec.__swap__(s)
@ -173,7 +173,7 @@ module Bundler
end end
unless Bundler.settings[:no_install] unless Bundler.settings[:no_install]
message = "Installing #{version_message(spec)}" message = "Installing #{version_message(spec, options[:previous_spec])}"
message += " with native extensions" if spec.extensions.any? message += " with native extensions" if spec.extensions.any?
Bundler.ui.confirm message Bundler.ui.confirm message
@ -198,7 +198,7 @@ module Bundler
:ignore_dependencies => true, :ignore_dependencies => true,
:wrappers => true, :wrappers => true,
:env_shebang => true, :env_shebang => true,
:build_args => opts[:build_args], :build_args => options[:build_args],
:bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum, :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
:bundler_extension_cache_path => extension_cache_path(spec) :bundler_extension_cache_path => extension_cache_path(spec)
).install ).install
@ -458,7 +458,7 @@ module Bundler
end end
end end
def fetch_gem(spec) def fetch_gem(spec, previous_spec = nil)
return false unless spec.remote return false unless spec.remote
spec.fetch_platform spec.fetch_platform
@ -476,7 +476,7 @@ module Bundler
SharedHelpers.filesystem_access(download_cache_path) do |p| SharedHelpers.filesystem_access(download_cache_path) do |p|
FileUtils.mkdir_p(p) FileUtils.mkdir_p(p)
end end
download_gem(spec, download_cache_path) download_gem(spec, download_cache_path, previous_spec)
if requires_sudo? if requires_sudo?
SharedHelpers.filesystem_access(cache_path) do |p| SharedHelpers.filesystem_access(cache_path) do |p|
@ -521,9 +521,12 @@ module Bundler
# @param [String] download_cache_path # @param [String] download_cache_path
# the local directory the .gem will end up in. # the local directory the .gem will end up in.
# #
def download_gem(spec, download_cache_path) # @param [Specification] previous_spec
# the spec previously locked
#
def download_gem(spec, download_cache_path, previous_spec = nil)
uri = spec.remote.uri uri = spec.remote.uri
Bundler.ui.confirm("Fetching #{version_message(spec)}") Bundler.ui.confirm("Fetching #{version_message(spec, previous_spec)}")
Bundler.rubygems.download_gem(spec, uri, download_cache_path) Bundler.rubygems.download_gem(spec, uri, download_cache_path)
end end

View file

@ -18,13 +18,13 @@ module Bundler
loop do loop do
break unless dep = deps.shift break unless dep = deps.shift
next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler" next if handled.any? {|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
handled << dep handled << dep
specs_for_dep = spec_for_dependency(dep, match_current_platform) specs_for_dep = spec_for_dependency(dep, match_current_platform)
if specs_for_dep.any? if specs_for_dep.any?
match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep specs.concat(specs_for_dep)
specs_for_dep.first.dependencies.each do |d| specs_for_dep.first.dependencies.each do |d|
next if d.type == :development next if d.type == :development
@ -40,6 +40,8 @@ module Bundler
specs << spec specs << spec
end end
specs.uniq! unless match_current_platform
check ? true : specs check ? true : specs
end end
@ -172,7 +174,7 @@ module Bundler
def spec_for_dependency(dep, match_current_platform) def spec_for_dependency(dep, match_current_platform)
specs_for_platforms = lookup[dep.name] specs_for_platforms = lookup[dep.name]
if match_current_platform if match_current_platform
GemHelpers.select_best_platform_match(specs_for_platforms.select{|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform) GemHelpers.select_best_platform_match(specs_for_platforms.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
else else
GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform) GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
end end

View file

@ -1,7 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
module Bundler module Bundler
VERSION = "2.3.13".freeze VERSION = "2.3.14".freeze
def self.bundler_major_version def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i @bundler_major_version ||= VERSION.split(".").first.to_i

View file

@ -8,7 +8,7 @@
require 'rbconfig' require 'rbconfig'
module Gem module Gem
VERSION = "3.3.13".freeze VERSION = "3.3.14".freeze
end end
# Must be first since it unloads the prelude from 1.9.2 # Must be first since it unloads the prelude from 1.9.2
@ -117,7 +117,7 @@ module Gem
# Taint support is deprecated in Ruby 2.7. # Taint support is deprecated in Ruby 2.7.
# This allows switching ".untaint" to ".tap(&Gem::UNTAINT)", # This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",
# to avoid deprecation warnings in Ruby 2.7. # to avoid deprecation warnings in Ruby 2.7.
UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc{} UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc {}
# When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn # When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn
KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" || KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" ||

View file

@ -113,7 +113,7 @@ extensions will be restored.
end.flatten end.flatten
end end
specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY } specs = specs.select {|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
if specs.to_a.empty? if specs.to_a.empty?
raise Gem::Exception, raise Gem::Exception,

View file

@ -475,7 +475,7 @@ By default, this RubyGems will install gem as:
def files_in(dir) def files_in(dir)
Dir.chdir dir do Dir.chdir dir do
Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH). Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH).
select{|f| !File.directory?(f) } select {|f| !File.directory?(f) }
end end
end end

View file

@ -129,7 +129,7 @@ Specific fields in the specification can be extracted in YAML format:
platform = get_platform_from_requirements(options) platform = get_platform_from_requirements(options)
if platform if platform
specs = specs.select{|s| s.platform.to_s == platform } specs = specs.select {|s| s.platform.to_s == platform }
end end
unless options[:all] unless options[:all]

View file

@ -725,11 +725,11 @@ class Gem::Installer
raise Gem::InstallError, "#{spec} has an invalid name" raise Gem::InstallError, "#{spec} has an invalid name"
end end
if spec.raw_require_paths.any?{|path| path =~ /\R/ } if spec.raw_require_paths.any? {|path| path =~ /\R/ }
raise Gem::InstallError, "#{spec} has an invalid require_paths" raise Gem::InstallError, "#{spec} has an invalid require_paths"
end end
if spec.extensions.any?{|ext| ext =~ /\R/ } if spec.extensions.any? {|ext| ext =~ /\R/ }
raise Gem::InstallError, "#{spec} has an invalid extensions" raise Gem::InstallError, "#{spec} has an invalid extensions"
end end

View file

@ -26,7 +26,7 @@ module Gem::LocalRemoteOptions
valid_uri_schemes = ["http", "https", "file", "s3"] valid_uri_schemes = ["http", "https", "file", "s3"]
unless valid_uri_schemes.include?(uri.scheme) unless valid_uri_schemes.include?(uri.scheme)
msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map{|s| "#{s}://" }}" msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map {|s| "#{s}://" }}"
raise ArgumentError, msg raise ArgumentError, msg
end end

View file

@ -61,7 +61,7 @@ module Gem::QueryUtils
gem_names = if args.empty? gem_names = if args.empty?
[options[:name]] [options[:name]]
else else
options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i } options[:exact] ? args.map {|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map {|arg| /#{arg}/i }
end end
terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems? terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems?

View file

@ -91,8 +91,8 @@ class Gem::SpecFetcher
list.each do |source, specs| list.each do |source, specs|
if dependency.name.is_a?(String) && specs.respond_to?(:bsearch) if dependency.name.is_a?(String) && specs.respond_to?(:bsearch)
start_index = (0 ... specs.length).bsearch{|i| specs[i].name >= dependency.name } start_index = (0 ... specs.length).bsearch {|i| specs[i].name >= dependency.name }
end_index = (0 ... specs.length).bsearch{|i| specs[i].name > dependency.name } end_index = (0 ... specs.length).bsearch {|i| specs[i].name > dependency.name }
specs = specs[start_index ... end_index] if start_index && end_index specs = specs[start_index ... end_index] if start_index && end_index
end end

View file

@ -1110,7 +1110,7 @@ class Gem::Specification < Gem::BasicSpecification
result[spec.name] = spec result[spec.name] = spec
end end
result.map(&:last).flatten.sort_by{|tup| tup.name } result.map(&:last).flatten.sort_by {|tup| tup.name }
end end
## ##

View file

@ -3,7 +3,8 @@
require "bundler/installer/gem_installer" require "bundler/installer/gem_installer"
RSpec.describe Bundler::GemInstaller do RSpec.describe Bundler::GemInstaller do
let(:installer) { instance_double("Installer") } let(:definition) { instance_double("Definition", :locked_gems => nil) }
let(:installer) { instance_double("Installer", :definition => definition) }
let(:spec_source) { instance_double("SpecSource") } let(:spec_source) { instance_double("SpecSource") }
let(:spec) { instance_double("Specification", :name => "dummy", :version => "0.0.1", :loaded_from => "dummy", :source => spec_source) } let(:spec) { instance_double("Specification", :name => "dummy", :version => "0.0.1", :loaded_from => "dummy", :source => spec_source) }
@ -11,7 +12,7 @@ RSpec.describe Bundler::GemInstaller do
context "spec_settings is nil" do context "spec_settings is nil" do
it "invokes install method with empty build_args" do it "invokes install method with empty build_args" do
allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => []) allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => [], :previous_spec => nil)
subject.install_from_spec subject.install_from_spec
end end
end end
@ -22,7 +23,7 @@ RSpec.describe Bundler::GemInstaller do
allow(Bundler.settings).to receive(:[]).with(:inline) allow(Bundler.settings).to receive(:[]).with(:inline)
allow(Bundler.settings).to receive(:[]).with(:forget_cli_options) allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy") allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy")
expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy"]) expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy"], :previous_spec => nil)
subject.install_from_spec subject.install_from_spec
end end
end end
@ -33,7 +34,13 @@ RSpec.describe Bundler::GemInstaller do
allow(Bundler.settings).to receive(:[]).with(:inline) allow(Bundler.settings).to receive(:[]).with(:inline)
allow(Bundler.settings).to receive(:[]).with(:forget_cli_options) allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy --with-another-dummy-config") allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy --with-another-dummy-config")
expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy", "--with-another-dummy-config"]) expect(spec_source).to receive(:install).with(
spec,
:force => false,
:ensure_builtin_gems_cached => false,
:build_args => ["--with-dummy-config=dummy", "--with-another-dummy-config"],
:previous_spec => nil
)
subject.install_from_spec subject.install_from_spec
end end
end end

View file

@ -30,17 +30,7 @@ RSpec.describe Bundler::Source do
end end
context "when there are locked gems" do context "when there are locked gems" do
let(:locked_gems) { double(:locked_gems) }
before { allow(Bundler).to receive(:locked_gems).and_return(locked_gems) }
context "that contain the relevant gem spec" do context "that contain the relevant gem spec" do
before do
specs = double(:specs)
allow(locked_gems).to receive(:specs).and_return(specs)
allow(specs).to receive(:find).and_return(locked_gem)
end
context "without a version" do context "without a version" do
let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => nil) } let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => nil) }
@ -62,7 +52,7 @@ RSpec.describe Bundler::Source do
end end
it "should return a string with the spec name and version and locked spec version" do it "should return a string with the spec name and version and locked spec version" do
expect(subject.version_message(spec)).to eq("nokogiri >= 1.6\e[32m (was < 1.5)\e[0m") expect(subject.version_message(spec, locked_gem)).to eq("nokogiri >= 1.6\e[32m (was < 1.5)\e[0m")
end end
end end
@ -74,7 +64,7 @@ RSpec.describe Bundler::Source do
end end
it "should return a string with the spec name and version and locked spec version" do it "should return a string with the spec name and version and locked spec version" do
expect(subject.version_message(spec)).to eq("nokogiri >= 1.6 (was < 1.5)") expect(subject.version_message(spec, locked_gem)).to eq("nokogiri >= 1.6 (was < 1.5)")
end end
end end
end end
@ -89,7 +79,7 @@ RSpec.describe Bundler::Source do
end end
it "should return a string with the locked spec version in yellow" do it "should return a string with the locked spec version in yellow" do
expect(subject.version_message(spec)).to eq("nokogiri 1.6.1\e[33m (was 1.7.0)\e[0m") expect(subject.version_message(spec, locked_gem)).to eq("nokogiri 1.6.1\e[33m (was 1.7.0)\e[0m")
end end
end end
@ -101,7 +91,7 @@ RSpec.describe Bundler::Source do
end end
it "should return a string with the locked spec version in yellow" do it "should return a string with the locked spec version in yellow" do
expect(subject.version_message(spec)).to eq("nokogiri 1.6.1 (was 1.7.0)") expect(subject.version_message(spec, locked_gem)).to eq("nokogiri 1.6.1 (was 1.7.0)")
end end
end end
end end
@ -116,7 +106,7 @@ RSpec.describe Bundler::Source do
end end
it "should return a string with the locked spec version in green" do it "should return a string with the locked spec version in green" do
expect(subject.version_message(spec)).to eq("nokogiri 1.7.1\e[32m (was 1.7.0)\e[0m") expect(subject.version_message(spec, locked_gem)).to eq("nokogiri 1.7.1\e[32m (was 1.7.0)\e[0m")
end end
end end
@ -128,27 +118,11 @@ RSpec.describe Bundler::Source do
end end
it "should return a string with the locked spec version in yellow" do it "should return a string with the locked spec version in yellow" do
expect(subject.version_message(spec)).to eq("nokogiri 1.7.1 (was 1.7.0)") expect(subject.version_message(spec, locked_gem)).to eq("nokogiri 1.7.1 (was 1.7.0)")
end end
end end
end end
end end
context "that do not contain the relevant gem spec" do
before do
specs = double(:specs)
allow(locked_gems).to receive(:specs).and_return(specs)
allow(specs).to receive(:find).and_return(nil)
end
it_behaves_like "the lockfile specs are not relevant"
end
end
context "when there are no locked gems" do
before { allow(Bundler).to receive(:locked_gems).and_return(nil) }
it_behaves_like "the lockfile specs are not relevant"
end end
end end

View file

@ -493,27 +493,25 @@ RSpec.describe "bundle lock" do
end end
it "does not conflict on ruby requirements when adding new platforms" do it "does not conflict on ruby requirements when adding new platforms" do
next_minor = Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".")
build_repo4 do build_repo4 do
build_gem "raygun-apm", "1.0.78" do |s| build_gem "raygun-apm", "1.0.78" do |s|
s.platform = "x86_64-linux" s.platform = "x86_64-linux"
s.required_ruby_version = "< #{next_minor}.dev" s.required_ruby_version = "< #{next_ruby_minor}.dev"
end end
build_gem "raygun-apm", "1.0.78" do |s| build_gem "raygun-apm", "1.0.78" do |s|
s.platform = "universal-darwin" s.platform = "universal-darwin"
s.required_ruby_version = "< #{next_minor}.dev" s.required_ruby_version = "< #{next_ruby_minor}.dev"
end end
build_gem "raygun-apm", "1.0.78" do |s| build_gem "raygun-apm", "1.0.78" do |s|
s.platform = "x64-mingw32" s.platform = "x64-mingw32"
s.required_ruby_version = "< #{next_minor}.dev" s.required_ruby_version = "< #{next_ruby_minor}.dev"
end end
build_gem "raygun-apm", "1.0.78" do |s| build_gem "raygun-apm", "1.0.78" do |s|
s.platform = "x64-mingw-ucrt" s.platform = "x64-mingw-ucrt"
s.required_ruby_version = "< #{next_minor}.dev" s.required_ruby_version = "< #{next_ruby_minor}.dev"
end end
end end

View file

@ -245,6 +245,43 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(the_bundle).to include_gems("rack 1.2") expect(the_bundle).to include_gems("rack 1.2")
end end
it "gives a meaningful error if there's a lockfile using the newer incompatible version" do
build_repo2 do
build_gem "parallel_tests", "3.7.0" do |s|
s.required_ruby_version = ">= #{current_ruby_minor}"
end
build_gem "parallel_tests", "3.8.0" do |s|
s.required_ruby_version = ">= #{next_ruby_minor}"
end
end
gemfile <<-G
source "http://localgemserver.test/"
gem 'parallel_tests'
G
lockfile <<~L
GEM
remote: http://localgemserver.test/
specs:
parallel_tests (3.8.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
parallel_tests
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false
expect(err).to include("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}")
expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
end
it "installs the older version under rate limiting conditions" do it "installs the older version under rate limiting conditions" do
build_repo4 do build_repo4 do
build_gem "rack", "9001.0.0" do |s| build_gem "rack", "9001.0.0" do |s|

View file

@ -66,7 +66,7 @@ RSpec.context "when using gem before installing" do
bundle :list, :raise_on_error => false bundle :list, :raise_on_error => false
expect(err).to include("Could not find rack-0.9.1 in any of the sources") expect(err).to include("Could not find rack-0.9.1 in any of the sources")
expect(err).to_not include("Your bundle is locked to rack (0.9.1), but that version could not be found in any of the sources listed in your Gemfile.") expect(err).to_not include("Your bundle is locked to rack (0.9.1) from")
expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.") expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")
expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.") expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.")
end end
@ -97,7 +97,7 @@ RSpec.context "when using gem before installing" do
expect(err).to include("Could not find rack-0.9.1, rack_middleware-1.0 in any of the sources") expect(err).to include("Could not find rack-0.9.1, rack_middleware-1.0 in any of the sources")
expect(err).to include("Install missing gems with `bundle install`.") expect(err).to include("Install missing gems with `bundle install`.")
expect(err).to_not include("Your bundle is locked to rack (0.9.1), but that version could not be found in any of the sources listed in your Gemfile.") expect(err).to_not include("Your bundle is locked to rack (0.9.1) from")
expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.") expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")
expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.") expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.")
end end

View file

@ -89,7 +89,7 @@ RSpec.describe "bundler/inline#gemfile" do
expect(out).to include("Installing activesupport") expect(out).to include("Installing activesupport")
err_lines = err.split("\n") err_lines = err.split("\n")
err_lines.reject!{|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7" err_lines.reject! {|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7"
expect(err_lines).to be_empty expect(err_lines).to be_empty
end end
@ -239,6 +239,40 @@ RSpec.describe "bundler/inline#gemfile" do
expect(err).to be_empty expect(err).to be_empty
end end
it "does not leak Gemfile.lock versions to the installation output" do
gemfile <<-G
source "https://notaserver.com"
gem "rake"
G
lockfile <<-G
GEM
remote: https://rubygems.org/
specs:
rake (11.3.0)
PLATFORMS
ruby
DEPENDENCIES
rake
BUNDLED WITH
#{Bundler::VERSION}
G
script <<-RUBY
gemfile(true) do
source "#{file_uri_for(gem_repo1)}"
gem "rake", "~> 13.0"
end
RUBY
expect(out).to include("Installing rake 13.0")
expect(out).not_to include("was 11.3.0")
expect(err).to be_empty
end
it "installs inline gems when frozen is set" do it "installs inline gems when frozen is set" do
script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" } script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" }
gemfile do gemfile do

View file

@ -471,6 +471,14 @@ module Spec
end end
end end
def current_ruby_minor
Gem.ruby_version.segments[0..1].join(".")
end
def next_ruby_minor
Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".")
end
# versions providing a bundler version finder but not including # versions providing a bundler version finder but not including
# https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1 # https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1
def rubygems_version_failing_to_activate_bundler_prereleases def rubygems_version_failing_to_activate_bundler_prereleases

View file

@ -18,6 +18,12 @@ module Spec
gem_load_and_activate(gem_name, bin_container) gem_load_and_activate(gem_name, bin_container)
end end
def gem_load_and_possibly_install(gem_name, bin_container)
require_relative "switch_rubygems"
gem_load_activate_and_possibly_install(gem_name, bin_container)
end
def gem_require(gem_name) def gem_require(gem_name)
gem_activate(gem_name) gem_activate(gem_name)
require gem_name require gem_name
@ -99,9 +105,21 @@ module Spec
abort "We couldn't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`" abort "We couldn't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`"
end end
def gem_load_activate_and_possibly_install(gem_name, bin_container)
gem_activate_and_possibly_install(gem_name)
load Gem.bin_path(gem_name, bin_container)
end
def gem_activate_and_possibly_install(gem_name)
gem_activate(gem_name)
rescue Gem::LoadError => e
Gem.install(gem_name, e.requirement)
retry
end
def gem_activate(gem_name) def gem_activate(gem_name)
require "bundler" require "bundler"
gem_requirement = Bundler::LockfileParser.new(File.read(dev_lockfile)).dependencies[gem_name]&.requirement gem_requirement = Bundler::LockfileParser.new(File.read(dev_lockfile)).specs.find {|spec| spec.name == gem_name }.version
gem gem_name, gem_requirement gem gem_name, gem_requirement
end end

View file

@ -1294,7 +1294,7 @@ Also, a list:
end end
def rubygems_path def rubygems_path
$LOAD_PATH.find{|p| p == File.dirname($LOADED_FEATURES.find{|f| f.end_with?("/rubygems.rb") }) } $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }
end end
def with_clean_path_to_ruby def with_clean_path_to_ruby

View file

@ -67,7 +67,7 @@ class Gem::Package::TarTestCase < Gem::TestCase
end end
def calc_checksum(header) def calc_checksum(header)
sum = header.unpack("C*").inject{|s,a| s + a } sum = header.unpack("C*").inject {|s,a| s + a }
SP(Z(to_oct(sum, 6))) SP(Z(to_oct(sum, 6)))
end end

View file

@ -1061,7 +1061,7 @@ class TestGem < Gem::TestCase
Gem.refresh Gem.refresh
Gem::Specification.each{|spec| assert spec.activated? if spec == s } Gem::Specification.each {|spec| assert spec.activated? if spec == s }
Gem.loaded_specs.delete(s) Gem.loaded_specs.delete(s)
Gem.refresh Gem.refresh

View file

@ -239,7 +239,7 @@ lib/foo.rb
[RbConfig::CONFIG['bindir'], 'default_command'], [RbConfig::CONFIG['bindir'], 'default_command'],
[RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'], [RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'],
[RbConfig::CONFIG['archdir'], 'default_gem.so'], [RbConfig::CONFIG['archdir'], 'default_gem.so'],
].sort.map{|a|File.join a }.join "\n" ].sort.map {|a|File.join a }.join "\n"
assert_equal expected, @ui.output.chomp assert_equal expected, @ui.output.chomp
assert_equal "", @ui.error assert_equal "", @ui.error

View file

@ -521,7 +521,7 @@ ERROR: Possible alternatives: non_existent_with_hint
end end
def test_execute_required_ruby_version def test_execute_required_ruby_version
next_ruby = Gem.ruby_version.segments.map.with_index{|n, i| i == 1 ? n + 1 : n }.join(".") next_ruby = Gem.ruby_version.segments.map.with_index {|n, i| i == 1 ? n + 1 : n }.join(".")
local = Gem::Platform.local local = Gem::Platform.local
spec_fetcher do |fetcher| spec_fetcher do |fetcher|
@ -610,7 +610,7 @@ ERROR: Possible alternatives: non_existent_with_hint
end end
def test_execute_required_ruby_version_specific_prerelease_not_met def test_execute_required_ruby_version_specific_prerelease_not_met
next_ruby_pre = Gem.ruby_version.segments.map.with_index{|n, i| i == 1 ? n + 1 : n }.join(".") + ".a" next_ruby_pre = Gem.ruby_version.segments.map.with_index {|n, i| i == 1 ? n + 1 : n }.join(".") + ".a"
spec_fetcher do |fetcher| spec_fetcher do |fetcher|
fetcher.gem 'a', '1.0' do |s| fetcher.gem 'a', '1.0' do |s|

View file

@ -248,7 +248,7 @@ DEPENDENCIES
assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name } assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name }
assert_equal %w[https://gems.example/ https://other.example/], assert_equal %w[https://gems.example/ https://other.example/],
lockfile_set.specs.flat_map {|s| s.sources.map{|src| src.uri.to_s } } lockfile_set.specs.flat_map {|s| s.sources.map {|src| src.uri.to_s } }
end end
def test_parse_GIT def test_parse_GIT

View file

@ -210,7 +210,7 @@ class TestGemResolverInstallerSet < Gem::TestCase
def (set.remote_set).prefetch(_) def (set.remote_set).prefetch(_)
raise "called" raise "called"
end end
assert_raise(RuntimeError){ set.prefetch(nil) } assert_raise(RuntimeError) { set.prefetch(nil) }
set = Gem::Resolver::InstallerSet.new :local set = Gem::Resolver::InstallerSet.new :local
def (set.remote_set).prefetch(_) def (set.remote_set).prefetch(_)

View file

@ -992,8 +992,8 @@ dependencies: []
dir_standard_specs = File.join Gem.dir, 'specifications' dir_standard_specs = File.join Gem.dir, 'specifications'
save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = 'a' } save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' }
save_gemspec('b-1', '1', dir_standard_specs){|s| s.name = 'b' } save_gemspec('b-1', '1', dir_standard_specs) {|s| s.name = 'b' }
assert_equal ['a-1'], Gem::Specification.stubs_for('a').map {|s| s.full_name } assert_equal ['a-1'], Gem::Specification.stubs_for('a').map {|s| s.full_name }
assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length
@ -1013,7 +1013,7 @@ dependencies: []
def test_self_stubs_for_no_lazy_loading_after_all_specs_setup def test_self_stubs_for_no_lazy_loading_after_all_specs_setup
Gem::Specification.all = [util_spec('a', '1')] Gem::Specification.all = [util_spec('a', '1')]
save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')){|s| s.name = 'b' } save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')) {|s| s.name = 'b' }
assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name } assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name }
end end
@ -1060,9 +1060,9 @@ dependencies: []
def test_self_stubs_returns_only_specified_named_specs def test_self_stubs_returns_only_specified_named_specs
dir_standard_specs = File.join Gem.dir, 'specifications' dir_standard_specs = File.join Gem.dir, 'specifications'
save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = 'a' } save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' }
save_gemspec('a-2', '2', dir_standard_specs){|s| s.name = 'a' } save_gemspec('a-2', '2', dir_standard_specs) {|s| s.name = 'a' }
save_gemspec('a-a', '3', dir_standard_specs){|s| s.name = 'a-a' } save_gemspec('a-a', '3', dir_standard_specs) {|s| s.name = 'a-a' }
assert_equal ['a-1', 'a-2'], Gem::Specification.stubs_for('a').map(&:full_name).sort assert_equal ['a-1', 'a-2'], Gem::Specification.stubs_for('a').map(&:full_name).sort
end end

View file

@ -152,8 +152,8 @@ class TestGemRequire < Gem::TestCase
install_specs a1, b1 install_specs a1, b1
t1 = create_sync_thread{ assert_require "a#{$$}" } t1 = create_sync_thread { assert_require "a#{$$}" }
t2 = create_sync_thread{ assert_require "b#{$$}" } t2 = create_sync_thread { assert_require "b#{$$}" }
# wait until both files are waiting on the exit latch # wait until both files are waiting on the exit latch
FILE_ENTERED_LATCH.await FILE_ENTERED_LATCH.await

View file

@ -66,6 +66,6 @@ class GemTest < Gem::TestCase
end end
def ruby_with_rubygems_and_fake_operating_system_in_load_path(operating_system_path) def ruby_with_rubygems_and_fake_operating_system_in_load_path(operating_system_path)
[Gem.ruby, "-I", operating_system_path, "-I" , $LOAD_PATH.find{|p| p == File.dirname($LOADED_FEATURES.find{|f| f.end_with?("/rubygems.rb") }) }] [Gem.ruby, "-I", operating_system_path, "-I" , $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }]
end end
end end

View file

@ -72,4 +72,4 @@ DEPENDENCIES
webrick (~> 1.6) webrick (~> 1.6)
BUNDLED WITH BUNDLED WITH
2.3.13 2.3.14

View file

@ -60,4 +60,4 @@ DEPENDENCIES
test-unit test-unit
BUNDLED WITH BUNDLED WITH
2.3.13 2.3.14

View file

@ -66,4 +66,4 @@ DEPENDENCIES
test-unit test-unit
BUNDLED WITH BUNDLED WITH
2.3.13 2.3.14

View file

@ -41,4 +41,4 @@ DEPENDENCIES
webrick (= 1.7.0) webrick (= 1.7.0)
BUNDLED WITH BUNDLED WITH
2.3.13 2.3.14