mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 03:24:00 +02:00
Merge pull request #5482 from hsbt/rubygems-3-3-bundler-2-3
Merge RubyGems 3.3.x and Bundler 2.3.x
This commit is contained in:
parent
69463805f0
commit
6794f8cf92
115 changed files with 1701 additions and 889 deletions
|
@ -1407,8 +1407,12 @@ yes-test-bundler-precheck: main
|
||||||
no-test-bundler-prepare: no-test-bundler-precheck
|
no-test-bundler-prepare: no-test-bundler-precheck
|
||||||
yes-test-bundler-prepare: yes-test-bundler-precheck
|
yes-test-bundler-prepare: yes-test-bundler-precheck
|
||||||
$(ACTIONS_GROUP)
|
$(ACTIONS_GROUP)
|
||||||
$(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
|
$(XRUBY) -C $(srcdir) -Ilib \
|
||||||
--install-dir .bundle --conservative "rspec:~> 3.8" "rake:~> 13.0" "parallel_tests:~> 2.29"
|
-e 'ENV["GEM_HOME"] = File.expand_path(".bundle")' \
|
||||||
|
-e 'ENV["BUNDLE_APP_CONFIG"] = File.expand_path(".bundle")' \
|
||||||
|
-e 'ENV["BUNDLE_PATH__SYSTEM"] = "true"' \
|
||||||
|
-e 'ENV["BUNDLE_WITHOUT"] = "lint doc"' \
|
||||||
|
-e 'load "spec/bundler/support/bundle.rb"' -- install --gemfile=tool/bundler/dev_gems.rb
|
||||||
$(ACTIONS_ENDGROUP)
|
$(ACTIONS_ENDGROUP)
|
||||||
|
|
||||||
RSPECOPTS =
|
RSPECOPTS =
|
||||||
|
|
|
@ -11,6 +11,6 @@ net-pop 0.1.1 https://github.com/ruby/net-pop
|
||||||
net-smtp 0.3.1 https://github.com/ruby/net-smtp
|
net-smtp 0.3.1 https://github.com/ruby/net-smtp
|
||||||
matrix 0.4.2 https://github.com/ruby/matrix
|
matrix 0.4.2 https://github.com/ruby/matrix
|
||||||
prime 0.1.2 https://github.com/ruby/prime
|
prime 0.1.2 https://github.com/ruby/prime
|
||||||
rbs 2.0.0 https://github.com/ruby/rbs
|
rbs 2.1.0 https://github.com/ruby/rbs
|
||||||
typeprof 0.21.1 https://github.com/ruby/typeprof
|
typeprof 0.21.1 https://github.com/ruby/typeprof
|
||||||
debug 1.4.0 https://github.com/ruby/debug
|
debug 1.4.0 https://github.com/ruby/debug
|
||||||
|
|
|
@ -809,17 +809,10 @@ module Bundler
|
||||||
|
|
||||||
current = Gem::Version.new(VERSION)
|
current = Gem::Version.new(VERSION)
|
||||||
return if current >= latest
|
return if current >= latest
|
||||||
latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max
|
|
||||||
|
|
||||||
installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`"
|
Bundler.ui.warn \
|
||||||
if latest_installed && latest_installed > current
|
"The latest bundler is #{latest}, but you are currently running #{current}.\n" \
|
||||||
suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`"
|
"To update to the most recent version, run `bundle update --bundler`"
|
||||||
suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest
|
|
||||||
else
|
|
||||||
suggestion = installation
|
|
||||||
end
|
|
||||||
|
|
||||||
Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
|
|
||||||
rescue RuntimeError
|
rescue RuntimeError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
require "rbconfig"
|
require "rbconfig"
|
||||||
require "shellwords"
|
require "shellwords"
|
||||||
|
require "fiddle"
|
||||||
|
|
||||||
module Bundler
|
module Bundler
|
||||||
class CLI::Doctor
|
class CLI::Doctor
|
||||||
|
@ -71,7 +72,14 @@ module Bundler
|
||||||
|
|
||||||
definition.specs.each do |spec|
|
definition.specs.each do |spec|
|
||||||
bundles_for_gem(spec).each do |bundle|
|
bundles_for_gem(spec).each do |bundle|
|
||||||
bad_paths = dylibs(bundle).select {|f| !File.exist?(f) }
|
bad_paths = dylibs(bundle).select do |f|
|
||||||
|
begin
|
||||||
|
Fiddle.dlopen(f)
|
||||||
|
false
|
||||||
|
rescue Fiddle::DLError
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
if bad_paths.any?
|
if bad_paths.any?
|
||||||
broken_links[spec] ||= []
|
broken_links[spec] ||= []
|
||||||
broken_links[spec].concat(bad_paths)
|
broken_links[spec].concat(bad_paths)
|
||||||
|
|
|
@ -38,6 +38,7 @@ module Bundler
|
||||||
namespaced_path = name.tr("-", "/")
|
namespaced_path = name.tr("-", "/")
|
||||||
constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
|
constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
|
||||||
constant_array = constant_name.split("::")
|
constant_array = constant_name.split("::")
|
||||||
|
minitest_constant_name = constant_array.clone.tap {|a| a[-1] = "Test#{a[-1]}" }.join("::") # Foo::Bar => Foo::TestBar
|
||||||
|
|
||||||
use_git = Bundler.git_present? && options[:git]
|
use_git = Bundler.git_present? && options[:git]
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ module Bundler
|
||||||
:git => use_git,
|
:git => use_git,
|
||||||
:github_username => github_username.empty? ? "[USERNAME]" : github_username,
|
:github_username => github_username.empty? ? "[USERNAME]" : github_username,
|
||||||
:required_ruby_version => required_ruby_version,
|
:required_ruby_version => required_ruby_version,
|
||||||
|
:minitest_constant_name => minitest_constant_name,
|
||||||
}
|
}
|
||||||
ensure_safe_gem_name(name, constant_array)
|
ensure_safe_gem_name(name, constant_array)
|
||||||
|
|
||||||
|
@ -104,9 +106,17 @@ module Bundler
|
||||||
)
|
)
|
||||||
config[:test_task] = :spec
|
config[:test_task] = :spec
|
||||||
when "minitest"
|
when "minitest"
|
||||||
|
# Generate path for minitest target file (FileList["test/**/test_*.rb"])
|
||||||
|
# foo => test/test_foo.rb
|
||||||
|
# foo-bar => test/foo/test_bar.rb
|
||||||
|
# foo_bar => test/test_foo_bar.rb
|
||||||
|
paths = namespaced_path.rpartition("/")
|
||||||
|
paths[2] = "test_#{paths[2]}"
|
||||||
|
minitest_namespaced_path = paths.join("")
|
||||||
|
|
||||||
templates.merge!(
|
templates.merge!(
|
||||||
"test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
|
"test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
|
||||||
"test/minitest/test_newgem.rb.tt" => "test/test_#{namespaced_path}.rb"
|
"test/minitest/test_newgem.rb.tt" => "test/#{minitest_namespaced_path}.rb"
|
||||||
)
|
)
|
||||||
config[:test_task] = :test
|
config[:test_task] = :test
|
||||||
when "test-unit"
|
when "test-unit"
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Bundler
|
||||||
output << "No ruby version specified"
|
output << "No ruby version specified"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
output << "Your platform is: #{RUBY_PLATFORM}"
|
output << "Your platform is: #{Gem::Platform.local}"
|
||||||
output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
|
output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
|
||||||
|
|
||||||
if ruby_version
|
if ruby_version
|
||||||
|
|
|
@ -11,12 +11,16 @@ module Bundler
|
||||||
def run
|
def run
|
||||||
Bundler.ui.level = "warn" if options[:quiet]
|
Bundler.ui.level = "warn" if options[:quiet]
|
||||||
|
|
||||||
|
update_bundler = options[:bundler]
|
||||||
|
|
||||||
|
Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler
|
||||||
|
|
||||||
Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
|
Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
|
||||||
|
|
||||||
sources = Array(options[:source])
|
sources = Array(options[:source])
|
||||||
groups = Array(options[:group]).map(&:to_sym)
|
groups = Array(options[:group]).map(&:to_sym)
|
||||||
|
|
||||||
full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
|
full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !update_bundler
|
||||||
|
|
||||||
if full_update && !options[:all]
|
if full_update && !options[:all]
|
||||||
if Bundler.feature_flag.update_requires_all_flag?
|
if Bundler.feature_flag.update_requires_all_flag?
|
||||||
|
@ -49,7 +53,7 @@ module Bundler
|
||||||
|
|
||||||
Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
|
Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
|
||||||
:conservative => conservative,
|
:conservative => conservative,
|
||||||
:bundler => options[:bundler])
|
:bundler => update_bundler)
|
||||||
end
|
end
|
||||||
|
|
||||||
Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
|
Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
|
||||||
|
|
|
@ -73,12 +73,6 @@ module Bundler
|
||||||
end.flatten(1)
|
end.flatten(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec(name, version, platform = nil)
|
|
||||||
Bundler::CompactIndexClient.debug { "spec(name = #{name}, version = #{version}, platform = #{platform})" }
|
|
||||||
update_info(name)
|
|
||||||
@cache.specific_dependency(name, version, platform)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_and_parse_checksums!
|
def update_and_parse_checksums!
|
||||||
Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" }
|
Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" }
|
||||||
return @info_checksums_by_name if @parsed_checksums
|
return @info_checksums_by_name if @parsed_checksums
|
||||||
|
|
|
@ -76,15 +76,6 @@ module Bundler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def specific_dependency(name, version, platform)
|
|
||||||
pattern = [version, platform].compact.join("-")
|
|
||||||
return nil if pattern.empty?
|
|
||||||
|
|
||||||
gem_lines = info_path(name).read
|
|
||||||
gem_line = gem_lines[/^#{Regexp.escape(pattern)}\b.*/, 0]
|
|
||||||
gem_line ? parse_gem(gem_line) : nil
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def lines(path)
|
def lines(path)
|
||||||
|
|
|
@ -265,7 +265,7 @@ module Bundler
|
||||||
else
|
else
|
||||||
# Run a resolve against the locally available gems
|
# Run a resolve against the locally available gems
|
||||||
Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
|
Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
|
||||||
expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote)
|
expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
|
||||||
Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
|
Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -309,14 +309,6 @@ module Bundler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def locked_bundler_version
|
|
||||||
if @locked_bundler_version && @locked_bundler_version < Gem::Version.new(Bundler::VERSION)
|
|
||||||
new_version = Bundler::VERSION
|
|
||||||
end
|
|
||||||
|
|
||||||
new_version || @locked_bundler_version || Bundler::VERSION
|
|
||||||
end
|
|
||||||
|
|
||||||
def locked_ruby_version
|
def locked_ruby_version
|
||||||
return unless ruby_version
|
return unless ruby_version
|
||||||
if @unlock[:ruby] || !@locked_ruby_version
|
if @unlock[:ruby] || !@locked_ruby_version
|
||||||
|
@ -503,6 +495,7 @@ module Bundler
|
||||||
|
|
||||||
def current_ruby_platform_locked?
|
def current_ruby_platform_locked?
|
||||||
return false unless generic_local_platform == Gem::Platform::RUBY
|
return false unless generic_local_platform == Gem::Platform::RUBY
|
||||||
|
return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
|
||||||
|
|
||||||
current_platform_locked?
|
current_platform_locked?
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,14 +5,15 @@ module Bundler
|
||||||
class EndpointSpecification < Gem::Specification
|
class EndpointSpecification < Gem::Specification
|
||||||
include MatchPlatform
|
include MatchPlatform
|
||||||
|
|
||||||
attr_reader :name, :version, :platform, :required_rubygems_version, :required_ruby_version, :checksum
|
attr_reader :name, :version, :platform, :checksum
|
||||||
attr_accessor :source, :remote, :dependencies
|
attr_accessor :source, :remote, :dependencies
|
||||||
|
|
||||||
def initialize(name, version, platform, dependencies, metadata = nil)
|
def initialize(name, version, platform, spec_fetcher, dependencies, metadata = nil)
|
||||||
super()
|
super()
|
||||||
@name = name
|
@name = name
|
||||||
@version = Gem::Version.create version
|
@version = Gem::Version.create version
|
||||||
@platform = platform
|
@platform = platform
|
||||||
|
@spec_fetcher = spec_fetcher
|
||||||
@dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
|
@dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
|
||||||
|
|
||||||
@loaded_from = nil
|
@loaded_from = nil
|
||||||
|
@ -21,6 +22,14 @@ module Bundler
|
||||||
parse_metadata(metadata)
|
parse_metadata(metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def required_ruby_version
|
||||||
|
@required_ruby_version ||= _remote_specification.required_ruby_version
|
||||||
|
end
|
||||||
|
|
||||||
|
def required_rubygems_version
|
||||||
|
@required_rubygems_version ||= _remote_specification.required_rubygems_version
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_platform
|
def fetch_platform
|
||||||
@platform
|
@platform
|
||||||
end
|
end
|
||||||
|
@ -105,12 +114,21 @@ module Bundler
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def _remote_specification
|
||||||
|
@_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform])
|
||||||
|
end
|
||||||
|
|
||||||
def local_specification_path
|
def local_specification_path
|
||||||
"#{base_dir}/specifications/#{full_name}.gemspec"
|
"#{base_dir}/specifications/#{full_name}.gemspec"
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_metadata(data)
|
def parse_metadata(data)
|
||||||
return unless data
|
unless data
|
||||||
|
@required_ruby_version = nil
|
||||||
|
@required_rubygems_version = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
data.each do |k, v|
|
data.each do |k, v|
|
||||||
next unless v
|
next unless v
|
||||||
case k.to_s
|
case k.to_s
|
||||||
|
|
|
@ -71,7 +71,7 @@ module Bundler
|
||||||
def self.ruby_version
|
def self.ruby_version
|
||||||
str = String.new(RUBY_VERSION)
|
str = String.new(RUBY_VERSION)
|
||||||
str << "p#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
|
str << "p#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
|
||||||
str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{RUBY_PLATFORM}]"
|
str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{Gem::Platform.local}]"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.git_version
|
def self.git_version
|
||||||
|
|
|
@ -129,17 +129,15 @@ module Bundler
|
||||||
specs = fetchers.last.specs(gem_names)
|
specs = fetchers.last.specs(gem_names)
|
||||||
else
|
else
|
||||||
specs = []
|
specs = []
|
||||||
fetchers.shift until fetchers.first.available? || fetchers.empty?
|
@fetchers = fetchers.drop_while do |f|
|
||||||
fetchers.dup.each do |f|
|
!f.available? || (f.api_fetcher? && !gem_names) || !specs = f.specs(gem_names)
|
||||||
break unless f.api_fetcher? && !gem_names || !specs = f.specs(gem_names)
|
|
||||||
fetchers.delete(f)
|
|
||||||
end
|
end
|
||||||
@use_api = false if fetchers.none?(&:api_fetcher?)
|
@use_api = false if fetchers.none?(&:api_fetcher?)
|
||||||
end
|
end
|
||||||
|
|
||||||
specs.each do |name, version, platform, dependencies, metadata|
|
specs.each do |name, version, platform, dependencies, metadata|
|
||||||
spec = if dependencies
|
spec = if dependencies
|
||||||
EndpointSpecification.new(name, version, platform, dependencies, metadata)
|
EndpointSpecification.new(name, version, platform, self, dependencies, metadata)
|
||||||
else
|
else
|
||||||
RemoteSpecification.new(name, version, platform, self)
|
RemoteSpecification.new(name, version, platform, self)
|
||||||
end
|
end
|
||||||
|
@ -272,8 +270,7 @@ module Bundler
|
||||||
# cached gem specification path, if one exists
|
# cached gem specification path, if one exists
|
||||||
def gemspec_cached_path(spec_file_name)
|
def gemspec_cached_path(spec_file_name)
|
||||||
paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
|
paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
|
||||||
paths = paths.select {|path| File.file? path }
|
paths.find {|path| File.file? path }
|
||||||
paths.first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
HTTP_ERRORS = [
|
HTTP_ERRORS = [
|
||||||
|
@ -301,8 +298,6 @@ module Bundler
|
||||||
store
|
store
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def remote_uri
|
def remote_uri
|
||||||
@remote.uri
|
@remote.uri
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,16 +57,6 @@ module Bundler
|
||||||
gem_info
|
gem_info
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_spec(spec)
|
|
||||||
spec -= [nil, "ruby", ""]
|
|
||||||
contents = compact_index_client.spec(*spec)
|
|
||||||
return nil if contents.nil?
|
|
||||||
contents.unshift(spec.first)
|
|
||||||
contents[3].map! {|d| Gem::Dependency.new(*d) }
|
|
||||||
EndpointSpecification.new(*contents)
|
|
||||||
end
|
|
||||||
compact_index_request :fetch_spec
|
|
||||||
|
|
||||||
def available?
|
def available?
|
||||||
unless SharedHelpers.md5_available?
|
unless SharedHelpers.md5_available?
|
||||||
Bundler.ui.debug("FIPS mode is enabled, bundler can't use the CompactIndex API")
|
Bundler.ui.debug("FIPS mode is enabled, bundler can't use the CompactIndex API")
|
||||||
|
|
|
@ -21,32 +21,6 @@ module Bundler
|
||||||
raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
|
raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_spec(spec)
|
|
||||||
spec -= [nil, "ruby", ""]
|
|
||||||
spec_file_name = "#{spec.join "-"}.gemspec"
|
|
||||||
|
|
||||||
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))
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
rescue MarshalError
|
|
||||||
raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
|
|
||||||
"Your network or your gem server is probably having issues right now."
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# cached gem specification path, if one exists
|
|
||||||
def gemspec_cached_path(spec_file_name)
|
|
||||||
paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
|
|
||||||
paths.find {|path| File.file? path }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,9 +107,9 @@ module Bundler
|
||||||
SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) }
|
SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) }
|
||||||
file_name = "#{File.basename(built_gem_path)}.sha512"
|
file_name = "#{File.basename(built_gem_path)}.sha512"
|
||||||
require "digest/sha2"
|
require "digest/sha2"
|
||||||
checksum = ::Digest::SHA512.new.hexdigest(built_gem_path.to_s)
|
checksum = ::Digest::SHA512.file(built_gem_path).hexdigest
|
||||||
target = File.join(base, "checksums", file_name)
|
target = File.join(base, "checksums", file_name)
|
||||||
File.write(target, checksum)
|
File.write(target, checksum + "\n")
|
||||||
Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}."
|
Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,11 @@ module Bundler
|
||||||
MatchPlatform.platforms_match?(spec.platform, platform_object)
|
MatchPlatform.platforms_match?(spec.platform, platform_object)
|
||||||
end
|
end
|
||||||
installable_candidates = same_platform_candidates.select do |spec|
|
installable_candidates = same_platform_candidates.select do |spec|
|
||||||
!spec.is_a?(EndpointSpecification) ||
|
spec.is_a?(StubSpecification) ||
|
||||||
(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 || same_platform_candidates.last
|
search = installable_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
|
||||||
|
|
|
@ -71,7 +71,7 @@ module Bundler
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_bundled_with
|
def add_bundled_with
|
||||||
add_section("BUNDLED WITH", definition.locked_bundler_version.to_s)
|
add_section("BUNDLED WITH", Bundler::VERSION)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_section(name, value)
|
def add_section(name, value)
|
||||||
|
|
|
@ -27,6 +27,13 @@ module Bundler
|
||||||
@platform = _remote_specification.platform
|
@platform = _remote_specification.platform
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A fallback is included because the original version of the specification
|
||||||
|
# API didn't include that field, so some marshalled specs in the index have it
|
||||||
|
# set to +nil+.
|
||||||
|
def required_rubygems_version
|
||||||
|
@required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default
|
||||||
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
if platform == Gem::Platform::RUBY || platform.nil?
|
if platform == Gem::Platform::RUBY || platform.nil?
|
||||||
"#{@name}-#{@version}"
|
"#{@name}-#{@version}"
|
||||||
|
|
|
@ -249,10 +249,11 @@ module Bundler
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_gemfile_dependencies_are_found!(requirements)
|
def verify_gemfile_dependencies_are_found!(requirements)
|
||||||
requirements.each do |requirement|
|
requirements.map! do |requirement|
|
||||||
name = requirement.name
|
name = requirement.name
|
||||||
next if name == "bundler"
|
next requirement if name == "bundler"
|
||||||
next unless search_for(requirement).empty?
|
next requirement unless search_for(requirement).empty?
|
||||||
|
next unless requirement.current_platform?
|
||||||
|
|
||||||
if (base = @base[name]) && !base.empty?
|
if (base = @base[name]) && !base.empty?
|
||||||
version = base.first.version
|
version = base.first.version
|
||||||
|
@ -266,7 +267,7 @@ module Bundler
|
||||||
message = gem_not_found_message(name, requirement, source_for(name))
|
message = gem_not_found_message(name, requirement, source_for(name))
|
||||||
end
|
end
|
||||||
raise GemNotFound, message
|
raise GemNotFound, message
|
||||||
end
|
end.compact!
|
||||||
end
|
end
|
||||||
|
|
||||||
def gem_not_found_message(name, requirement, source, extra_message = "")
|
def gem_not_found_message(name, requirement, source, extra_message = "")
|
||||||
|
@ -358,24 +359,18 @@ module Bundler
|
||||||
o << "\n"
|
o << "\n"
|
||||||
o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
|
o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
|
||||||
o << %(the gems in your Gemfile, which may resolve the conflict.\n)
|
o << %(the gems in your Gemfile, which may resolve the conflict.\n)
|
||||||
elsif !conflict.existing
|
elsif !conflict.existing && !name.end_with?("\0")
|
||||||
o << "\n"
|
o << "\n"
|
||||||
|
|
||||||
relevant_source = conflict.requirement.source || source_for(name)
|
relevant_source = conflict.requirement.source || source_for(name)
|
||||||
|
|
||||||
metadata_requirement = name.end_with?("\0")
|
|
||||||
|
|
||||||
extra_message = if conflict.requirement_trees.first.size > 1
|
extra_message = if conflict.requirement_trees.first.size > 1
|
||||||
", which is required by gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
|
", which is required by gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
|
|
||||||
if metadata_requirement
|
o << gem_not_found_message(name, conflict.requirement, relevant_source, extra_message)
|
||||||
o << "#{SharedHelpers.pretty_dependency(conflict.requirement)}#{extra_message} is not available in #{relevant_source}"
|
|
||||||
else
|
|
||||||
o << gem_not_found_message(name, conflict.requirement, relevant_source, extra_message)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
:version_for_spec => lambda {|spec| spec.version },
|
:version_for_spec => lambda {|spec| spec.version },
|
||||||
|
|
|
@ -95,7 +95,7 @@ module Bundler
|
||||||
|
|
||||||
def metadata_dependencies(platform)
|
def metadata_dependencies(platform)
|
||||||
spec = @specs[platform].first
|
spec = @specs[platform].first
|
||||||
return [] unless spec.is_a?(Gem::Specification)
|
return [] if spec.is_a?(LazySpecification)
|
||||||
dependencies = []
|
dependencies = []
|
||||||
if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
|
if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
|
||||||
dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
|
dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
|
||||||
|
|
|
@ -103,7 +103,7 @@ module Bundler
|
||||||
|
|
||||||
def self.system
|
def self.system
|
||||||
ruby_engine = RUBY_ENGINE.dup
|
ruby_engine = RUBY_ENGINE.dup
|
||||||
ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
|
ruby_version = RUBY_VERSION.dup
|
||||||
ruby_engine_version = RUBY_ENGINE_VERSION.dup
|
ruby_engine_version = RUBY_ENGINE_VERSION.dup
|
||||||
patchlevel = RUBY_PATCHLEVEL.to_s
|
patchlevel = RUBY_PATCHLEVEL.to_s
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Bundler
|
||||||
def restart_with_locked_bundler_if_needed
|
def restart_with_locked_bundler_if_needed
|
||||||
return unless needs_switching? && installed?
|
return unless needs_switching? && installed?
|
||||||
|
|
||||||
restart_with_locked_bundler
|
restart_with(lockfile_version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_locked_bundler_and_restart_with_it_if_needed
|
def install_locked_bundler_and_restart_with_it_if_needed
|
||||||
|
@ -19,23 +19,48 @@ module Bundler
|
||||||
"Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
|
"Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
|
||||||
"Installing Bundler #{lockfile_version} and restarting using that version."
|
"Installing Bundler #{lockfile_version} and restarting using that version."
|
||||||
|
|
||||||
install_and_restart_with_locked_bundler
|
install_and_restart_with(lockfile_version)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_bundler_and_restart_with_it_if_needed(target)
|
||||||
|
return unless autoswitching_applies?
|
||||||
|
|
||||||
|
spec = resolve_update_version_from(target)
|
||||||
|
return unless spec
|
||||||
|
|
||||||
|
version = spec.version
|
||||||
|
|
||||||
|
Bundler.ui.info "Updating bundler to #{version}."
|
||||||
|
|
||||||
|
install(spec)
|
||||||
|
|
||||||
|
restart_with(version)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def install_and_restart_with_locked_bundler
|
def install_and_restart_with(version)
|
||||||
bundler_dep = Gem::Dependency.new("bundler", lockfile_version)
|
requirement = Gem::Requirement.new(version)
|
||||||
|
spec = find_latest_matching_spec(requirement)
|
||||||
|
|
||||||
Gem.install(bundler_dep)
|
if spec.nil?
|
||||||
|
Bundler.ui.warn "Your lockfile is locked to a version of bundler (#{lockfile_version}) that doesn't exist at https://rubygems.org/. Going on using #{current_version}"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
install(spec)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Bundler.ui.trace e
|
Bundler.ui.trace e
|
||||||
Bundler.ui.warn "There was an error installing the locked bundler version (#{lockfile_version}), rerun with the `--verbose` flag for more details. Going on using bundler #{current_version}."
|
Bundler.ui.warn "There was an error installing the locked bundler version (#{lockfile_version}), rerun with the `--verbose` flag for more details. Going on using bundler #{current_version}."
|
||||||
else
|
else
|
||||||
restart_with_locked_bundler
|
restart_with(version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def restart_with_locked_bundler
|
def install(spec)
|
||||||
|
spec.source.install(spec)
|
||||||
|
end
|
||||||
|
|
||||||
|
def restart_with(version)
|
||||||
configured_gem_home = ENV["GEM_HOME"]
|
configured_gem_home = ENV["GEM_HOME"]
|
||||||
configured_gem_path = ENV["GEM_PATH"]
|
configured_gem_path = ENV["GEM_PATH"]
|
||||||
|
|
||||||
|
@ -44,33 +69,100 @@ module Bundler
|
||||||
|
|
||||||
Bundler.with_original_env do
|
Bundler.with_original_env do
|
||||||
Kernel.exec(
|
Kernel.exec(
|
||||||
{ "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => lockfile_version },
|
{ "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => version.to_s },
|
||||||
*cmd
|
*cmd
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_switching?
|
def needs_switching?
|
||||||
|
autoswitching_applies? &&
|
||||||
|
released?(lockfile_version) &&
|
||||||
|
!running?(lockfile_version) &&
|
||||||
|
!updating?
|
||||||
|
end
|
||||||
|
|
||||||
|
def autoswitching_applies?
|
||||||
ENV["BUNDLER_VERSION"].nil? &&
|
ENV["BUNDLER_VERSION"].nil? &&
|
||||||
Bundler.rubygems.supports_bundler_trampolining? &&
|
Bundler.rubygems.supports_bundler_trampolining? &&
|
||||||
SharedHelpers.in_bundle? &&
|
SharedHelpers.in_bundle? &&
|
||||||
lockfile_version &&
|
lockfile_version
|
||||||
!lockfile_version.end_with?(".dev") &&
|
end
|
||||||
lockfile_version != current_version
|
|
||||||
|
def resolve_update_version_from(target)
|
||||||
|
requirement = Gem::Requirement.new(target)
|
||||||
|
update_candidate = find_latest_matching_spec(requirement)
|
||||||
|
|
||||||
|
if update_candidate.nil?
|
||||||
|
raise InvalidOption, "The `bundle update --bundler` target version (#{target}) does not exist"
|
||||||
|
end
|
||||||
|
|
||||||
|
resolved_version = update_candidate.version
|
||||||
|
needs_update = requirement.specific? ? !running?(resolved_version) : running_older_than?(resolved_version)
|
||||||
|
|
||||||
|
return unless needs_update
|
||||||
|
|
||||||
|
update_candidate
|
||||||
|
end
|
||||||
|
|
||||||
|
def local_specs
|
||||||
|
@local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true).specs.select {|spec| spec.name == "bundler" }
|
||||||
|
end
|
||||||
|
|
||||||
|
def remote_specs
|
||||||
|
@remote_specs ||= begin
|
||||||
|
source = Bundler::Source::Rubygems.new("remotes" => "https://rubygems.org")
|
||||||
|
source.remote!
|
||||||
|
source.add_dependency_names("bundler")
|
||||||
|
source.specs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_latest_matching_spec(requirement)
|
||||||
|
local_result = find_latest_matching_spec_from_collection(local_specs, requirement)
|
||||||
|
return local_result if local_result && requirement.specific?
|
||||||
|
|
||||||
|
remote_result = find_latest_matching_spec_from_collection(remote_specs, requirement)
|
||||||
|
return remote_result if local_result.nil?
|
||||||
|
|
||||||
|
[local_result, remote_result].max
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_latest_matching_spec_from_collection(specs, requirement)
|
||||||
|
specs.sort.reverse_each.find {|spec| requirement.satisfied_by?(spec.version) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def running?(version)
|
||||||
|
version == current_version
|
||||||
|
end
|
||||||
|
|
||||||
|
def running_older_than?(version)
|
||||||
|
current_version < version
|
||||||
|
end
|
||||||
|
|
||||||
|
def released?(version)
|
||||||
|
!version.to_s.end_with?(".dev")
|
||||||
|
end
|
||||||
|
|
||||||
|
def updating?
|
||||||
|
"update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed?
|
def installed?
|
||||||
Bundler.configure
|
Bundler.configure
|
||||||
|
|
||||||
Bundler.rubygems.find_bundler(lockfile_version)
|
Bundler.rubygems.find_bundler(lockfile_version.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_version
|
def current_version
|
||||||
@current_version ||= Bundler::VERSION
|
@current_version ||= Gem::Version.new(Bundler::VERSION)
|
||||||
end
|
end
|
||||||
|
|
||||||
def lockfile_version
|
def lockfile_version
|
||||||
@lockfile_version ||= Bundler::LockfileParser.bundled_with
|
return @lockfile_version if defined?(@lockfile_version)
|
||||||
|
|
||||||
|
parsed_version = Bundler::LockfileParser.bundled_with
|
||||||
|
@lockfile_version = parsed_version ? Gem::Version.new(parsed_version) : nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
||||||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
||||||
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
||||||
`git ls-files -z`.split("\x0").reject do |f|
|
`git ls-files -z`.split("\x0").reject do |f|
|
||||||
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
spec.bindir = "exe"
|
spec.bindir = "exe"
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
# For available configuration options, see:
|
# For available configuration options, see:
|
||||||
# https://github.com/testdouble/standard
|
# https://github.com/testdouble/standard
|
||||||
|
ruby_version: <%= ::Gem::Version.new(config[:required_ruby_version]).segments[0..1].join(".") %>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class Test<%= config[:constant_name] %> < Minitest::Test
|
class <%= config[:minitest_constant_name] %> < Minitest::Test
|
||||||
def test_that_it_has_a_version_number
|
def test_that_it_has_a_version_number
|
||||||
refute_nil ::<%= config[:constant_name] %>::VERSION
|
refute_nil ::<%= config[:constant_name] %>::VERSION
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,10 +107,7 @@ class Bundler::Thor
|
||||||
#
|
#
|
||||||
def replace!(regexp, string, force)
|
def replace!(regexp, string, force)
|
||||||
content = File.read(destination)
|
content = File.read(destination)
|
||||||
before, after = content.split(regexp, 2)
|
if force || !content.include?(replacement)
|
||||||
snippet = (behavior == :after ? after : before).to_s
|
|
||||||
|
|
||||||
if force || !snippet.include?(replacement)
|
|
||||||
success = content.gsub!(regexp, string)
|
success = content.gsub!(regexp, string)
|
||||||
|
|
||||||
File.open(destination, "wb") { |file| file.write(content) } unless pretend?
|
File.open(destination, "wb") { |file| file.write(content) } unless pretend?
|
||||||
|
|
2
lib/bundler/vendor/thor/lib/thor/version.rb
vendored
2
lib/bundler/vendor/thor/lib/thor/version.rb
vendored
|
@ -1,3 +1,3 @@
|
||||||
class Bundler::Thor
|
class Bundler::Thor
|
||||||
VERSION = "1.1.0"
|
VERSION = "1.2.1"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: false
|
||||||
|
|
||||||
module Bundler
|
module Bundler
|
||||||
VERSION = "2.3.3".freeze
|
VERSION = "2.3.6".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
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
module Gem
|
module Gem
|
||||||
VERSION = "3.3.3".freeze
|
VERSION = "3.3.6".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
|
||||||
|
@ -606,17 +606,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
def self.load_yaml
|
def self.load_yaml
|
||||||
return if @yaml_loaded
|
return if @yaml_loaded
|
||||||
|
|
||||||
begin
|
require 'psych'
|
||||||
# Try requiring the gem version *or* stdlib version of psych.
|
require_relative 'rubygems/psych_additions'
|
||||||
require 'psych'
|
require_relative 'rubygems/psych_tree'
|
||||||
rescue ::LoadError
|
|
||||||
# If we can't load psych, that's fine, go on.
|
|
||||||
else
|
|
||||||
require_relative 'rubygems/psych_additions'
|
|
||||||
require_relative 'rubygems/psych_tree'
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'yaml'
|
|
||||||
require_relative 'rubygems/safe_yaml'
|
require_relative 'rubygems/safe_yaml'
|
||||||
|
|
||||||
@yaml_loaded = true
|
@yaml_loaded = true
|
||||||
|
@ -766,11 +759,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
# Safely read a file in binary mode on all platforms.
|
# Safely read a file in binary mode on all platforms.
|
||||||
|
|
||||||
def self.read_binary(path)
|
def self.read_binary(path)
|
||||||
open_with_flock(path, 'rb+') do |io|
|
open_file(path, 'rb+') do |io|
|
||||||
io.read
|
io.read
|
||||||
end
|
end
|
||||||
rescue Errno::EACCES, Errno::EROFS
|
rescue Errno::EACCES, Errno::EROFS
|
||||||
open_with_flock(path, 'rb') do |io|
|
open_file(path, 'rb') do |io|
|
||||||
io.read
|
io.read
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -778,17 +771,17 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
##
|
##
|
||||||
# Safely write a file in binary mode on all platforms.
|
# Safely write a file in binary mode on all platforms.
|
||||||
def self.write_binary(path, data)
|
def self.write_binary(path, data)
|
||||||
open_with_flock(path, 'wb') do |io|
|
open_file(path, 'wb') do |io|
|
||||||
io.write data
|
io.write data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Open a file with given flags, and protect access with flock
|
# Open a file with given flags, and on Windows protect access with flock
|
||||||
|
|
||||||
def self.open_with_flock(path, flags, &block)
|
def self.open_file(path, flags, &block)
|
||||||
File.open(path, flags) do |io|
|
File.open(path, flags) do |io|
|
||||||
if !java_platform? && !solaris_platform?
|
if !java_platform? && win_platform?
|
||||||
begin
|
begin
|
||||||
io.flock(File::LOCK_EX)
|
io.flock(File::LOCK_EX)
|
||||||
rescue Errno::ENOSYS, Errno::ENOTSUP
|
rescue Errno::ENOSYS, Errno::ENOTSUP
|
||||||
|
@ -1316,6 +1309,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
autoload :Source, File.expand_path('rubygems/source', __dir__)
|
autoload :Source, File.expand_path('rubygems/source', __dir__)
|
||||||
autoload :SourceList, File.expand_path('rubygems/source_list', __dir__)
|
autoload :SourceList, File.expand_path('rubygems/source_list', __dir__)
|
||||||
autoload :SpecFetcher, File.expand_path('rubygems/spec_fetcher', __dir__)
|
autoload :SpecFetcher, File.expand_path('rubygems/spec_fetcher', __dir__)
|
||||||
|
autoload :SpecificationPolicy, File.expand_path('rubygems/specification_policy', __dir__)
|
||||||
autoload :Util, File.expand_path('rubygems/util', __dir__)
|
autoload :Util, File.expand_path('rubygems/util', __dir__)
|
||||||
autoload :Version, File.expand_path('rubygems/version', __dir__)
|
autoload :Version, File.expand_path('rubygems/version', __dir__)
|
||||||
end
|
end
|
||||||
|
|
|
@ -289,14 +289,14 @@ class Gem::BasicSpecification
|
||||||
|
|
||||||
def lib_dirs_glob
|
def lib_dirs_glob
|
||||||
dirs = if self.raw_require_paths
|
dirs = if self.raw_require_paths
|
||||||
if self.raw_require_paths.size > 1
|
if self.raw_require_paths.size > 1
|
||||||
"{#{self.raw_require_paths.join(',')}}"
|
"{#{self.raw_require_paths.join(',')}}"
|
||||||
else
|
else
|
||||||
self.raw_require_paths.first
|
self.raw_require_paths.first
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
"lib" # default value for require_paths for bundler/inline
|
"lib" # default value for require_paths for bundler/inline
|
||||||
end
|
end
|
||||||
|
|
||||||
"#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT)
|
"#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,9 +65,9 @@ module Gem::BundlerVersionFinder
|
||||||
return unless gemfile
|
return unless gemfile
|
||||||
|
|
||||||
lockfile = case gemfile
|
lockfile = case gemfile
|
||||||
when "gems.rb" then "gems.locked"
|
when "gems.rb" then "gems.locked"
|
||||||
else "#{gemfile}.lock"
|
else "#{gemfile}.lock"
|
||||||
end.dup.tap(&Gem::UNTAINT)
|
end.dup.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
return unless File.file?(lockfile)
|
return unless File.file?(lockfile)
|
||||||
|
|
||||||
|
|
|
@ -398,10 +398,10 @@ class Gem::Command
|
||||||
version_to_expire = deprecation["rg_version_to_expire"]
|
version_to_expire = deprecation["rg_version_to_expire"]
|
||||||
|
|
||||||
deprecate_option_msg = if version_to_expire
|
deprecate_option_msg = if version_to_expire
|
||||||
"The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}."
|
"The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}."
|
||||||
else
|
else
|
||||||
"The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems."
|
"The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems."
|
||||||
end
|
end
|
||||||
|
|
||||||
extra_msg = deprecation["extra_msg"]
|
extra_msg = deprecation["extra_msg"]
|
||||||
|
|
||||||
|
|
|
@ -117,12 +117,12 @@ If no gems are named all gems in GEM_HOME are cleaned.
|
||||||
|
|
||||||
def get_candidate_gems
|
def get_candidate_gems
|
||||||
@candidate_gems = unless options[:args].empty?
|
@candidate_gems = unless options[:args].empty?
|
||||||
options[:args].map do |gem_name|
|
options[:args].map do |gem_name|
|
||||||
Gem::Specification.find_all_by_name gem_name
|
Gem::Specification.find_all_by_name gem_name
|
||||||
end.flatten
|
end.flatten
|
||||||
else
|
else
|
||||||
Gem::Specification.to_a
|
Gem::Specification.to_a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_gems_to_cleanup
|
def get_gems_to_cleanup
|
||||||
|
|
|
@ -53,41 +53,41 @@ use with other commands.
|
||||||
"#{program_name} REGEXP"
|
"#{program_name} REGEXP"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_remote_specs(dependency) # :nodoc:
|
def fetch_remote_specs(name, requirement, prerelease) # :nodoc:
|
||||||
fetcher = Gem::SpecFetcher.fetcher
|
fetcher = Gem::SpecFetcher.fetcher
|
||||||
|
|
||||||
ss, = fetcher.spec_for_dependency dependency
|
specs_type = prerelease ? :complete : :released
|
||||||
|
|
||||||
ss.map {|spec, _| spec }
|
ss = if name.nil?
|
||||||
|
fetcher.detect(specs_type) { true }
|
||||||
|
else
|
||||||
|
fetcher.detect(specs_type) do |name_tuple|
|
||||||
|
name === name_tuple.name && requirement.satisfied_by?(name_tuple.version)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ss.map {|tuple, source| source.fetch_spec(tuple) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_specs(name_pattern, dependency) # :nodoc:
|
def fetch_specs(name_pattern, requirement, prerelease) # :nodoc:
|
||||||
specs = []
|
specs = []
|
||||||
|
|
||||||
if local?
|
if local?
|
||||||
specs.concat Gem::Specification.stubs.find_all {|spec|
|
specs.concat Gem::Specification.stubs.find_all {|spec|
|
||||||
name_pattern =~ spec.name and
|
name_matches = name_pattern ? name_pattern =~ spec.name : true
|
||||||
dependency.requirement.satisfied_by? spec.version
|
version_matches = requirement.satisfied_by?(spec.version)
|
||||||
|
|
||||||
|
name_matches and version_matches
|
||||||
}.map(&:to_spec)
|
}.map(&:to_spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
specs.concat fetch_remote_specs dependency if remote?
|
specs.concat fetch_remote_specs name_pattern, requirement, prerelease if remote?
|
||||||
|
|
||||||
ensure_specs specs
|
ensure_specs specs
|
||||||
|
|
||||||
specs.uniq.sort
|
specs.uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def gem_dependency(pattern, version, prerelease) # :nodoc:
|
|
||||||
dependency = Gem::Deprecate.skip_during do
|
|
||||||
Gem::Dependency.new pattern, version
|
|
||||||
end
|
|
||||||
|
|
||||||
dependency.prerelease = prerelease
|
|
||||||
|
|
||||||
dependency
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_pipe(specs) # :nodoc:
|
def display_pipe(specs) # :nodoc:
|
||||||
specs.each do |spec|
|
specs.each do |spec|
|
||||||
unless spec.dependencies.empty?
|
unless spec.dependencies.empty?
|
||||||
|
@ -119,11 +119,9 @@ use with other commands.
|
||||||
ensure_local_only_reverse_dependencies
|
ensure_local_only_reverse_dependencies
|
||||||
|
|
||||||
pattern = name_pattern options[:args]
|
pattern = name_pattern options[:args]
|
||||||
|
requirement = Gem::Requirement.new options[:version]
|
||||||
|
|
||||||
dependency =
|
specs = fetch_specs pattern, requirement, options[:prerelease]
|
||||||
gem_dependency pattern, options[:version], options[:prerelease]
|
|
||||||
|
|
||||||
specs = fetch_specs pattern, dependency
|
|
||||||
|
|
||||||
reverse = reverse_dependencies specs
|
reverse = reverse_dependencies specs
|
||||||
|
|
||||||
|
@ -162,14 +160,6 @@ use with other commands.
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote_specs(dependency) # :nodoc:
|
|
||||||
fetcher = Gem::SpecFetcher.fetcher
|
|
||||||
|
|
||||||
ss, _ = fetcher.spec_for_dependency dependency
|
|
||||||
|
|
||||||
ss.map {|s,o| s }
|
|
||||||
end
|
|
||||||
|
|
||||||
def reverse_dependencies(specs) # :nodoc:
|
def reverse_dependencies(specs) # :nodoc:
|
||||||
reverse = Hash.new {|h, k| h[k] = [] }
|
reverse = Hash.new {|h, k| h[k] = [] }
|
||||||
|
|
||||||
|
@ -205,7 +195,7 @@ use with other commands.
|
||||||
private
|
private
|
||||||
|
|
||||||
def name_pattern(args)
|
def name_pattern(args)
|
||||||
args << '' if args.empty?
|
return if args.empty?
|
||||||
|
|
||||||
if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
|
if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
|
||||||
flags = $2 ? Regexp::IGNORECASE : nil
|
flags = $2 ? Regexp::IGNORECASE : nil
|
||||||
|
|
|
@ -8,7 +8,12 @@ class Gem::Commands::FetchCommand < Gem::Command
|
||||||
include Gem::VersionOption
|
include Gem::VersionOption
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super 'fetch', 'Download a gem and place it in the current directory'
|
defaults = {
|
||||||
|
:suggest_alternate => true,
|
||||||
|
:version => Gem::Requirement.default,
|
||||||
|
}
|
||||||
|
|
||||||
|
super 'fetch', 'Download a gem and place it in the current directory', defaults
|
||||||
|
|
||||||
add_bulk_threshold_option
|
add_bulk_threshold_option
|
||||||
add_proxy_option
|
add_proxy_option
|
||||||
|
@ -18,6 +23,10 @@ class Gem::Commands::FetchCommand < Gem::Command
|
||||||
add_version_option
|
add_version_option
|
||||||
add_platform_option
|
add_platform_option
|
||||||
add_prerelease_option
|
add_prerelease_option
|
||||||
|
|
||||||
|
add_option '--[no-]suggestions', 'Suggest alternates when gems are not found' do |value, options|
|
||||||
|
options[:suggest_alternate] = value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def arguments # :nodoc:
|
def arguments # :nodoc:
|
||||||
|
@ -42,15 +51,27 @@ then repackaging it.
|
||||||
"#{program_name} GEMNAME [GEMNAME ...]"
|
"#{program_name} GEMNAME [GEMNAME ...]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_version # :nodoc:
|
||||||
|
if options[:version] != Gem::Requirement.default and
|
||||||
|
get_all_gem_names.size > 1
|
||||||
|
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
|
||||||
|
" version requirements using `gem fetch 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
|
||||||
|
terminate_interaction 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
version = options[:version] || Gem::Requirement.default
|
check_version
|
||||||
|
version = options[:version]
|
||||||
|
|
||||||
platform = Gem.platforms.last
|
platform = Gem.platforms.last
|
||||||
gem_names = get_all_gem_names
|
gem_names = get_all_gem_names_and_versions
|
||||||
|
|
||||||
gem_names.each do |gem_name|
|
gem_names.each do |gem_name, gem_version|
|
||||||
dep = Gem::Dependency.new gem_name, version
|
gem_version ||= version
|
||||||
|
dep = Gem::Dependency.new gem_name, gem_version
|
||||||
dep.prerelease = options[:prerelease]
|
dep.prerelease = options[:prerelease]
|
||||||
|
suppress_suggestions = !options[:suggest_alternate]
|
||||||
|
|
||||||
specs_and_sources, errors =
|
specs_and_sources, errors =
|
||||||
Gem::SpecFetcher.fetcher.spec_for_dependency dep
|
Gem::SpecFetcher.fetcher.spec_for_dependency dep
|
||||||
|
@ -63,12 +84,10 @@ then repackaging it.
|
||||||
spec, source = specs_and_sources.max_by {|s,| s }
|
spec, source = specs_and_sources.max_by {|s,| s }
|
||||||
|
|
||||||
if spec.nil?
|
if spec.nil?
|
||||||
show_lookup_failure gem_name, version, errors, options[:domain]
|
show_lookup_failure gem_name, gem_version, errors, suppress_suggestions, options[:domain]
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
source.download spec
|
source.download spec
|
||||||
|
|
||||||
say "Downloaded #{spec.full_name}"
|
say "Downloaded #{spec.full_name}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Gem::Commands::ListCommand < Gem::Command
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super 'list', 'Display local gems whose name matches REGEXP',
|
super 'list', 'Display local gems whose name matches REGEXP',
|
||||||
:name => //, :domain => :local, :details => false, :versions => true,
|
:domain => :local, :details => false, :versions => true,
|
||||||
:installed => nil, :version => Gem::Requirement.default
|
:installed => nil, :version => Gem::Requirement.default
|
||||||
|
|
||||||
add_query_options
|
add_query_options
|
||||||
|
|
|
@ -98,20 +98,20 @@ extensions will be restored.
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
specs = if options[:all]
|
specs = if options[:all]
|
||||||
Gem::Specification.map
|
Gem::Specification.map
|
||||||
|
|
||||||
# `--extensions` must be explicitly given to pristine only gems
|
# `--extensions` must be explicitly given to pristine only gems
|
||||||
# with extensions.
|
# with extensions.
|
||||||
elsif options[:extensions_set] and
|
elsif options[:extensions_set] and
|
||||||
options[:extensions] and options[:args].empty?
|
options[:extensions] and options[:args].empty?
|
||||||
Gem::Specification.select do |spec|
|
Gem::Specification.select do |spec|
|
||||||
spec.extensions and not spec.extensions.empty?
|
spec.extensions and not spec.extensions.empty?
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
get_all_gem_names.sort.map do |gem_name|
|
get_all_gem_names.sort.map do |gem_name|
|
||||||
Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse
|
Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse
|
||||||
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 }
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,14 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
|
||||||
default_gem_server, push_host = get_hosts_for(gem_name)
|
default_gem_server, push_host = get_hosts_for(gem_name)
|
||||||
|
|
||||||
@host = if @user_defined_host
|
@host = if @user_defined_host
|
||||||
options[:host]
|
options[:host]
|
||||||
elsif default_gem_server
|
elsif default_gem_server
|
||||||
default_gem_server
|
default_gem_server
|
||||||
elsif push_host
|
elsif push_host
|
||||||
push_host
|
push_host
|
||||||
else
|
else
|
||||||
options[:host]
|
options[:host]
|
||||||
end
|
end
|
||||||
|
|
||||||
sign_in @host, scope: get_push_scope
|
sign_in @host, scope: get_push_scope
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Gem::Commands::QueryCommand < Gem::Command
|
||||||
def initialize(name = 'query',
|
def initialize(name = 'query',
|
||||||
summary = 'Query gem information in local or remote repositories')
|
summary = 'Query gem information in local or remote repositories')
|
||||||
super name, summary,
|
super name, summary,
|
||||||
:name => //, :domain => :local, :details => false, :versions => true,
|
:domain => :local, :details => false, :versions => true,
|
||||||
:installed => nil, :version => Gem::Requirement.default
|
:installed => nil, :version => Gem::Requirement.default
|
||||||
|
|
||||||
add_option('-n', '--name-matches REGEXP',
|
add_option('-n', '--name-matches REGEXP',
|
||||||
|
|
|
@ -61,12 +61,12 @@ Use --overwrite to force rebuilding of documentation.
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
specs = if options[:all]
|
specs = if options[:all]
|
||||||
Gem::Specification.to_a
|
Gem::Specification.to_a
|
||||||
else
|
else
|
||||||
get_all_gem_names.map do |name|
|
get_all_gem_names.map do |name|
|
||||||
Gem::Specification.find_by_name name, options[:version]
|
Gem::Specification.find_by_name name, options[:version]
|
||||||
end.flatten.uniq
|
end.flatten.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
if specs.empty?
|
if specs.empty?
|
||||||
alert_error 'No matching gems found'
|
alert_error 'No matching gems found'
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Gem::Commands::SearchCommand < Gem::Command
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super 'search', 'Display remote gems whose name matches REGEXP',
|
super 'search', 'Display remote gems whose name matches REGEXP',
|
||||||
:name => //, :domain => :remote, :details => false, :versions => true,
|
:domain => :remote, :details => false, :versions => true,
|
||||||
:installed => nil, :version => Gem::Requirement.default
|
:installed => nil, :version => Gem::Requirement.default
|
||||||
|
|
||||||
add_query_options
|
add_query_options
|
||||||
|
|
|
@ -54,10 +54,10 @@ class Gem::Commands::SetupCommand < Gem::Command
|
||||||
'List the documentation types you wish to',
|
'List the documentation types you wish to',
|
||||||
'generate. For example: rdoc,ri' do |value, options|
|
'generate. For example: rdoc,ri' do |value, options|
|
||||||
options[:document] = case value
|
options[:document] = case value
|
||||||
when nil then %w[rdoc ri]
|
when nil then %w[rdoc ri]
|
||||||
when false then []
|
when false then []
|
||||||
else value
|
else value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option '--[no-]rdoc',
|
add_option '--[no-]rdoc',
|
||||||
|
@ -666,10 +666,10 @@ abort "#{deprecation_message}"
|
||||||
|
|
||||||
def target_bin_path(bin_dir, bin_file)
|
def target_bin_path(bin_dir, bin_file)
|
||||||
bin_file_formatted = if options[:format_executable]
|
bin_file_formatted = if options[:format_executable]
|
||||||
Gem.default_exec_format % bin_file
|
Gem.default_exec_format % bin_file
|
||||||
else
|
else
|
||||||
bin_file
|
bin_file
|
||||||
end
|
end
|
||||||
File.join bin_dir, bin_file_formatted
|
File.join bin_dir, bin_file_formatted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -140,10 +140,10 @@ Specific fields in the specification can be extracted in YAML format:
|
||||||
s = s.send field if field
|
s = s.send field if field
|
||||||
|
|
||||||
say case options[:format]
|
say case options[:format]
|
||||||
when :ruby then s.to_ruby
|
when :ruby then s.to_ruby
|
||||||
when :marshal then Marshal.dump s
|
when :marshal then Marshal.dump s
|
||||||
else s.to_yaml
|
else s.to_yaml
|
||||||
end
|
end
|
||||||
|
|
||||||
say "\n"
|
say "\n"
|
||||||
end
|
end
|
||||||
|
|
|
@ -233,10 +233,10 @@ command to remove old versions.
|
||||||
up_ver = gems_to_update.first.version
|
up_ver = gems_to_update.first.version
|
||||||
|
|
||||||
target = if update_latest
|
target = if update_latest
|
||||||
up_ver
|
up_ver
|
||||||
else
|
else
|
||||||
version
|
version
|
||||||
end
|
end
|
||||||
|
|
||||||
return target, requirement
|
return target, requirement
|
||||||
end
|
end
|
||||||
|
@ -286,10 +286,11 @@ command to remove old versions.
|
||||||
|
|
||||||
check_oldest_rubygems version
|
check_oldest_rubygems version
|
||||||
|
|
||||||
update_gem 'rubygems-update', version
|
|
||||||
|
|
||||||
installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement
|
installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement
|
||||||
version = installed_gems.first.version
|
installed_gems = update_gem('rubygems-update', version) if installed_gems.empty? || installed_gems.first.version != version
|
||||||
|
return if installed_gems.empty?
|
||||||
|
|
||||||
|
version = installed_gems.first.version
|
||||||
|
|
||||||
install_rubygems version
|
install_rubygems version
|
||||||
end
|
end
|
||||||
|
@ -335,7 +336,9 @@ command to remove old versions.
|
||||||
#
|
#
|
||||||
def oldest_supported_version
|
def oldest_supported_version
|
||||||
@oldest_supported_version ||=
|
@oldest_supported_version ||=
|
||||||
if Gem.ruby_version > Gem::Version.new("3.0.a")
|
if Gem.ruby_version > Gem::Version.new("3.1.a")
|
||||||
|
Gem::Version.new("3.3.3")
|
||||||
|
elsif Gem.ruby_version > Gem::Version.new("3.0.a")
|
||||||
Gem::Version.new("3.2.3")
|
Gem::Version.new("3.2.3")
|
||||||
elsif Gem.ruby_version > Gem::Version.new("2.7.a")
|
elsif Gem.ruby_version > Gem::Version.new("2.7.a")
|
||||||
Gem::Version.new("3.1.2")
|
Gem::Version.new("3.1.2")
|
||||||
|
|
|
@ -281,10 +281,10 @@ if you believe they were disclosed to a third party.
|
||||||
check_credentials_permissions
|
check_credentials_permissions
|
||||||
|
|
||||||
@api_keys = if File.exist? credentials_path
|
@api_keys = if File.exist? credentials_path
|
||||||
load_file(credentials_path)
|
load_file(credentials_path)
|
||||||
else
|
else
|
||||||
@hash
|
@hash
|
||||||
end
|
end
|
||||||
|
|
||||||
if @api_keys.key? :rubygems_api_key
|
if @api_keys.key? :rubygems_api_key
|
||||||
@rubygems_api_key = @api_keys[:rubygems_api_key]
|
@rubygems_api_key = @api_keys[:rubygems_api_key]
|
||||||
|
|
|
@ -117,11 +117,11 @@ class Gem::Doctor
|
||||||
type = File.directory?(child) ? 'directory' : 'file'
|
type = File.directory?(child) ? 'directory' : 'file'
|
||||||
|
|
||||||
action = if @dry_run
|
action = if @dry_run
|
||||||
'Extra'
|
'Extra'
|
||||||
else
|
else
|
||||||
FileUtils.rm_r(child)
|
FileUtils.rm_r(child)
|
||||||
'Removed'
|
'Removed'
|
||||||
end
|
end
|
||||||
|
|
||||||
say "#{action} #{type} #{sub_directory}/#{File.basename(child)}"
|
say "#{action} #{type} #{sub_directory}/#{File.basename(child)}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,11 +42,11 @@ class Gem::GemRunner
|
||||||
cmd.command_names.each do |command_name|
|
cmd.command_names.each do |command_name|
|
||||||
config_args = Gem.configuration[command_name]
|
config_args = Gem.configuration[command_name]
|
||||||
config_args = case config_args
|
config_args = case config_args
|
||||||
when String
|
when String
|
||||||
config_args.split ' '
|
config_args.split ' '
|
||||||
else
|
else
|
||||||
Array(config_args)
|
Array(config_args)
|
||||||
end
|
end
|
||||||
Gem::Command.add_specific_extra_args command_name, config_args
|
Gem::Command.add_specific_extra_args command_name, config_args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,10 @@ module Gem::InstallUpdateOptions
|
||||||
'List the documentation types you wish to',
|
'List the documentation types you wish to',
|
||||||
'generate. For example: rdoc,ri') do |value, options|
|
'generate. For example: rdoc,ri') do |value, options|
|
||||||
options[:document] = case value
|
options[:document] = case value
|
||||||
when nil then %w[ri]
|
when nil then %w[ri]
|
||||||
when false then []
|
when false then []
|
||||||
else value
|
else value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option(:"Install/Update", '--build-root DIR',
|
add_option(:"Install/Update", '--build-root DIR',
|
||||||
|
|
|
@ -201,8 +201,8 @@ class Gem::Installer
|
||||||
#
|
#
|
||||||
# If +@force+ is set +filename+ is overwritten.
|
# If +@force+ is set +filename+ is overwritten.
|
||||||
#
|
#
|
||||||
# If +filename+ exists and is a RubyGems wrapper for different gem the user
|
# If +filename+ exists and it is a RubyGems wrapper for a different gem, then
|
||||||
# is consulted.
|
# the user is consulted.
|
||||||
#
|
#
|
||||||
# If +filename+ exists and +@bin_dir+ is Gem.default_bindir (/usr/local) the
|
# If +filename+ exists and +@bin_dir+ is Gem.default_bindir (/usr/local) the
|
||||||
# user is consulted.
|
# user is consulted.
|
||||||
|
@ -220,7 +220,17 @@ class Gem::Installer
|
||||||
existing = nil
|
existing = nil
|
||||||
|
|
||||||
File.open generated_bin, 'rb' do |io|
|
File.open generated_bin, 'rb' do |io|
|
||||||
next unless io.gets =~ /^#!/ # shebang
|
line = io.gets
|
||||||
|
shebang = /^#!.*ruby/
|
||||||
|
|
||||||
|
if load_relative_enabled?
|
||||||
|
until line.nil? || line =~ shebang do
|
||||||
|
line = io.gets
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
next unless line =~ shebang
|
||||||
|
|
||||||
io.gets # blankline
|
io.gets # blankline
|
||||||
|
|
||||||
# TODO detect a specially formatted comment instead of trying
|
# TODO detect a specially formatted comment instead of trying
|
||||||
|
@ -585,7 +595,6 @@ class Gem::Installer
|
||||||
#
|
#
|
||||||
|
|
||||||
def shebang(bin_file_name)
|
def shebang(bin_file_name)
|
||||||
ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang
|
|
||||||
path = File.join gem_dir, spec.bindir, bin_file_name
|
path = File.join gem_dir, spec.bindir, bin_file_name
|
||||||
first_line = File.open(path, "rb") {|file| file.gets } || ""
|
first_line = File.open(path, "rb") {|file| file.gets } || ""
|
||||||
|
|
||||||
|
@ -598,7 +607,7 @@ class Gem::Installer
|
||||||
|
|
||||||
if which = Gem.configuration[:custom_shebang]
|
if which = Gem.configuration[:custom_shebang]
|
||||||
# replace bin_file_name with "ruby" to avoid endless loops
|
# replace bin_file_name with "ruby" to avoid endless loops
|
||||||
which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}")
|
which = which.gsub(/ #{bin_file_name}$/," #{ruby_install_name}")
|
||||||
|
|
||||||
which = which.gsub(/\$(\w+)/) do
|
which = which.gsub(/\$(\w+)/) do
|
||||||
case $1
|
case $1
|
||||||
|
@ -614,14 +623,12 @@ class Gem::Installer
|
||||||
end
|
end
|
||||||
|
|
||||||
"#!#{which}"
|
"#!#{which}"
|
||||||
elsif not ruby_name
|
elsif @env_shebang
|
||||||
"#!#{Gem.ruby}#{opts}"
|
|
||||||
elsif opts
|
|
||||||
"#!/bin/sh\n'exec' #{ruby_name.dump} '-x' \"$0\" \"$@\"\n#{shebang}"
|
|
||||||
else
|
|
||||||
# Create a plain shebang line.
|
# Create a plain shebang line.
|
||||||
@env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
|
@env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
|
||||||
"#!#{@env_path} #{ruby_name}"
|
"#!#{@env_path} #{ruby_install_name}"
|
||||||
|
else
|
||||||
|
"#{bash_prolog_script}#!#{Gem.ruby}#{opts}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -805,7 +812,6 @@ TEXT
|
||||||
# return the stub script text used to launch the true Ruby script
|
# return the stub script text used to launch the true Ruby script
|
||||||
|
|
||||||
def windows_stub_script(bindir, bin_file_name)
|
def windows_stub_script(bindir, bin_file_name)
|
||||||
rb_config = RbConfig::CONFIG
|
|
||||||
rb_topdir = RbConfig::TOPDIR || File.dirname(rb_config["bindir"])
|
rb_topdir = RbConfig::TOPDIR || File.dirname(rb_config["bindir"])
|
||||||
|
|
||||||
# get ruby executable file name from RbConfig
|
# get ruby executable file name from RbConfig
|
||||||
|
@ -973,4 +979,37 @@ TEXT
|
||||||
Gem::Command.build_args
|
Gem::Command.build_args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rb_config
|
||||||
|
RbConfig::CONFIG
|
||||||
|
end
|
||||||
|
|
||||||
|
def ruby_install_name
|
||||||
|
rb_config["ruby_install_name"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_relative_enabled?
|
||||||
|
rb_config["LIBRUBY_RELATIVE"] == 'yes'
|
||||||
|
end
|
||||||
|
|
||||||
|
def bash_prolog_script
|
||||||
|
if load_relative_enabled?
|
||||||
|
script = +<<~EOS
|
||||||
|
bindir="${0%/*}"
|
||||||
|
EOS
|
||||||
|
|
||||||
|
script << %Q(exec "$bindir/#{ruby_install_name}" "-x" "$0" "$@"\n)
|
||||||
|
|
||||||
|
<<~EOS
|
||||||
|
#!/bin/sh
|
||||||
|
# -*- ruby -*-
|
||||||
|
_=_\\
|
||||||
|
=begin
|
||||||
|
#{script.chomp}
|
||||||
|
=end
|
||||||
|
EOS
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -146,12 +146,12 @@ class Gem::Package
|
||||||
|
|
||||||
def self.new(gem, security_policy = nil)
|
def self.new(gem, security_policy = nil)
|
||||||
gem = if gem.is_a?(Gem::Package::Source)
|
gem = if gem.is_a?(Gem::Package::Source)
|
||||||
gem
|
gem
|
||||||
elsif gem.respond_to? :read
|
elsif gem.respond_to? :read
|
||||||
Gem::Package::IOSource.new gem
|
Gem::Package::IOSource.new gem
|
||||||
else
|
else
|
||||||
Gem::Package::FileSource.new gem
|
Gem::Package::FileSource.new gem
|
||||||
end
|
end
|
||||||
|
|
||||||
return super unless Gem::Package == self
|
return super unless Gem::Package == self
|
||||||
return super unless gem.present?
|
return super unless gem.present?
|
||||||
|
@ -230,7 +230,7 @@ class Gem::Package
|
||||||
|
|
||||||
tar.add_file_signed 'checksums.yaml.gz', 0444, @signer do |io|
|
tar.add_file_signed 'checksums.yaml.gz', 0444, @signer do |io|
|
||||||
gzip_to io do |gz_io|
|
gzip_to io do |gz_io|
|
||||||
YAML.dump checksums_by_algorithm, gz_io
|
Psych.dump checksums_by_algorithm, gz_io
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -353,10 +353,10 @@ EOM
|
||||||
|
|
||||||
def digest(entry) # :nodoc:
|
def digest(entry) # :nodoc:
|
||||||
algorithms = if @checksums
|
algorithms = if @checksums
|
||||||
@checksums.keys
|
@checksums.keys
|
||||||
else
|
else
|
||||||
[Gem::Security::DIGEST_NAME].compact
|
[Gem::Security::DIGEST_NAME].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
algorithms.each do |algorithm|
|
algorithms.each do |algorithm|
|
||||||
digester = Gem::Security.create_digest(algorithm)
|
digester = Gem::Security.create_digest(algorithm)
|
||||||
|
|
|
@ -145,7 +145,7 @@ class Gem::Package::Old < Gem::Package
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@spec = Gem::Specification.from_yaml yaml
|
@spec = Gem::Specification.from_yaml yaml
|
||||||
rescue YAML::SyntaxError
|
rescue Psych::SyntaxError
|
||||||
raise Gem::Exception, "Failed to parse gem specification out of gem file"
|
raise Gem::Exception, "Failed to parse gem specification out of gem file"
|
||||||
end
|
end
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
|
|
|
@ -78,9 +78,9 @@ class Gem::Platform
|
||||||
cpu = arch.shift
|
cpu = arch.shift
|
||||||
|
|
||||||
@cpu = case cpu
|
@cpu = case cpu
|
||||||
when /i\d86/ then 'x86'
|
when /i\d86/ then 'x86'
|
||||||
else cpu
|
else cpu
|
||||||
end
|
end
|
||||||
|
|
||||||
if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ # for command-line
|
if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ # for command-line
|
||||||
@os, @version = arch
|
@os, @version = arch
|
||||||
|
@ -91,32 +91,32 @@ class Gem::Platform
|
||||||
@cpu, os = nil, cpu if os.nil? # legacy jruby
|
@cpu, os = nil, cpu if os.nil? # legacy jruby
|
||||||
|
|
||||||
@os, @version = case os
|
@os, @version = case os
|
||||||
when /aix(\d+)?/ then [ 'aix', $1 ]
|
when /aix(\d+)?/ then [ 'aix', $1 ]
|
||||||
when /cygwin/ then [ 'cygwin', nil ]
|
when /cygwin/ then [ 'cygwin', nil ]
|
||||||
when /darwin(\d+)?/ then [ 'darwin', $1 ]
|
when /darwin(\d+)?/ then [ 'darwin', $1 ]
|
||||||
when /^macruby$/ then [ 'macruby', nil ]
|
when /^macruby$/ then [ 'macruby', nil ]
|
||||||
when /freebsd(\d+)?/ then [ 'freebsd', $1 ]
|
when /freebsd(\d+)?/ then [ 'freebsd', $1 ]
|
||||||
when /hpux(\d+)?/ then [ 'hpux', $1 ]
|
when /hpux(\d+)?/ then [ 'hpux', $1 ]
|
||||||
when /^java$/, /^jruby$/ then [ 'java', nil ]
|
when /^java$/, /^jruby$/ then [ 'java', nil ]
|
||||||
when /^java([\d.]*)/ then [ 'java', $1 ]
|
when /^java([\d.]*)/ then [ 'java', $1 ]
|
||||||
when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ]
|
when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ]
|
||||||
when /^dotnet$/ then [ 'dotnet', nil ]
|
when /^dotnet$/ then [ 'dotnet', nil ]
|
||||||
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
|
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
|
||||||
when /linux-?((?!gnu)\w+)?/ then [ 'linux', $1 ]
|
when /linux-?((?!gnu)\w+)?/ then [ 'linux', $1 ]
|
||||||
when /mingw32/ then [ 'mingw32', nil ]
|
when /mingw32/ then [ 'mingw32', nil ]
|
||||||
when /mingw-?(\w+)?/ then [ 'mingw', $1 ]
|
when /mingw-?(\w+)?/ then [ 'mingw', $1 ]
|
||||||
when /(mswin\d+)(\_(\d+))?/ then
|
when /(mswin\d+)(\_(\d+))?/ then
|
||||||
os, version = $1, $3
|
os, version = $1, $3
|
||||||
@cpu = 'x86' if @cpu.nil? and os =~ /32$/
|
@cpu = 'x86' if @cpu.nil? and os =~ /32$/
|
||||||
[os, version]
|
[os, version]
|
||||||
when /netbsdelf/ then [ 'netbsdelf', nil ]
|
when /netbsdelf/ then [ 'netbsdelf', nil ]
|
||||||
when /openbsd(\d+\.\d+)?/ then [ 'openbsd', $1 ]
|
when /openbsd(\d+\.\d+)?/ then [ 'openbsd', $1 ]
|
||||||
when /bitrig(\d+\.\d+)?/ then [ 'bitrig', $1 ]
|
when /bitrig(\d+\.\d+)?/ then [ 'bitrig', $1 ]
|
||||||
when /solaris(\d+\.\d+)?/ then [ 'solaris', $1 ]
|
when /solaris(\d+\.\d+)?/ then [ 'solaris', $1 ]
|
||||||
# test
|
# test
|
||||||
when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]
|
when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]
|
||||||
else [ 'unknown', nil ]
|
else [ 'unknown', nil ]
|
||||||
end
|
end
|
||||||
when Gem::Platform then
|
when Gem::Platform then
|
||||||
@cpu = arch.cpu
|
@cpu = arch.cpu
|
||||||
@os = arch.os
|
@os = arch.os
|
||||||
|
@ -180,19 +180,19 @@ class Gem::Platform
|
||||||
when String then
|
when String then
|
||||||
# This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
|
# This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
|
||||||
other = case other
|
other = case other
|
||||||
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
|
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
|
||||||
when /^i\d86-linux/ then ['x86', 'linux', nil ]
|
when /^i\d86-linux/ then ['x86', 'linux', nil ]
|
||||||
when 'java', 'jruby' then [nil, 'java', nil ]
|
when 'java', 'jruby' then [nil, 'java', nil ]
|
||||||
when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ]
|
when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ]
|
||||||
when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ]
|
when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ]
|
||||||
when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ]
|
when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ]
|
||||||
when /mswin64(\_(\d+))?/ then ['x64', 'mswin64', $2 ]
|
when /mswin64(\_(\d+))?/ then ['x64', 'mswin64', $2 ]
|
||||||
when 'powerpc-darwin' then ['powerpc', 'darwin', nil ]
|
when 'powerpc-darwin' then ['powerpc', 'darwin', nil ]
|
||||||
when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ]
|
when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ]
|
||||||
when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8' ]
|
when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8' ]
|
||||||
when /universal-darwin(\d)/ then ['universal', 'darwin', $1 ]
|
when /universal-darwin(\d)/ then ['universal', 'darwin', $1 ]
|
||||||
else other
|
else other
|
||||||
end
|
end
|
||||||
|
|
||||||
other = Gem::Platform.new other
|
other = Gem::Platform.new other
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# This exists just to satisfy bugs in marshal'd gemspecs that
|
# This exists just to satisfy bugs in marshal'd gemspecs that
|
||||||
# contain a reference to YAML::PrivateType. We prune these out
|
# contain a reference to Psych::PrivateType. We prune these out
|
||||||
# in Specification._load, but if we don't have the constant, Marshal
|
# in Specification._load, but if we don't have the constant, Marshal
|
||||||
# blows up.
|
# blows up.
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,14 @@ module Gem::QueryUtils
|
||||||
end
|
end
|
||||||
|
|
||||||
def defaults_str # :nodoc:
|
def defaults_str # :nodoc:
|
||||||
"--local --name-matches // --no-details --versions --no-installed"
|
"--local --no-details --versions --no-installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
gem_names = Array(options[:name])
|
gem_names = if args.empty?
|
||||||
|
[options[:name]]
|
||||||
if !args.empty?
|
else
|
||||||
gem_names = 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?
|
||||||
|
@ -96,7 +96,7 @@ module Gem::QueryUtils
|
||||||
end
|
end
|
||||||
|
|
||||||
def gem_name?
|
def gem_name?
|
||||||
!options[:name].source.empty?
|
!options[:name].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def prerelease
|
def prerelease
|
||||||
|
@ -129,12 +129,10 @@ module Gem::QueryUtils
|
||||||
display_header("LOCAL")
|
display_header("LOCAL")
|
||||||
|
|
||||||
specs = Gem::Specification.find_all do |s|
|
specs = Gem::Specification.find_all do |s|
|
||||||
s.name =~ name and req =~ s.version
|
name_matches = name ? s.name =~ name : true
|
||||||
end
|
version_matches = show_prereleases? || !s.version.prerelease?
|
||||||
|
|
||||||
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
|
name_matches and version_matches
|
||||||
specs.select! do |s|
|
|
||||||
dep.match?(s.name, s.version, show_prereleases?)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
spec_tuples = specs.map do |spec|
|
spec_tuples = specs.map do |spec|
|
||||||
|
@ -149,13 +147,13 @@ module Gem::QueryUtils
|
||||||
|
|
||||||
fetcher = Gem::SpecFetcher.fetcher
|
fetcher = Gem::SpecFetcher.fetcher
|
||||||
|
|
||||||
spec_tuples = if name.respond_to?(:source) && name.source.empty?
|
spec_tuples = if name.nil?
|
||||||
fetcher.detect(specs_type) { true }
|
fetcher.detect(specs_type) { true }
|
||||||
else
|
else
|
||||||
fetcher.detect(specs_type) do |name_tuple|
|
fetcher.detect(specs_type) do |name_tuple|
|
||||||
name === name_tuple.name
|
name === name_tuple.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
output_query_results(spec_tuples)
|
output_query_results(spec_tuples)
|
||||||
end
|
end
|
||||||
|
|
|
@ -172,10 +172,10 @@ class Gem::RemoteFetcher
|
||||||
when nil then # TODO test for local overriding cache
|
when nil then # TODO test for local overriding cache
|
||||||
source_path = if Gem.win_platform? && source_uri.scheme &&
|
source_path = if Gem.win_platform? && source_uri.scheme &&
|
||||||
!source_uri.path.include?(':')
|
!source_uri.path.include?(':')
|
||||||
"#{source_uri.scheme}:#{source_uri.path}"
|
"#{source_uri.scheme}:#{source_uri.path}"
|
||||||
else
|
else
|
||||||
source_uri.path
|
source_uri.path
|
||||||
end
|
end
|
||||||
|
|
||||||
source_path = Gem::UriFormatter.new(source_path).unescape
|
source_path = Gem::UriFormatter.new(source_path).unescape
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,10 @@ class Gem::RequestSet::Lockfile
|
||||||
|
|
||||||
deps[name] = if [Gem::Resolver::VendorSpecification,
|
deps[name] = if [Gem::Resolver::VendorSpecification,
|
||||||
Gem::Resolver::GitSpecification].include? spec.class
|
Gem::Resolver::GitSpecification].include? spec.class
|
||||||
Gem::Requirement.source_set
|
Gem::Requirement.source_set
|
||||||
else
|
else
|
||||||
requirement
|
requirement
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
deps
|
deps
|
||||||
|
|
|
@ -76,21 +76,21 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
|
||||||
|
|
||||||
newest = found.last
|
newest = found.last
|
||||||
|
|
||||||
|
unless newest
|
||||||
|
exc = Gem::UnsatisfiableDependencyError.new request
|
||||||
|
exc.errors = errors
|
||||||
|
|
||||||
|
raise exc
|
||||||
|
end
|
||||||
|
|
||||||
unless @force
|
unless @force
|
||||||
found_matching_metadata = found.reverse.find do |spec|
|
found_matching_metadata = found.reverse.find do |spec|
|
||||||
metadata_satisfied?(spec)
|
metadata_satisfied?(spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
if found_matching_metadata.nil?
|
if found_matching_metadata.nil?
|
||||||
if newest
|
ensure_required_ruby_version_met(newest.spec)
|
||||||
ensure_required_ruby_version_met(newest.spec)
|
ensure_required_rubygems_version_met(newest.spec)
|
||||||
ensure_required_rubygems_version_met(newest.spec)
|
|
||||||
else
|
|
||||||
exc = Gem::UnsatisfiableDependencyError.new request
|
|
||||||
exc.errors = errors
|
|
||||||
|
|
||||||
raise exc
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
newest = found_matching_metadata
|
newest = found_matching_metadata
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,33 +24,33 @@ module Gem
|
||||||
runtime
|
runtime
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
if ::YAML.respond_to? :safe_load
|
if ::Psych.respond_to? :safe_load
|
||||||
def self.safe_load(input)
|
def self.safe_load(input)
|
||||||
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
|
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
|
||||||
::YAML.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true)
|
::Psych.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true)
|
||||||
else
|
else
|
||||||
::YAML.safe_load(input, PERMITTED_CLASSES, PERMITTED_SYMBOLS, true)
|
::Psych.safe_load(input, PERMITTED_CLASSES, PERMITTED_SYMBOLS, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load(input)
|
def self.load(input)
|
||||||
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
|
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
|
||||||
::YAML.safe_load(input, permitted_classes: [::Symbol])
|
::Psych.safe_load(input, permitted_classes: [::Symbol])
|
||||||
else
|
else
|
||||||
::YAML.safe_load(input, [::Symbol])
|
::Psych.safe_load(input, [::Symbol])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
unless Gem::Deprecate.skip
|
unless Gem::Deprecate.skip
|
||||||
warn "YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0)."
|
warn "Psych safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0)."
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.safe_load(input, *args)
|
def self.safe_load(input, *args)
|
||||||
::YAML.load input
|
::Psych.load input
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load(input)
|
def self.load(input)
|
||||||
::YAML.load input
|
::Psych.load input
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -261,7 +261,7 @@ require_relative 'openssl'
|
||||||
# 2. Grab the public key from the gemspec
|
# 2. Grab the public key from the gemspec
|
||||||
#
|
#
|
||||||
# gem spec some_signed_gem-1.0.gem cert_chain | \
|
# gem spec some_signed_gem-1.0.gem cert_chain | \
|
||||||
# ruby -ryaml -e 'puts YAML.load($stdin)' > public_key.crt
|
# ruby -rpsych -e 'puts Psych.load($stdin)' > public_key.crt
|
||||||
#
|
#
|
||||||
# 3. Generate a SHA1 hash of the data.tar.gz
|
# 3. Generate a SHA1 hash of the data.tar.gz
|
||||||
#
|
#
|
||||||
|
|
|
@ -81,12 +81,12 @@ class Gem::Source
|
||||||
return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme
|
return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme
|
||||||
|
|
||||||
fetch_uri = if uri.host == "rubygems.org"
|
fetch_uri = if uri.host == "rubygems.org"
|
||||||
index_uri = uri.dup
|
index_uri = uri.dup
|
||||||
index_uri.host = "index.rubygems.org"
|
index_uri.host = "index.rubygems.org"
|
||||||
index_uri
|
index_uri
|
||||||
else
|
else
|
||||||
uri
|
uri
|
||||||
end
|
end
|
||||||
|
|
||||||
bundler_api_uri = enforce_trailing_slash(fetch_uri)
|
bundler_api_uri = enforce_trailing_slash(fetch_uri)
|
||||||
|
|
||||||
|
|
|
@ -51,13 +51,13 @@ class Gem::SourceList
|
||||||
require "uri"
|
require "uri"
|
||||||
|
|
||||||
src = case obj
|
src = case obj
|
||||||
when URI
|
when URI
|
||||||
Gem::Source.new(obj)
|
Gem::Source.new(obj)
|
||||||
when Gem::Source
|
when Gem::Source
|
||||||
obj
|
obj
|
||||||
else
|
else
|
||||||
Gem::Source.new(URI.parse(obj))
|
Gem::Source.new(URI.parse(obj))
|
||||||
end
|
end
|
||||||
|
|
||||||
@sources << src unless @sources.include?(src)
|
@sources << src unless @sources.include?(src)
|
||||||
src
|
src
|
||||||
|
|
|
@ -191,10 +191,10 @@ class Gem::SpecFetcher
|
||||||
end
|
end
|
||||||
|
|
||||||
matches = if matches.empty? && type != :prerelease
|
matches = if matches.empty? && type != :prerelease
|
||||||
suggest_gems_from_name gem_name, :prerelease
|
suggest_gems_from_name gem_name, :prerelease
|
||||||
else
|
else
|
||||||
matches.uniq.sort_by {|name, dist| dist }
|
matches.uniq.sort_by {|name, dist| dist }
|
||||||
end
|
end
|
||||||
|
|
||||||
matches.map {|name, dist| name }.uniq.first(num_results)
|
matches.map {|name, dist| name }.uniq.first(num_results)
|
||||||
end
|
end
|
||||||
|
@ -216,27 +216,27 @@ class Gem::SpecFetcher
|
||||||
@sources.each_source do |source|
|
@sources.each_source do |source|
|
||||||
begin
|
begin
|
||||||
names = case type
|
names = case type
|
||||||
when :latest
|
when :latest
|
||||||
tuples_for source, :latest
|
tuples_for source, :latest
|
||||||
when :released
|
when :released
|
||||||
tuples_for source, :released
|
tuples_for source, :released
|
||||||
when :complete
|
when :complete
|
||||||
names =
|
names =
|
||||||
tuples_for(source, :prerelease, true) +
|
tuples_for(source, :prerelease, true) +
|
||||||
tuples_for(source, :released)
|
tuples_for(source, :released)
|
||||||
|
|
||||||
names.sort
|
names.sort
|
||||||
when :abs_latest
|
when :abs_latest
|
||||||
names =
|
names =
|
||||||
tuples_for(source, :prerelease, true) +
|
tuples_for(source, :prerelease, true) +
|
||||||
tuples_for(source, :latest)
|
tuples_for(source, :latest)
|
||||||
|
|
||||||
names.sort
|
names.sort
|
||||||
when :prerelease
|
when :prerelease
|
||||||
tuples_for(source, :prerelease)
|
tuples_for(source, :prerelease)
|
||||||
else
|
else
|
||||||
raise Gem::Exception, "Unknown type - :#{type}"
|
raise Gem::Exception, "Unknown type - :#{type}"
|
||||||
end
|
end
|
||||||
rescue Gem::RemoteFetcher::FetchError => e
|
rescue Gem::RemoteFetcher::FetchError => e
|
||||||
errors << Gem::SourceFetchProblem.new(source, e)
|
errors << Gem::SourceFetchProblem.new(source, e)
|
||||||
else
|
else
|
||||||
|
|
|
@ -11,7 +11,6 @@ require_relative 'basic_specification'
|
||||||
require_relative 'stub_specification'
|
require_relative 'stub_specification'
|
||||||
require_relative 'platform'
|
require_relative 'platform'
|
||||||
require_relative 'requirement'
|
require_relative 'requirement'
|
||||||
require_relative 'specification_policy'
|
|
||||||
require_relative 'util/list'
|
require_relative 'util/list'
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -163,15 +162,15 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
|
|
||||||
@@default_value.each do |k,v|
|
@@default_value.each do |k,v|
|
||||||
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
|
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
|
||||||
when [], {}, true, false, nil, Numeric, Symbol
|
when [], {}, true, false, nil, Numeric, Symbol
|
||||||
v.inspect
|
v.inspect
|
||||||
when String
|
when String
|
||||||
v.dump
|
v.dump
|
||||||
when Numeric
|
when Numeric
|
||||||
"default_value(:#{k})"
|
"default_value(:#{k})"
|
||||||
else
|
else
|
||||||
"default_value(:#{k}).dup"
|
"default_value(:#{k}).dup"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@attributes = @@default_value.keys.sort_by {|s| s.to_s }
|
@@attributes = @@default_value.keys.sort_by {|s| s.to_s }
|
||||||
|
@ -226,7 +225,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
attr_reader :version
|
attr_reader :version
|
||||||
|
|
||||||
##
|
##
|
||||||
# A short summary of this gem's description. Displayed in `gem list -d`.
|
# A short summary of this gem's description. Displayed in <tt>gem list -d</tt>.
|
||||||
#
|
#
|
||||||
# The #description should be more detailed than the summary.
|
# The #description should be more detailed than the summary.
|
||||||
#
|
#
|
||||||
|
@ -272,7 +271,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
# A list of authors for this gem.
|
# A list of authors for this gem.
|
||||||
#
|
#
|
||||||
# Alternatively, a single author can be specified by assigning a string to
|
# Alternatively, a single author can be specified by assigning a string to
|
||||||
# `spec.author`
|
# +spec.author+
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
|
@ -1116,7 +1115,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
file = file.dup.tap(&Gem::UNTAINT)
|
file = file.dup.tap(&Gem::UNTAINT)
|
||||||
return unless File.file?(file)
|
return unless File.file?(file)
|
||||||
|
|
||||||
code = Gem.open_with_flock(file, 'r:UTF-8:-', &:read)
|
code = Gem.open_file(file, 'r:UTF-8:-', &:read)
|
||||||
|
|
||||||
code.tap(&Gem::UNTAINT)
|
code.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
|
@ -1269,21 +1268,21 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
current_version = CURRENT_SPECIFICATION_VERSION
|
current_version = CURRENT_SPECIFICATION_VERSION
|
||||||
|
|
||||||
field_count = if spec.specification_version > current_version
|
field_count = if spec.specification_version > current_version
|
||||||
spec.instance_variable_set :@specification_version,
|
spec.instance_variable_set :@specification_version,
|
||||||
current_version
|
current_version
|
||||||
MARSHAL_FIELDS[current_version]
|
MARSHAL_FIELDS[current_version]
|
||||||
else
|
else
|
||||||
MARSHAL_FIELDS[spec.specification_version]
|
MARSHAL_FIELDS[spec.specification_version]
|
||||||
end
|
end
|
||||||
|
|
||||||
if array.size < field_count
|
if array.size < field_count
|
||||||
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Cleanup any YAML::PrivateType. They only show up for an old bug
|
# Cleanup any Psych::PrivateType. They only show up for an old bug
|
||||||
# where nil => null, so just convert them to nil based on the type.
|
# where nil => null, so just convert them to nil based on the type.
|
||||||
|
|
||||||
array.map! {|e| e.kind_of?(YAML::PrivateType) ? nil : e }
|
array.map! {|e| e.kind_of?(Psych::PrivateType) ? nil : e }
|
||||||
|
|
||||||
spec.instance_variable_set :@rubygems_version, array[0]
|
spec.instance_variable_set :@rubygems_version, array[0]
|
||||||
# spec version
|
# spec version
|
||||||
|
@ -1474,10 +1473,10 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
|
|
||||||
def add_dependency_with_type(dependency, type, requirements)
|
def add_dependency_with_type(dependency, type, requirements)
|
||||||
requirements = if requirements.empty?
|
requirements = if requirements.empty?
|
||||||
Gem::Requirement.default
|
Gem::Requirement.default
|
||||||
else
|
else
|
||||||
requirements.flatten
|
requirements.flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
unless dependency.respond_to?(:name) &&
|
unless dependency.respond_to?(:name) &&
|
||||||
dependency.respond_to?(:requirement)
|
dependency.respond_to?(:requirement)
|
||||||
|
@ -1685,18 +1684,18 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
# This is the cleanest, most-readable, faster-than-using-Date
|
# This is the cleanest, most-readable, faster-than-using-Date
|
||||||
# way to do it.
|
# way to do it.
|
||||||
@date = case date
|
@date = case date
|
||||||
when String then
|
when String then
|
||||||
if DateTimeFormat =~ date
|
if DateTimeFormat =~ date
|
||||||
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
||||||
else
|
else
|
||||||
raise(Gem::InvalidSpecificationException,
|
raise(Gem::InvalidSpecificationException,
|
||||||
"invalid date format in specification: #{date.inspect}")
|
"invalid date format in specification: #{date.inspect}")
|
||||||
end
|
end
|
||||||
when Time, DateLike then
|
when Time, DateLike then
|
||||||
Time.utc(date.year, date.month, date.day)
|
Time.utc(date.year, date.month, date.day)
|
||||||
else
|
else
|
||||||
TODAY
|
TODAY
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -1802,13 +1801,13 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
coder.add 'name', @name
|
coder.add 'name', @name
|
||||||
coder.add 'version', @version
|
coder.add 'version', @version
|
||||||
platform = case @original_platform
|
platform = case @original_platform
|
||||||
when nil, '' then
|
when nil, '' then
|
||||||
'ruby'
|
'ruby'
|
||||||
when String then
|
when String then
|
||||||
@original_platform
|
@original_platform
|
||||||
else
|
else
|
||||||
@original_platform.to_s
|
@original_platform.to_s
|
||||||
end
|
end
|
||||||
coder.add 'platform', platform
|
coder.add 'platform', platform
|
||||||
|
|
||||||
attributes = @@attributes.map(&:to_s) - %w[name version platform]
|
attributes = @@attributes.map(&:to_s) - %w[name version platform]
|
||||||
|
@ -2025,10 +2024,10 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
def base_dir
|
def base_dir
|
||||||
return Gem.dir unless loaded_from
|
return Gem.dir unless loaded_from
|
||||||
@base_dir ||= if default_gem?
|
@base_dir ||= if default_gem?
|
||||||
File.dirname File.dirname File.dirname loaded_from
|
File.dirname File.dirname File.dirname loaded_from
|
||||||
else
|
else
|
||||||
File.dirname File.dirname loaded_from
|
File.dirname File.dirname loaded_from
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -2655,9 +2654,9 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
default = self.default_value attribute
|
default = self.default_value attribute
|
||||||
|
|
||||||
value = case default
|
value = case default
|
||||||
when Time, Numeric, Symbol, true, false, nil then default
|
when Time, Numeric, Symbol, true, false, nil then default
|
||||||
else default.dup
|
else default.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
instance_variable_set "@#{attribute}", value
|
instance_variable_set "@#{attribute}", value
|
||||||
end
|
end
|
||||||
|
|
|
@ -199,17 +199,17 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
||||||
base = segments.first 2
|
base = segments.first 2
|
||||||
|
|
||||||
recommendation = if (op == '>' || op == '>=') && segments == [0]
|
recommendation = if (op == '>' || op == '>=') && segments == [0]
|
||||||
" use a bounded requirement, such as '~> x.y'"
|
" use a bounded requirement, such as '~> x.y'"
|
||||||
else
|
else
|
||||||
bugfix = if op == '>'
|
bugfix = if op == '>'
|
||||||
", '> #{dep_version}'"
|
", '> #{dep_version}'"
|
||||||
elsif op == '>=' and base != segments
|
elsif op == '>=' and base != segments
|
||||||
", '>= #{dep_version}'"
|
", '>= #{dep_version}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
" if #{dep.name} is semantically versioned, use:\n" \
|
" if #{dep.name} is semantically versioned, use:\n" \
|
||||||
" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
|
" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
|
||||||
end
|
end
|
||||||
|
|
||||||
warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
|
warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
|
||||||
end
|
end
|
||||||
|
@ -332,11 +332,11 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
||||||
def validate_array_attribute(field)
|
def validate_array_attribute(field)
|
||||||
val = @specification.send(field)
|
val = @specification.send(field)
|
||||||
klass = case field
|
klass = case field
|
||||||
when :dependencies then
|
when :dependencies then
|
||||||
Gem::Dependency
|
Gem::Dependency
|
||||||
else
|
else
|
||||||
String
|
String
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Array === val and val.all? {|x| x.kind_of?(klass) }
|
unless Array === val and val.all? {|x| x.kind_of?(klass) }
|
||||||
error "#{field} must be an Array of #{klass}"
|
error "#{field} must be an Array of #{klass}"
|
||||||
|
|
|
@ -36,18 +36,18 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
||||||
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
|
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
|
||||||
@name = parts[0].freeze
|
@name = parts[0].freeze
|
||||||
@version = if Gem::Version.correct?(parts[1])
|
@version = if Gem::Version.correct?(parts[1])
|
||||||
Gem::Version.new(parts[1])
|
Gem::Version.new(parts[1])
|
||||||
else
|
else
|
||||||
Gem::Version.new(0)
|
Gem::Version.new(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@platform = Gem::Platform.new parts[2]
|
@platform = Gem::Platform.new parts[2]
|
||||||
@extensions = extensions
|
@extensions = extensions
|
||||||
@full_name = if platform == Gem::Platform::RUBY
|
@full_name = if platform == Gem::Platform::RUBY
|
||||||
"#{name}-#{version}"
|
"#{name}-#{version}"
|
||||||
else
|
else
|
||||||
"#{name}-#{version}-#{platform}"
|
"#{name}-#{version}-#{platform}"
|
||||||
end
|
end
|
||||||
|
|
||||||
path_list = parts.last
|
path_list = parts.last
|
||||||
@require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! do |x|
|
@require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! do |x|
|
||||||
|
@ -110,16 +110,16 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
||||||
begin
|
begin
|
||||||
saved_lineno = $.
|
saved_lineno = $.
|
||||||
|
|
||||||
Gem.open_with_flock loaded_from, OPEN_MODE do |file|
|
Gem.open_file loaded_from, OPEN_MODE do |file|
|
||||||
begin
|
begin
|
||||||
file.readline # discard encoding line
|
file.readline # discard encoding line
|
||||||
stubline = file.readline.chomp
|
stubline = file.readline.chomp
|
||||||
if stubline.start_with?(PREFIX)
|
if stubline.start_with?(PREFIX)
|
||||||
extensions = if /\A#{PREFIX}/ =~ file.readline.chomp
|
extensions = if /\A#{PREFIX}/ =~ file.readline.chomp
|
||||||
$'.split "\0"
|
$'.split "\0"
|
||||||
else
|
else
|
||||||
StubLine::NO_EXTENSIONS
|
StubLine::NO_EXTENSIONS
|
||||||
end
|
end
|
||||||
|
|
||||||
@data = StubLine.new stubline, extensions
|
@data = StubLine.new stubline, extensions
|
||||||
end
|
end
|
||||||
|
@ -185,14 +185,11 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
||||||
|
|
||||||
def to_spec
|
def to_spec
|
||||||
@spec ||= if @data
|
@spec ||= if @data
|
||||||
loaded = Gem.loaded_specs[name]
|
loaded = Gem.loaded_specs[name]
|
||||||
loaded if loaded && loaded.version == version
|
loaded if loaded && loaded.version == version
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec ||= Gem::Specification.load(loaded_from)
|
@spec ||= Gem::Specification.load(loaded_from)
|
||||||
@spec.ignored = @ignored if @spec
|
|
||||||
|
|
||||||
@spec
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -200,13 +200,13 @@ class Gem::Uninstaller
|
||||||
executables = executables.map {|exec| formatted_program_filename exec }
|
executables = executables.map {|exec| formatted_program_filename exec }
|
||||||
|
|
||||||
remove = if @force_executables.nil?
|
remove = if @force_executables.nil?
|
||||||
ask_yes_no("Remove executables:\n" +
|
ask_yes_no("Remove executables:\n" +
|
||||||
"\t#{executables.join ', '}\n\n" +
|
"\t#{executables.join ', '}\n\n" +
|
||||||
"in addition to the gem?",
|
"in addition to the gem?",
|
||||||
true)
|
true)
|
||||||
else
|
else
|
||||||
@force_executables
|
@force_executables
|
||||||
end
|
end
|
||||||
|
|
||||||
if remove
|
if remove
|
||||||
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
|
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
|
||||||
|
|
|
@ -258,23 +258,23 @@ class Gem::StreamUI
|
||||||
end
|
end
|
||||||
|
|
||||||
default_answer = case default
|
default_answer = case default
|
||||||
when nil
|
when nil
|
||||||
'yn'
|
'yn'
|
||||||
when true
|
when true
|
||||||
'Yn'
|
'Yn'
|
||||||
else
|
else
|
||||||
'yN'
|
'yN'
|
||||||
end
|
end
|
||||||
|
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
while result.nil? do
|
while result.nil? do
|
||||||
result = case ask "#{question} [#{default_answer}]"
|
result = case ask "#{question} [#{default_answer}]"
|
||||||
when /^y/i then true
|
when /^y/i then true
|
||||||
when /^n/i then false
|
when /^n/i then false
|
||||||
when /^$/ then default
|
when /^$/ then default
|
||||||
else nil
|
else nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -310,12 +310,12 @@ class Gem::Version
|
||||||
|
|
||||||
def release
|
def release
|
||||||
@@release[self] ||= if prerelease?
|
@@release[self] ||= if prerelease?
|
||||||
segments = self.segments
|
segments = self.segments
|
||||||
segments.pop while segments.any? {|s| String === s }
|
segments.pop while segments.any? {|s| String === s }
|
||||||
self.class.new segments.join('.')
|
self.class.new segments.join('.')
|
||||||
else
|
else
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def segments # :nodoc:
|
def segments # :nodoc:
|
||||||
|
@ -341,9 +341,11 @@ class Gem::Version
|
||||||
# Compares this version with +other+ returning -1, 0, or 1 if the
|
# Compares this version with +other+ returning -1, 0, or 1 if the
|
||||||
# other version is larger, the same, or smaller than this
|
# other version is larger, the same, or smaller than this
|
||||||
# one. Attempts to compare to something that's not a
|
# one. Attempts to compare to something that's not a
|
||||||
# <tt>Gem::Version</tt> return +nil+.
|
# <tt>Gem::Version</tt> or a valid version String return +nil+.
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
|
return self <=> self.class.new(other) if (String === other) && self.class.correct?(other)
|
||||||
|
|
||||||
return unless Gem::Version === other
|
return unless Gem::Version === other
|
||||||
return 0 if @version == other._version || canonical_segments == other.canonical_segments
|
return 0 if @version == other._version || canonical_segments == other.canonical_segments
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ RSpec.describe "bundle executable" do
|
||||||
bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }, :raise_on_error => false
|
bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }, :raise_on_error => false
|
||||||
expect(err).to start_with(<<-EOS.strip)
|
expect(err).to start_with(<<-EOS.strip)
|
||||||
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
|
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
|
||||||
To install the latest version, run `gem install bundler`
|
To update to the most recent version, run `bundle update --bundler`
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ To install the latest version, run `gem install bundler`
|
||||||
bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }, :raise_on_error => false
|
bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }, :raise_on_error => false
|
||||||
expect(err).to start_with(<<-EOS.strip)
|
expect(err).to start_with(<<-EOS.strip)
|
||||||
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
|
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
|
||||||
To install the latest version, run `gem install bundler --pre`
|
To update to the most recent version, run `bundle update --bundler`
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,9 +5,10 @@ RSpec.describe Bundler::EndpointSpecification do
|
||||||
let(:version) { "1.0.0" }
|
let(:version) { "1.0.0" }
|
||||||
let(:platform) { Gem::Platform::RUBY }
|
let(:platform) { Gem::Platform::RUBY }
|
||||||
let(:dependencies) { [] }
|
let(:dependencies) { [] }
|
||||||
|
let(:spec_fetcher) { double(:spec_fetcher) }
|
||||||
let(:metadata) { nil }
|
let(:metadata) { nil }
|
||||||
|
|
||||||
subject(:spec) { described_class.new(name, version, platform, dependencies, metadata) }
|
subject(:spec) { described_class.new(name, version, platform, spec_fetcher, dependencies, metadata) }
|
||||||
|
|
||||||
describe "#build_dependency" do
|
describe "#build_dependency" do
|
||||||
let(:name) { "foo" }
|
let(:name) { "foo" }
|
||||||
|
@ -48,7 +49,9 @@ RSpec.describe Bundler::EndpointSpecification do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports equality comparison" do
|
it "supports equality comparison" do
|
||||||
other_spec = described_class.new("bar", version, platform, dependencies, metadata)
|
remote_spec = double(:remote_spec, :required_ruby_version => nil, :required_rubygems_version => nil)
|
||||||
|
allow(spec_fetcher).to receive(:fetch_spec).and_return(remote_spec)
|
||||||
|
other_spec = described_class.new("bar", version, platform, spec_fetcher, dependencies, metadata)
|
||||||
expect(spec).to eql(spec)
|
expect(spec).to eql(spec)
|
||||||
expect(spec).to_not eql(other_spec)
|
expect(spec).to_not eql(other_spec)
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,6 +66,10 @@ RSpec.describe Bundler::GemHelper do
|
||||||
mock_confirm_message message
|
mock_confirm_message message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sha512_hexdigest(path)
|
||||||
|
Digest::SHA512.file(path).hexdigest
|
||||||
|
end
|
||||||
|
|
||||||
subject! { Bundler::GemHelper.new(app_path) }
|
subject! { Bundler::GemHelper.new(app_path) }
|
||||||
let(:app_version) { "0.1.0" }
|
let(:app_version) { "0.1.0" }
|
||||||
let(:app_gem_dir) { app_path.join("pkg") }
|
let(:app_gem_dir) { app_path.join("pkg") }
|
||||||
|
@ -169,12 +173,21 @@ RSpec.describe Bundler::GemHelper do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#build_checksum" do
|
describe "#build_checksum" do
|
||||||
|
it "calculates SHA512 of the content" do
|
||||||
|
FileUtils.mkdir_p(app_gem_dir)
|
||||||
|
File.write(app_gem_path, "")
|
||||||
|
mock_checksum_message app_name, app_version
|
||||||
|
subject.build_checksum(app_gem_path)
|
||||||
|
expect(File.read(app_sha_path).chomp).to eql(Digest::SHA512.hexdigest(""))
|
||||||
|
end
|
||||||
|
|
||||||
context "when build was successful" do
|
context "when build was successful" do
|
||||||
it "creates .sha512 file" do
|
it "creates .sha512 file" do
|
||||||
mock_build_message app_name, app_version
|
mock_build_message app_name, app_version
|
||||||
mock_checksum_message app_name, app_version
|
mock_checksum_message app_name, app_version
|
||||||
subject.build_checksum
|
subject.build_checksum
|
||||||
expect(app_sha_path).to exist
|
expect(app_sha_path).to exist
|
||||||
|
expect(File.read(app_sha_path).chomp).to eql(sha512_hexdigest(app_gem_path))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "when building in the current working directory" do
|
context "when building in the current working directory" do
|
||||||
|
@ -185,6 +198,7 @@ RSpec.describe Bundler::GemHelper do
|
||||||
Bundler::GemHelper.new.build_checksum
|
Bundler::GemHelper.new.build_checksum
|
||||||
end
|
end
|
||||||
expect(app_sha_path).to exist
|
expect(app_sha_path).to exist
|
||||||
|
expect(File.read(app_sha_path).chomp).to eql(sha512_hexdigest(app_gem_path))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "when building in a location relative to the current working directory" do
|
context "when building in a location relative to the current working directory" do
|
||||||
|
@ -195,6 +209,7 @@ RSpec.describe Bundler::GemHelper do
|
||||||
Bundler::GemHelper.new(File.basename(app_path)).build_checksum
|
Bundler::GemHelper.new(File.basename(app_path)).build_checksum
|
||||||
end
|
end
|
||||||
expect(app_sha_path).to exist
|
expect(app_sha_path).to exist
|
||||||
|
expect(File.read(app_sha_path).chomp).to eql(sha512_hexdigest(app_gem_path))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -182,30 +182,26 @@ RSpec.describe "bundle binstubs <gem>" do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "and the version is older and the same major" do
|
context "and the version is older and the same major" do
|
||||||
let(:system_bundler_version) { "55.1" }
|
let(:system_bundler_version) { "2.999.999" }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 55.0")
|
lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 2.3.0")
|
||||||
|
|
||||||
update_repo2 do
|
|
||||||
with_built_bundler("55.0") {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs and runs the exact version of bundler", :rubygems => ">= 3.3.0.dev" do
|
it "installs and runs the exact version of bundler", :rubygems => ">= 3.3.0.dev" do
|
||||||
sys_exec "bin/bundle install --verbose", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s, "RUBYOPT" => "-r#{spec_dir}/support/hax.rb" }
|
sys_exec "bin/bundle install --verbose", :artifice => "vcr"
|
||||||
expect(exitstatus).not_to eq(42)
|
expect(exitstatus).not_to eq(42)
|
||||||
expect(out).to include("Bundler 55.1 is running, but your lockfile was generated with 55.0. Installing Bundler 55.0 and restarting using that version.")
|
expect(out).to include("Bundler 2.999.999 is running, but your lockfile was generated with 2.3.0. Installing Bundler 2.3.0 and restarting using that version.")
|
||||||
expect(out).to include("Using bundler 55.0")
|
expect(out).to include("Using bundler 2.3.0")
|
||||||
expect(err).not_to include("Activating bundler (~> 55.0) failed:")
|
expect(err).not_to include("Activating bundler (~> 2.3.0) failed:")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "runs the available version of bundler", :rubygems => "< 3.3.0.dev" do
|
it "runs the available version of bundler", :rubygems => "< 3.3.0.dev" do
|
||||||
sys_exec "bin/bundle install --verbose"
|
sys_exec "bin/bundle install --verbose"
|
||||||
expect(exitstatus).not_to eq(42)
|
expect(exitstatus).not_to eq(42)
|
||||||
expect(out).not_to include("Bundler 55.1 is running, but your lockfile was generated with 55.0. Installing Bundler 55.0 and restarting using that version.")
|
expect(out).not_to include("Bundler 2.999.999 is running, but your lockfile was generated with 2.3.0. Installing Bundler 2.3.0 and restarting using that version.")
|
||||||
expect(out).to include("Using bundler 55.1")
|
expect(out).to include("Using bundler 2.999.999")
|
||||||
expect(err).not_to include("Activating bundler (~> 55.0) failed:")
|
expect(err).not_to include("Activating bundler (~> 2.3.0) failed:")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -403,14 +403,14 @@ RSpec.describe "bundle install with gem sources" do
|
||||||
|
|
||||||
simulate_new_machine
|
simulate_new_machine
|
||||||
|
|
||||||
simulate_platform "ruby" do
|
bundle "config set --local force_ruby_platform true"
|
||||||
install_gemfile <<-G
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
install_gemfile <<-G
|
||||||
gem "platform_specific"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
G
|
gem "platform_specific"
|
||||||
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
|
G
|
||||||
expect(out).to eq("1.0.0 RUBY")
|
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
|
||||||
end
|
expect(out).to eq("1.0.0 RUBY")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not update the cache if --no-cache is passed" do
|
it "does not update the cache if --no-cache is passed" do
|
||||||
|
|
|
@ -49,8 +49,8 @@ RSpec.describe "bundle doctor" do
|
||||||
doctor = Bundler::CLI::Doctor.new({})
|
doctor = Bundler::CLI::Doctor.new({})
|
||||||
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
|
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
|
||||||
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/lib/libSystem.dylib"]
|
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/lib/libSystem.dylib"]
|
||||||
allow(File).to receive(:exist?).with("/usr/lib/libSystem.dylib").and_return(true)
|
allow(Fiddle).to receive(:dlopen).with("/usr/lib/libSystem.dylib").and_return(true)
|
||||||
expect { doctor.run }.not_to(raise_error, @stdout.string)
|
expect { doctor.run }.not_to raise_error
|
||||||
expect(@stdout.string).to be_empty
|
expect(@stdout.string).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ RSpec.describe "bundle doctor" do
|
||||||
doctor = Bundler::CLI::Doctor.new({})
|
doctor = Bundler::CLI::Doctor.new({})
|
||||||
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
|
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
|
||||||
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"]
|
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"]
|
||||||
allow(File).to receive(:exist?).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_return(false)
|
allow(Fiddle).to receive(:dlopen).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_raise(Fiddle::DLError)
|
||||||
expect { doctor.run }.to raise_error(Bundler::ProductionError, strip_whitespace(<<-E).strip), @stdout.string
|
expect { doctor.run }.to raise_error(Bundler::ProductionError, strip_whitespace(<<-E).strip), @stdout.string
|
||||||
The following gems are missing OS dependencies:
|
The following gems are missing OS dependencies:
|
||||||
* bundler: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
|
* bundler: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
|
||||||
|
|
|
@ -499,20 +499,17 @@ RSpec.describe "bundle install with gem sources" do
|
||||||
context "and using an unsupported Ruby version" do
|
context "and using an unsupported Ruby version" do
|
||||||
it "prints an error" do
|
it "prints an error" do
|
||||||
install_gemfile <<-G, :raise_on_error => false
|
install_gemfile <<-G, :raise_on_error => false
|
||||||
::RUBY_VERSION = '2.0.1'
|
ruby '~> 1.2'
|
||||||
ruby '~> 2.2'
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
G
|
G
|
||||||
expect(err).to include("Your Ruby version is 2.0.1, but your Gemfile specified ~> 2.2")
|
expect(err).to include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified ~> 1.2")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "and using a supported Ruby version" do
|
context "and using a supported Ruby version" do
|
||||||
before do
|
before do
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
::RUBY_VERSION = '2.1.3'
|
ruby '~> #{RUBY_VERSION}'
|
||||||
::RUBY_PATCHLEVEL = 100
|
|
||||||
ruby '~> 2.1.0'
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
G
|
G
|
||||||
end
|
end
|
||||||
|
@ -529,18 +526,16 @@ RSpec.describe "bundle install with gem sources" do
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.1.3p100
|
#{Bundler::RubyVersion.system}
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
#{Bundler::VERSION}
|
#{Bundler::VERSION}
|
||||||
L
|
L
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates Gemfile.lock with updated incompatible ruby version" do
|
it "updates Gemfile.lock with updated yet still compatible ruby version" do
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
::RUBY_VERSION = '2.2.3'
|
ruby '~> #{RUBY_VERSION[0..2]}'
|
||||||
::RUBY_PATCHLEVEL = 100
|
|
||||||
ruby '~> 2.2.0'
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
G
|
G
|
||||||
|
|
||||||
|
@ -555,7 +550,7 @@ RSpec.describe "bundle install with gem sources" do
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.2.3p100
|
#{Bundler::RubyVersion.system}
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
#{Bundler::VERSION}
|
#{Bundler::VERSION}
|
||||||
|
|
|
@ -337,7 +337,8 @@ RSpec.describe "bundle lock" do
|
||||||
#{Bundler::VERSION}
|
#{Bundler::VERSION}
|
||||||
G
|
G
|
||||||
|
|
||||||
simulate_platform(rb) { bundle :lock }
|
bundle "config set --local force_ruby_platform true"
|
||||||
|
bundle :lock
|
||||||
|
|
||||||
expect(lockfile).to eq <<~G
|
expect(lockfile).to eq <<~G
|
||||||
GEM
|
GEM
|
||||||
|
|
|
@ -28,6 +28,10 @@ RSpec.describe "bundle gem" do
|
||||||
|
|
||||||
let(:require_path) { "mygem" }
|
let(:require_path) { "mygem" }
|
||||||
|
|
||||||
|
let(:minitest_test_file_path) { "test/test_mygem.rb" }
|
||||||
|
|
||||||
|
let(:minitest_test_class_name) { "class TestMygem < Minitest::Test" }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sys_exec("git config --global user.name 'Bundler User'")
|
sys_exec("git config --global user.name 'Bundler User'")
|
||||||
sys_exec("git config --global user.email user@example.com")
|
sys_exec("git config --global user.email user@example.com")
|
||||||
|
@ -702,7 +706,7 @@ RSpec.describe "bundle gem" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "builds spec skeleton" do
|
it "builds spec skeleton" do
|
||||||
expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb")).to exist
|
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}")).to exist
|
||||||
expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
|
expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -722,7 +726,7 @@ RSpec.describe "bundle gem" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "builds spec skeleton" do
|
it "builds spec skeleton" do
|
||||||
expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb")).to exist
|
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}")).to exist
|
||||||
expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
|
expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -731,11 +735,15 @@ RSpec.describe "bundle gem" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "requires 'test_helper'" do
|
it "requires 'test_helper'" do
|
||||||
expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb").read).to include(%(require "test_helper"))
|
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}").read).to include(%(require "test_helper"))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "defines valid test class name" do
|
||||||
|
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}").read).to include(minitest_test_class_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a default test which fails" do
|
it "creates a default test which fails" do
|
||||||
expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb").read).to include("assert false")
|
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}").read).to include("assert false")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1300,6 +1308,10 @@ RSpec.describe "bundle gem" do
|
||||||
|
|
||||||
let(:require_relative_path) { "test_gem" }
|
let(:require_relative_path) { "test_gem" }
|
||||||
|
|
||||||
|
let(:minitest_test_file_path) { "test/test_test_gem.rb" }
|
||||||
|
|
||||||
|
let(:minitest_test_class_name) { "class TestTestGem < Minitest::Test" }
|
||||||
|
|
||||||
let(:flags) { nil }
|
let(:flags) { nil }
|
||||||
|
|
||||||
it "does not nest constants" do
|
it "does not nest constants" do
|
||||||
|
@ -1355,6 +1367,10 @@ RSpec.describe "bundle gem" do
|
||||||
|
|
||||||
let(:require_relative_path) { "gem" }
|
let(:require_relative_path) { "gem" }
|
||||||
|
|
||||||
|
let(:minitest_test_file_path) { "test/test/test_gem.rb" }
|
||||||
|
|
||||||
|
let(:minitest_test_class_name) { "class Test::TestGem < Minitest::Test" }
|
||||||
|
|
||||||
it "nests constants so they work" do
|
it "nests constants so they work" do
|
||||||
bundle "gem #{gem_name}"
|
bundle "gem #{gem_name}"
|
||||||
expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/module Test\n module Gem/)
|
expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/module Test\n module Gem/)
|
||||||
|
|
|
@ -48,12 +48,14 @@ RSpec.describe "bundle remove" do
|
||||||
|
|
||||||
context "when gem is specified in multiple lines" do
|
context "when gem is specified in multiple lines" do
|
||||||
it "shows success for removed gem" do
|
it "shows success for removed gem" do
|
||||||
|
build_git "rack"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source '#{file_uri_for(gem_repo1)}'
|
source '#{file_uri_for(gem_repo1)}'
|
||||||
|
|
||||||
gem 'git'
|
gem 'git'
|
||||||
gem 'rack',
|
gem 'rack',
|
||||||
git: 'https://github.com/rack/rack',
|
git: "#{lib_path("rack-1.0")}",
|
||||||
branch: 'master'
|
branch: 'master'
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
G
|
G
|
||||||
|
|
|
@ -980,20 +980,14 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler"
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe "bundle update --ruby" do
|
RSpec.describe "bundle update --ruby" do
|
||||||
before do
|
|
||||||
install_gemfile <<-G
|
|
||||||
::RUBY_VERSION = '2.1.3'
|
|
||||||
::RUBY_PATCHLEVEL = 100
|
|
||||||
ruby '~> 2.1.0'
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
|
||||||
G
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the Gemfile removes the ruby" do
|
context "when the Gemfile removes the ruby" do
|
||||||
before do
|
before do
|
||||||
|
install_gemfile <<-G
|
||||||
|
ruby '~> #{RUBY_VERSION}'
|
||||||
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
G
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
::RUBY_VERSION = '2.1.4'
|
|
||||||
::RUBY_PATCHLEVEL = 222
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
G
|
G
|
||||||
end
|
end
|
||||||
|
@ -1018,10 +1012,13 @@ RSpec.describe "bundle update --ruby" do
|
||||||
|
|
||||||
context "when the Gemfile specified an updated Ruby version" do
|
context "when the Gemfile specified an updated Ruby version" do
|
||||||
before do
|
before do
|
||||||
|
install_gemfile <<-G
|
||||||
|
ruby '~> #{RUBY_VERSION}'
|
||||||
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
G
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
::RUBY_VERSION = '2.1.4'
|
ruby '~> #{RUBY_VERSION[0..2]}'
|
||||||
::RUBY_PATCHLEVEL = 222
|
|
||||||
ruby '~> 2.1.0'
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
G
|
G
|
||||||
end
|
end
|
||||||
|
@ -1038,37 +1035,55 @@ RSpec.describe "bundle update --ruby" do
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
|
||||||
|
RUBY VERSION
|
||||||
|
#{Bundler::RubyVersion.system}
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
#{Bundler::VERSION}
|
||||||
|
L
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when a different Ruby is being used than has been versioned" do
|
||||||
|
before do
|
||||||
|
install_gemfile <<-G
|
||||||
|
ruby '~> #{RUBY_VERSION}'
|
||||||
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
G
|
||||||
|
|
||||||
|
gemfile <<-G
|
||||||
|
ruby '~> 2.1.0'
|
||||||
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
G
|
||||||
|
end
|
||||||
|
it "shows a helpful error message" do
|
||||||
|
bundle "update --ruby", :raise_on_error => false
|
||||||
|
|
||||||
|
expect(err).to include("Your Ruby version is #{Bundler::RubyVersion.system.gem_version}, but your Gemfile specified ~> 2.1.0")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when updating Ruby version and Gemfile `ruby`" do
|
||||||
|
before do
|
||||||
|
lockfile <<~L
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo1)}/
|
||||||
|
specs:
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{lockfile_platforms}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.1.4p222
|
ruby 2.1.4p222
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
#{Bundler::VERSION}
|
#{Bundler::VERSION}
|
||||||
L
|
L
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when a different Ruby is being used than has been versioned" do
|
|
||||||
before do
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
::RUBY_VERSION = '2.2.2'
|
ruby '~> #{RUBY_VERSION}'
|
||||||
::RUBY_PATCHLEVEL = 505
|
|
||||||
ruby '~> 2.1.0'
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
|
||||||
G
|
|
||||||
end
|
|
||||||
it "shows a helpful error message" do
|
|
||||||
bundle "update --ruby", :raise_on_error => false
|
|
||||||
|
|
||||||
expect(err).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when updating Ruby version and Gemfile `ruby`" do
|
|
||||||
before do
|
|
||||||
gemfile <<-G
|
|
||||||
::RUBY_VERSION = '1.8.3'
|
|
||||||
::RUBY_PATCHLEVEL = 55
|
|
||||||
ruby '~> 1.8.0'
|
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
G
|
G
|
||||||
end
|
end
|
||||||
|
@ -1086,7 +1101,7 @@ RSpec.describe "bundle update --ruby" do
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 1.8.3p55
|
#{Bundler::RubyVersion.system}
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
#{Bundler::VERSION}
|
#{Bundler::VERSION}
|
||||||
|
@ -1105,15 +1120,208 @@ RSpec.describe "bundle update --bundler" do
|
||||||
source "#{file_uri_for(gem_repo4)}"
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
gem "rack"
|
gem "rack"
|
||||||
G
|
G
|
||||||
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
|
|
||||||
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2')
|
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2')
|
||||||
|
|
||||||
FileUtils.rm_r gem_repo4
|
FileUtils.rm_r gem_repo4
|
||||||
|
|
||||||
bundle :update, :bundler => true, :verbose => true
|
bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true
|
||||||
expect(the_bundle).to include_gem "rack 1.0"
|
expect(out).to include("Using bundler #{Bundler::VERSION}")
|
||||||
|
|
||||||
expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION)
|
expect(lockfile).to eq <<~L
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo4)}/
|
||||||
|
specs:
|
||||||
|
rack (1.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{lockfile_platforms}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rack
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
#{Bundler::VERSION}
|
||||||
|
L
|
||||||
|
|
||||||
|
expect(the_bundle).to include_gem "rack 1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "updates the bundler version in the lockfile without re-resolving if the highest version is already installed" do
|
||||||
|
system_gems "bundler-2.3.3"
|
||||||
|
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "rack", "1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gem "rack"
|
||||||
|
G
|
||||||
|
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3")
|
||||||
|
|
||||||
|
bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true
|
||||||
|
expect(out).to include("Using bundler #{Bundler::VERSION}")
|
||||||
|
|
||||||
|
expect(lockfile).to eq <<~L
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo4)}/
|
||||||
|
specs:
|
||||||
|
rack (1.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{lockfile_platforms}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rack
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
#{Bundler::VERSION}
|
||||||
|
L
|
||||||
|
|
||||||
|
expect(the_bundle).to include_gem "rack 1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo, :realworld do
|
||||||
|
pristine_system_gems "bundler-2.3.3"
|
||||||
|
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "rack", "1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gem "rack"
|
||||||
|
G
|
||||||
|
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3")
|
||||||
|
|
||||||
|
bundle :update, :bundler => true, :artifice => "vcr", :verbose => true
|
||||||
|
|
||||||
|
# Only updates properly on modern RubyGems.
|
||||||
|
|
||||||
|
if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev")
|
||||||
|
expect(out).to include("Updating bundler to 2.3.4")
|
||||||
|
expect(out).to include("Using bundler 2.3.4")
|
||||||
|
expect(out).not_to include("Installing Bundler 2.3.3 and restarting using that version.")
|
||||||
|
|
||||||
|
expect(lockfile).to eq <<~L
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo4)}/
|
||||||
|
specs:
|
||||||
|
rack (1.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{lockfile_platforms}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rack
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.3.4
|
||||||
|
L
|
||||||
|
|
||||||
|
expect(the_bundle).to include_gems "bundler 2.3.4"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(the_bundle).to include_gems "rack 1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "errors if the explicit target version does not exist", :realworld do
|
||||||
|
pristine_system_gems "bundler-2.3.3"
|
||||||
|
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "rack", "1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gem "rack"
|
||||||
|
G
|
||||||
|
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3")
|
||||||
|
|
||||||
|
bundle :update, :bundler => "999.999.999", :artifice => "vcr", :raise_on_error => false
|
||||||
|
|
||||||
|
# Only gives a meaningful error message on modern RubyGems.
|
||||||
|
|
||||||
|
if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev")
|
||||||
|
expect(last_command).to be_failure
|
||||||
|
expect(err).to include("The `bundle update --bundler` target version (999.999.999) does not exist")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows updating to development versions if already installed locally" do
|
||||||
|
system_gems "bundler-2.3.0.dev"
|
||||||
|
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "rack", "1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gem "rack"
|
||||||
|
G
|
||||||
|
|
||||||
|
bundle :update, :bundler => "2.3.0.dev"
|
||||||
|
|
||||||
|
# Only updates properly on modern RubyGems.
|
||||||
|
|
||||||
|
if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev")
|
||||||
|
expect(lockfile).to eq <<~L
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo4)}/
|
||||||
|
specs:
|
||||||
|
rack (1.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{lockfile_platforms}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rack
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.3.0.dev
|
||||||
|
L
|
||||||
|
|
||||||
|
expect(out).to include("Using bundler 2.3.0.dev")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not touch the network if not necessary" do
|
||||||
|
system_gems "bundler-2.3.3"
|
||||||
|
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "rack", "1.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gem "rack"
|
||||||
|
G
|
||||||
|
|
||||||
|
bundle :update, :bundler => "2.3.3", :raise_on_error => false
|
||||||
|
|
||||||
|
expect(out).not_to include("Fetching gem metadata from https://rubygems.org/")
|
||||||
|
|
||||||
|
# Only updates properly on modern RubyGems.
|
||||||
|
|
||||||
|
if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev")
|
||||||
|
expect(lockfile).to eq <<~L
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo4)}/
|
||||||
|
specs:
|
||||||
|
rack (1.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{lockfile_platforms}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rack
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.3.3
|
||||||
|
L
|
||||||
|
|
||||||
|
expect(out).to include("Using bundler 2.3.3")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ RSpec.describe "bundle install from an existing gemspec" do
|
||||||
gemspec :path => '#{tmp.join("foo")}'
|
gemspec :path => '#{tmp.join("foo")}'
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "update --bundler", :verbose => true
|
bundle "update --bundler", :artifice => "compact_index", :verbose => true
|
||||||
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 JAVA"
|
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 JAVA"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -429,13 +429,16 @@ RSpec.describe "bundle install from an existing gemspec" do
|
||||||
gemspec
|
gemspec
|
||||||
G
|
G
|
||||||
|
|
||||||
simulate_platform("ruby") { bundle "install" }
|
bundle "config set --local force_ruby_platform true"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
|
simulate_new_machine
|
||||||
simulate_platform("jruby") { bundle "install" }
|
simulate_platform("jruby") { bundle "install" }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "on ruby" do
|
context "on ruby" do
|
||||||
before do
|
before do
|
||||||
simulate_platform("ruby")
|
bundle "config set --local force_ruby_platform true"
|
||||||
bundle :install
|
bundle :install
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -546,7 +549,7 @@ RSpec.describe "bundle install from an existing gemspec" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs the ruby platform gemspec" do
|
it "installs the ruby platform gemspec" do
|
||||||
simulate_platform "ruby"
|
bundle "config set --local force_ruby_platform true"
|
||||||
|
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -557,7 +560,7 @@ RSpec.describe "bundle install from an existing gemspec" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs the ruby platform gemspec and skips dev deps with `without development` configured" do
|
it "installs the ruby platform gemspec and skips dev deps with `without development` configured" do
|
||||||
simulate_platform "ruby"
|
bundle "config set --local force_ruby_platform true"
|
||||||
|
|
||||||
bundle "config set --local without development"
|
bundle "config set --local without development"
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
|
@ -622,4 +625,64 @@ RSpec.describe "bundle install from an existing gemspec" do
|
||||||
expect(lockfile).to eq initial_lockfile
|
expect(lockfile).to eq initial_lockfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with multiple locked platforms" do
|
||||||
|
before do
|
||||||
|
build_lib("activeadmin", :path => tmp.join("activeadmin")) do |s|
|
||||||
|
s.version = "2.9.0"
|
||||||
|
s.add_dependency "railties", ">= 5.2", "< 6.2"
|
||||||
|
end
|
||||||
|
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "railties", "6.1.4"
|
||||||
|
|
||||||
|
build_gem "jruby-openssl", "0.10.7" do |s|
|
||||||
|
s.platform = "java"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gemspec :path => "../activeadmin"
|
||||||
|
gem "jruby-openssl", :platform => :jruby
|
||||||
|
G
|
||||||
|
|
||||||
|
bundle "lock --add-platform java"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not remove the platform specific specs from the lockfile when re-resolving due to gemspec changes" do
|
||||||
|
expect(lockfile).to eq <<~L
|
||||||
|
PATH
|
||||||
|
remote: ../activeadmin
|
||||||
|
specs:
|
||||||
|
activeadmin (2.9.0)
|
||||||
|
railties (>= 5.2, < 6.2)
|
||||||
|
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo4)}/
|
||||||
|
specs:
|
||||||
|
jruby-openssl (0.10.7-java)
|
||||||
|
railties (6.1.4)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{lockfile_platforms_for(["java"] + local_platforms)}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
activeadmin!
|
||||||
|
jruby-openssl
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
#{Bundler::VERSION}
|
||||||
|
L
|
||||||
|
|
||||||
|
gemspec = tmp.join("activeadmin/activeadmin.gemspec")
|
||||||
|
File.write(gemspec, File.read(gemspec).sub(">= 5.2", ">= 6.0"))
|
||||||
|
|
||||||
|
previous_lockfile = lockfile
|
||||||
|
|
||||||
|
bundle "install --local"
|
||||||
|
|
||||||
|
expect(lockfile).to eq(previous_lockfile.sub(">= 5.2", ">= 6.0"))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -92,9 +92,7 @@ RSpec.describe "bundle install with git sources" do
|
||||||
expect(err).to include("The source contains the following gems matching 'foo':\n * foo-1.0")
|
expect(err).to include("The source contains the following gems matching 'foo':\n * foo-1.0")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "complains with version and platform if pinned specs don't exist in the git repo" do
|
it "complains with version and platform if pinned specs don't exist in the git repo", :jruby do
|
||||||
simulate_platform "java"
|
|
||||||
|
|
||||||
build_git "only_java" do |s|
|
build_git "only_java" do |s|
|
||||||
s.platform = "java"
|
s.platform = "java"
|
||||||
end
|
end
|
||||||
|
@ -109,9 +107,7 @@ RSpec.describe "bundle install with git sources" do
|
||||||
expect(err).to include("The source contains the following gems matching 'only_java':\n * only_java-1.0-java")
|
expect(err).to include("The source contains the following gems matching 'only_java':\n * only_java-1.0-java")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "complains with multiple versions and platforms if pinned specs don't exist in the git repo" do
|
it "complains with multiple versions and platforms if pinned specs don't exist in the git repo", :jruby do
|
||||||
simulate_platform "java"
|
|
||||||
|
|
||||||
build_git "only_java", "1.0" do |s|
|
build_git "only_java", "1.0" do |s|
|
||||||
s.platform = "java"
|
s.platform = "java"
|
||||||
end
|
end
|
||||||
|
@ -418,9 +414,6 @@ RSpec.describe "bundle install with git sources" do
|
||||||
|
|
||||||
describe "when specifying local override" do
|
describe "when specifying local override" do
|
||||||
it "uses the local repository instead of checking a new one out" do
|
it "uses the local repository instead of checking a new one out" do
|
||||||
# We don't generate it because we actually don't need it
|
|
||||||
# build_git "rack", "0.8"
|
|
||||||
|
|
||||||
build_git "rack", "0.8", :path => lib_path("local-rack") do |s|
|
build_git "rack", "0.8", :path => lib_path("local-rack") do |s|
|
||||||
s.write "lib/rack.rb", "puts :LOCAL"
|
s.write "lib/rack.rb", "puts :LOCAL"
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,13 +86,13 @@ RSpec.describe "bundle install across platforms" do
|
||||||
expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
|
expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
|
||||||
|
|
||||||
simulate_new_machine
|
simulate_new_machine
|
||||||
|
bundle "config set --local force_ruby_platform true"
|
||||||
simulate_platform "ruby"
|
|
||||||
bundle "install"
|
bundle "install"
|
||||||
|
|
||||||
expect(the_bundle).to include_gems "nokogiri 1.4.2"
|
expect(the_bundle).to include_gems "nokogiri 1.4.2"
|
||||||
expect(the_bundle).not_to include_gems "weakling"
|
expect(the_bundle).not_to include_gems "weakling"
|
||||||
|
|
||||||
|
simulate_new_machine
|
||||||
simulate_platform "java"
|
simulate_platform "java"
|
||||||
bundle "install"
|
bundle "install"
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ RSpec.describe "bundle install with platform conditionals" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not attempt to install gems from :rbx when using --local" do
|
it "does not attempt to install gems from :rbx when using --local" do
|
||||||
simulate_platform "ruby"
|
bundle "config set --local force_ruby_platform true"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -465,7 +465,7 @@ RSpec.describe "bundle install with platform conditionals" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not attempt to install gems from other rubies when using --local" do
|
it "does not attempt to install gems from other rubies when using --local" do
|
||||||
simulate_platform "ruby"
|
bundle "config set --local force_ruby_platform true"
|
||||||
other_ruby_version_tag = RUBY_VERSION =~ /^1\.8/ ? :ruby_19 : :ruby_18
|
other_ruby_version_tag = RUBY_VERSION =~ /^1\.8/ ? :ruby_19 : :ruby_18
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
|
@ -478,7 +478,7 @@ RSpec.describe "bundle install with platform conditionals" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not print a warning when a dependency is unused on a platform different from the current one" do
|
it "does not print a warning when a dependency is unused on a platform different from the current one" do
|
||||||
simulate_platform "ruby"
|
bundle "config set --local force_ruby_platform true"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
|
|
@ -46,18 +46,16 @@ RSpec.describe "ruby requirement" do
|
||||||
it "allows changing the ruby version requirement to something compatible" do
|
it "allows changing the ruby version requirement to something compatible" do
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
ruby ">= 1.0.0"
|
ruby ">= #{RUBY_VERSION[0..2]}.0"
|
||||||
gem "rack"
|
gem "rack"
|
||||||
G
|
G
|
||||||
|
|
||||||
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
|
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
|
||||||
expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
|
expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
|
||||||
|
|
||||||
simulate_ruby_version "5100"
|
|
||||||
|
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
ruby ">= 1.0.1"
|
ruby ">= #{RUBY_VERSION}"
|
||||||
gem "rack"
|
gem "rack"
|
||||||
G
|
G
|
||||||
|
|
||||||
|
@ -72,19 +70,35 @@ RSpec.describe "ruby requirement" do
|
||||||
gem "rack"
|
gem "rack"
|
||||||
G
|
G
|
||||||
|
|
||||||
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
|
lockfile <<~L
|
||||||
expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo1)}/
|
||||||
|
specs:
|
||||||
|
rack (1.0.0)
|
||||||
|
|
||||||
simulate_ruby_version "5100"
|
PLATFORMS
|
||||||
|
#{lockfile_platforms}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rack
|
||||||
|
|
||||||
|
RUBY VERSION
|
||||||
|
ruby 2.1.4p422
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
#{Bundler::VERSION}
|
||||||
|
L
|
||||||
|
|
||||||
|
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
|
||||||
|
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
ruby ">= 5000.0"
|
ruby ">= #{RUBY_VERSION[0..2]}.0"
|
||||||
gem "rack"
|
gem "rack"
|
||||||
G
|
G
|
||||||
|
|
||||||
expect(the_bundle).to include_gems "rack 1.0.0"
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
||||||
expect(locked_ruby_version.versions).to eq(["5100"])
|
expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows requirements with trailing whitespace" do
|
it "allows requirements with trailing whitespace" do
|
||||||
|
|
|
@ -1443,4 +1443,57 @@ RSpec.describe "bundle install with gems on multiple sources" do
|
||||||
L
|
L
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when default source includes old gems with nil required_rubygems_version" do
|
||||||
|
before do
|
||||||
|
build_repo2 do
|
||||||
|
build_gem "ruport", "1.7.0.3" do |s|
|
||||||
|
s.add_dependency "pdf-writer", "1.1.8"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
build_repo gem_repo4 do
|
||||||
|
build_gem "pdf-writer", "1.1.8"
|
||||||
|
end
|
||||||
|
|
||||||
|
path = "#{gem_repo4}/#{Gem::MARSHAL_SPEC_DIR}/pdf-writer-1.1.8.gemspec.rz"
|
||||||
|
spec = Marshal.load(Bundler.rubygems.inflate(File.binread(path)))
|
||||||
|
spec.instance_variable_set(:@required_rubygems_version, nil)
|
||||||
|
File.open(path, "wb") do |f|
|
||||||
|
f.write Gem.deflate(Marshal.dump(spec))
|
||||||
|
end
|
||||||
|
|
||||||
|
gemfile <<~G
|
||||||
|
source "https://localgemserver.test"
|
||||||
|
|
||||||
|
gem "ruport", "= 1.7.0.3", :source => "https://localgemserver.test/extra"
|
||||||
|
G
|
||||||
|
end
|
||||||
|
|
||||||
|
it "handles that fine" do
|
||||||
|
bundle "install", :artifice => "compact_index_extra", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
|
||||||
|
|
||||||
|
expect(lockfile).to eq <<~L
|
||||||
|
GEM
|
||||||
|
remote: https://localgemserver.test/
|
||||||
|
specs:
|
||||||
|
pdf-writer (1.1.8)
|
||||||
|
|
||||||
|
GEM
|
||||||
|
remote: https://localgemserver.test/extra/
|
||||||
|
specs:
|
||||||
|
ruport (1.7.0.3)
|
||||||
|
pdf-writer (= 1.1.8)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
#{specific_local_platform}
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
ruport (= 1.7.0.3)!
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
#{Bundler::VERSION}
|
||||||
|
L
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -402,17 +402,6 @@ RSpec.describe "gemcutter's dependency API" do
|
||||||
expect(the_bundle).to include_gems "back_deps 1.0"
|
expect(the_bundle).to include_gems "back_deps 1.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the endpoint if all sources support it" do
|
|
||||||
gemfile <<-G
|
|
||||||
source "#{source_uri}"
|
|
||||||
|
|
||||||
gem 'foo'
|
|
||||||
G
|
|
||||||
|
|
||||||
bundle :install, :artifice => "endpoint_api_missing"
|
|
||||||
expect(the_bundle).to include_gems "foo 1.0"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "fetches again when more dependencies are found in subsequent sources using deployment mode", :bundler => "< 3" do
|
it "fetches again when more dependencies are found in subsequent sources using deployment mode", :bundler => "< 3" do
|
||||||
build_repo2 do
|
build_repo2 do
|
||||||
build_gem "back_deps" do |s|
|
build_gem "back_deps" do |s|
|
||||||
|
|
|
@ -101,8 +101,6 @@ RSpec.describe "bundle install with install-time dependencies" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs gems with a dependency with no type" do
|
it "installs gems with a dependency with no type" do
|
||||||
skip "incorrect data check error" if Gem.win_platform?
|
|
||||||
|
|
||||||
build_repo2
|
build_repo2
|
||||||
|
|
||||||
path = "#{gem_repo2}/#{Gem::MARSHAL_SPEC_DIR}/actionpack-2.3.2.gemspec.rz"
|
path = "#{gem_repo2}/#{Gem::MARSHAL_SPEC_DIR}/actionpack-2.3.2.gemspec.rz"
|
||||||
|
@ -110,7 +108,7 @@ RSpec.describe "bundle install with install-time dependencies" do
|
||||||
spec.dependencies.each do |d|
|
spec.dependencies.each do |d|
|
||||||
d.instance_variable_set(:@type, :fail)
|
d.instance_variable_set(:@type, :fail)
|
||||||
end
|
end
|
||||||
File.open(path, "w") do |f|
|
File.open(path, "wb") do |f|
|
||||||
f.write Gem.deflate(Marshal.dump(spec))
|
f.write Gem.deflate(Marshal.dump(spec))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -226,6 +224,27 @@ 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 "installs the older version when using servers not implementing the compact index API" do
|
||||||
|
build_repo2 do
|
||||||
|
build_gem "rack", "1.2" do |s|
|
||||||
|
s.executables = "rackup"
|
||||||
|
end
|
||||||
|
|
||||||
|
build_gem "rack", "9001.0.0" do |s|
|
||||||
|
s.required_ruby_version = "> 9000"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G, :artifice => "endpoint", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
|
||||||
|
ruby "#{RUBY_VERSION}"
|
||||||
|
source "http://localgemserver.test/"
|
||||||
|
gem 'rack'
|
||||||
|
G
|
||||||
|
|
||||||
|
expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
|
||||||
|
expect(the_bundle).to include_gems("rack 1.2")
|
||||||
|
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|
|
||||||
|
@ -286,8 +305,6 @@ RSpec.describe "bundle install with install-time dependencies" do
|
||||||
|
|
||||||
shared_examples_for "ruby version conflicts" do
|
shared_examples_for "ruby version conflicts" do
|
||||||
it "raises an error during resolution" do
|
it "raises an error during resolution" do
|
||||||
skip "ruby requirement includes platform and it shouldn't" if Gem.win_platform?
|
|
||||||
|
|
||||||
install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false
|
install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false
|
||||||
source "http://localgemserver.test/"
|
source "http://localgemserver.test/"
|
||||||
ruby #{ruby_requirement}
|
ruby #{ruby_requirement}
|
||||||
|
@ -303,8 +320,6 @@ RSpec.describe "bundle install with install-time dependencies" do
|
||||||
|
|
||||||
require_ruby was resolved to 1.0, which depends on
|
require_ruby was resolved to 1.0, which depends on
|
||||||
Ruby\0 (> 9000)
|
Ruby\0 (> 9000)
|
||||||
|
|
||||||
Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
|
|
||||||
E
|
E
|
||||||
expect(err).to end_with(nice_error)
|
expect(err).to end_with(nice_error)
|
||||||
end
|
end
|
||||||
|
@ -343,7 +358,15 @@ RSpec.describe "bundle install with install-time dependencies" do
|
||||||
G
|
G
|
||||||
|
|
||||||
expect(err).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
|
expect(err).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
|
||||||
expect(err).to include("require_rubygems-1.0 requires rubygems version > 9000, which is incompatible with the current version, #{Gem::VERSION}")
|
nice_error = strip_whitespace(<<-E).strip
|
||||||
|
Bundler found conflicting requirements for the RubyGems\0 version:
|
||||||
|
In Gemfile:
|
||||||
|
RubyGems\0 (= #{Gem::VERSION})
|
||||||
|
|
||||||
|
require_rubygems was resolved to 1.0, which depends on
|
||||||
|
RubyGems\0 (> 9000)
|
||||||
|
E
|
||||||
|
expect(err).to end_with(nice_error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.describe "the lockfile format" do
|
RSpec.describe "the lockfile format" do
|
||||||
include Bundler::GemHelpers
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
build_repo2 do
|
build_repo2
|
||||||
# Capistrano did this (at least until version 2.5.10)
|
|
||||||
# RubyGems 2.2 doesn't allow the specifying of a dependency twice
|
|
||||||
# See https://github.com/rubygems/rubygems/commit/03dbac93a3396a80db258d9bc63500333c25bd2f
|
|
||||||
build_gem "double_deps", "1.0", :skip_validation => true do |s|
|
|
||||||
s.add_dependency "net-ssh", ">= 1.0.0"
|
|
||||||
s.add_dependency "net-ssh"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "generates a simple lockfile for a single source, gem" do
|
it "generates a simple lockfile for a single source, gem" do
|
||||||
|
@ -90,12 +80,8 @@ RSpec.describe "the lockfile format" do
|
||||||
G
|
G
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not update the lockfile's bundler version if nothing changed during bundle install, but uses the locked version", :rubygems => ">= 3.3.0.a" do
|
it "does not update the lockfile's bundler version if nothing changed during bundle install, but uses the locked version", :rubygems => ">= 3.3.0.a", :realworld => true do
|
||||||
version = "#{Bundler::VERSION.split(".").first}.0.0.a"
|
version = "2.3.0"
|
||||||
|
|
||||||
update_repo2 do
|
|
||||||
with_built_bundler(version) {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
|
|
||||||
end
|
|
||||||
|
|
||||||
lockfile <<-L
|
lockfile <<-L
|
||||||
GEM
|
GEM
|
||||||
|
@ -113,7 +99,7 @@ RSpec.describe "the lockfile format" do
|
||||||
#{version}
|
#{version}
|
||||||
L
|
L
|
||||||
|
|
||||||
install_gemfile <<-G, :verbose => true, :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
|
install_gemfile <<-G, :verbose => true, :artifice => "vcr"
|
||||||
source "#{file_uri_for(gem_repo2)}"
|
source "#{file_uri_for(gem_repo2)}"
|
||||||
|
|
||||||
gem "rack"
|
gem "rack"
|
||||||
|
@ -142,10 +128,6 @@ RSpec.describe "the lockfile format" do
|
||||||
it "does not update the lockfile's bundler version if nothing changed during bundle install, and uses the latest version", :rubygems => "< 3.3.0.a" do
|
it "does not update the lockfile's bundler version if nothing changed during bundle install, and uses the latest version", :rubygems => "< 3.3.0.a" do
|
||||||
version = "#{Bundler::VERSION.split(".").first}.0.0.a"
|
version = "#{Bundler::VERSION.split(".").first}.0.0.a"
|
||||||
|
|
||||||
update_repo2 do
|
|
||||||
with_built_bundler(version) {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
|
|
||||||
end
|
|
||||||
|
|
||||||
lockfile <<-L
|
lockfile <<-L
|
||||||
GEM
|
GEM
|
||||||
remote: #{file_uri_for(gem_repo2)}/
|
remote: #{file_uri_for(gem_repo2)}/
|
||||||
|
@ -162,7 +144,7 @@ RSpec.describe "the lockfile format" do
|
||||||
#{version}
|
#{version}
|
||||||
L
|
L
|
||||||
|
|
||||||
install_gemfile <<-G, :verbose => true, :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
|
install_gemfile <<-G, :verbose => true
|
||||||
source "#{file_uri_for(gem_repo2)}"
|
source "#{file_uri_for(gem_repo2)}"
|
||||||
|
|
||||||
gem "rack"
|
gem "rack"
|
||||||
|
@ -761,6 +743,16 @@ RSpec.describe "the lockfile format" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "orders dependencies by version" do
|
it "orders dependencies by version" do
|
||||||
|
update_repo2 do
|
||||||
|
# Capistrano did this (at least until version 2.5.10)
|
||||||
|
# RubyGems 2.2 doesn't allow the specifying of a dependency twice
|
||||||
|
# See https://github.com/rubygems/rubygems/commit/03dbac93a3396a80db258d9bc63500333c25bd2f
|
||||||
|
build_gem "double_deps", "1.0", :skip_validation => true do |s|
|
||||||
|
s.add_dependency "net-ssh", ">= 1.0.0"
|
||||||
|
s.add_dependency "net-ssh"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo2)}/"
|
source "#{file_uri_for(gem_repo2)}/"
|
||||||
gem 'double_deps'
|
gem 'double_deps'
|
||||||
|
|
|
@ -17,7 +17,7 @@ RSpec.describe "bundle platform" do
|
||||||
|
|
||||||
bundle "platform"
|
bundle "platform"
|
||||||
expect(out).to eq(<<-G.chomp)
|
expect(out).to eq(<<-G.chomp)
|
||||||
Your platform is: #{RUBY_PLATFORM}
|
Your platform is: #{Gem::Platform.local}
|
||||||
|
|
||||||
Your app has gems that work on these platforms:
|
Your app has gems that work on these platforms:
|
||||||
#{bundle_platform_platforms_string}
|
#{bundle_platform_platforms_string}
|
||||||
|
@ -40,7 +40,7 @@ G
|
||||||
|
|
||||||
bundle "platform"
|
bundle "platform"
|
||||||
expect(out).to eq(<<-G.chomp)
|
expect(out).to eq(<<-G.chomp)
|
||||||
Your platform is: #{RUBY_PLATFORM}
|
Your platform is: #{Gem::Platform.local}
|
||||||
|
|
||||||
Your app has gems that work on these platforms:
|
Your app has gems that work on these platforms:
|
||||||
#{bundle_platform_platforms_string}
|
#{bundle_platform_platforms_string}
|
||||||
|
@ -61,7 +61,7 @@ G
|
||||||
|
|
||||||
bundle "platform"
|
bundle "platform"
|
||||||
expect(out).to eq(<<-G.chomp)
|
expect(out).to eq(<<-G.chomp)
|
||||||
Your platform is: #{RUBY_PLATFORM}
|
Your platform is: #{Gem::Platform.local}
|
||||||
|
|
||||||
Your app has gems that work on these platforms:
|
Your app has gems that work on these platforms:
|
||||||
#{bundle_platform_platforms_string}
|
#{bundle_platform_platforms_string}
|
||||||
|
@ -81,7 +81,7 @@ G
|
||||||
|
|
||||||
bundle "platform"
|
bundle "platform"
|
||||||
expect(out).to eq(<<-G.chomp)
|
expect(out).to eq(<<-G.chomp)
|
||||||
Your platform is: #{RUBY_PLATFORM}
|
Your platform is: #{Gem::Platform.local}
|
||||||
|
|
||||||
Your app has gems that work on these platforms:
|
Your app has gems that work on these platforms:
|
||||||
#{bundle_platform_platforms_string}
|
#{bundle_platform_platforms_string}
|
||||||
|
|
|
@ -309,7 +309,7 @@ RSpec.describe "bundler/inline#gemfile" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "skips platform warnings" do
|
it "skips platform warnings" do
|
||||||
simulate_platform "ruby"
|
bundle "config set --local force_ruby_platform true"
|
||||||
|
|
||||||
script <<-RUBY
|
script <<-RUBY
|
||||||
gemfile(true) do
|
gemfile(true) do
|
||||||
|
|
|
@ -232,6 +232,20 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
|
||||||
expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 RUBY"
|
expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 RUBY"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows specifying only-ruby-platform even if the lockfile is locked to a specific compatible platform" do
|
||||||
|
install_gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
gem "nokogiri"
|
||||||
|
gem "platform_specific"
|
||||||
|
G
|
||||||
|
|
||||||
|
bundle "config set force_ruby_platform true"
|
||||||
|
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
|
expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 RUBY"
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't pull platform specific gems on truffleruby", :truffleruby do
|
it "doesn't pull platform specific gems on truffleruby", :truffleruby do
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
|
RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => true do
|
||||||
describe "auto switching" do
|
describe "auto switching" do
|
||||||
let(:next_minor) do
|
let(:previous_minor) do
|
||||||
Bundler::VERSION.split(".").map.with_index {|s, i| i == 1 ? s.to_i + 1 : s }[0..2].join(".")
|
"2.3.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
build_repo2 do
|
build_repo2
|
||||||
with_built_bundler(next_minor) {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
|
|
||||||
end
|
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo2)}"
|
source "#{file_uri_for(gem_repo2)}"
|
||||||
|
@ -19,11 +17,11 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs locked version when using system path and uses it" do
|
it "installs locked version when using system path and uses it" do
|
||||||
lockfile_bundled_with(next_minor)
|
lockfile_bundled_with(previous_minor)
|
||||||
|
|
||||||
bundle "config set --local path.system true"
|
bundle "config set --local path.system true"
|
||||||
bundle "install", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
|
bundle "install", :artifice => "vcr"
|
||||||
expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
|
expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.")
|
||||||
|
|
||||||
# It uninstalls the older system bundler
|
# It uninstalls the older system bundler
|
||||||
bundle "clean --force"
|
bundle "clean --force"
|
||||||
|
@ -31,21 +29,21 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
|
||||||
|
|
||||||
# App now uses locked version
|
# App now uses locked version
|
||||||
bundle "-v"
|
bundle "-v"
|
||||||
expect(out).to end_with(next_minor[0] == "2" ? "Bundler version #{next_minor}" : next_minor)
|
expect(out).to end_with(previous_minor[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor)
|
||||||
|
|
||||||
# Subsequent installs use the locked version without reinstalling
|
# Subsequent installs use the locked version without reinstalling
|
||||||
bundle "install --verbose"
|
bundle "install --verbose"
|
||||||
expect(out).to include("Using bundler #{next_minor}")
|
expect(out).to include("Using bundler #{previous_minor}")
|
||||||
expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
|
expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs locked version when using local path and uses it" do
|
it "installs locked version when using local path and uses it" do
|
||||||
lockfile_bundled_with(next_minor)
|
lockfile_bundled_with(previous_minor)
|
||||||
|
|
||||||
bundle "config set --local path vendor/bundle"
|
bundle "config set --local path vendor/bundle"
|
||||||
bundle "install", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
|
bundle "install", :artifice => "vcr"
|
||||||
expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
|
expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.")
|
||||||
expect(vendored_gems("gems/bundler-#{next_minor}")).to exist
|
expect(vendored_gems("gems/bundler-#{previous_minor}")).to exist
|
||||||
|
|
||||||
# It does not uninstall the locked bundler
|
# It does not uninstall the locked bundler
|
||||||
bundle "clean"
|
bundle "clean"
|
||||||
|
@ -53,21 +51,21 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
|
||||||
|
|
||||||
# App now uses locked version
|
# App now uses locked version
|
||||||
bundle "-v"
|
bundle "-v"
|
||||||
expect(out).to end_with(next_minor[0] == "2" ? "Bundler version #{next_minor}" : next_minor)
|
expect(out).to end_with(previous_minor[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor)
|
||||||
|
|
||||||
# Subsequent installs use the locked version without reinstalling
|
# Subsequent installs use the locked version without reinstalling
|
||||||
bundle "install --verbose"
|
bundle "install --verbose"
|
||||||
expect(out).to include("Using bundler #{next_minor}")
|
expect(out).to include("Using bundler #{previous_minor}")
|
||||||
expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
|
expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs locked version when using deployment option and uses it" do
|
it "installs locked version when using deployment option and uses it" do
|
||||||
lockfile_bundled_with(next_minor)
|
lockfile_bundled_with(previous_minor)
|
||||||
|
|
||||||
bundle "config set --local deployment true"
|
bundle "config set --local deployment true"
|
||||||
bundle "install", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
|
bundle "install", :artifice => "vcr"
|
||||||
expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
|
expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.")
|
||||||
expect(vendored_gems("gems/bundler-#{next_minor}")).to exist
|
expect(vendored_gems("gems/bundler-#{previous_minor}")).to exist
|
||||||
|
|
||||||
# It does not uninstall the locked bundler
|
# It does not uninstall the locked bundler
|
||||||
bundle "clean"
|
bundle "clean"
|
||||||
|
@ -75,16 +73,16 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
|
||||||
|
|
||||||
# App now uses locked version
|
# App now uses locked version
|
||||||
bundle "-v"
|
bundle "-v"
|
||||||
expect(out).to end_with(next_minor[0] == "2" ? "Bundler version #{next_minor}" : next_minor)
|
expect(out).to end_with(previous_minor[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor)
|
||||||
|
|
||||||
# Subsequent installs use the locked version without reinstalling
|
# Subsequent installs use the locked version without reinstalling
|
||||||
bundle "install --verbose"
|
bundle "install --verbose"
|
||||||
expect(out).to include("Using bundler #{next_minor}")
|
expect(out).to include("Using bundler #{previous_minor}")
|
||||||
expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
|
expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not try to install a development version" do
|
it "does not try to install a development version" do
|
||||||
lockfile_bundled_with("#{next_minor}.dev")
|
lockfile_bundled_with("#{previous_minor}.dev")
|
||||||
|
|
||||||
bundle "install --verbose"
|
bundle "install --verbose"
|
||||||
expect(out).not_to match(/restarting using that version/)
|
expect(out).not_to match(/restarting using that version/)
|
||||||
|
@ -93,17 +91,13 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
|
||||||
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
|
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows a discreet message if locked bundler does not exist, and something more complete in `--verbose` mode" do
|
it "shows a discreet message if locked bundler does not exist" do
|
||||||
missing_minor ="#{Bundler::VERSION[0]}.999.999"
|
missing_minor ="#{Bundler::VERSION[0]}.999.999"
|
||||||
|
|
||||||
lockfile_bundled_with(missing_minor)
|
lockfile_bundled_with(missing_minor)
|
||||||
|
|
||||||
bundle "install"
|
bundle "install", :artifice => "vcr"
|
||||||
expect(err).to eq("There was an error installing the locked bundler version (#{missing_minor}), rerun with the `--verbose` flag for more details. Going on using bundler #{Bundler::VERSION}.")
|
expect(err).to eq("Your lockfile is locked to a version of bundler (#{missing_minor}) that doesn't exist at https://rubygems.org/. Going on using #{Bundler::VERSION}")
|
||||||
|
|
||||||
bundle "install --verbose"
|
|
||||||
expect(err).to include("There was an error installing the locked bundler version (#{missing_minor}), rerun with the `--verbose` flag for more details. Going on using bundler #{Bundler::VERSION}.")
|
|
||||||
expect(err).to include("Gem::UnsatisfiableDependencyError")
|
|
||||||
|
|
||||||
bundle "-v"
|
bundle "-v"
|
||||||
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
|
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require_relative "endpoint"
|
|
||||||
|
|
||||||
Artifice.deactivate
|
|
||||||
|
|
||||||
class EndpointApiMissing < Endpoint
|
|
||||||
get "/fetch/actual/gem/:id" do
|
|
||||||
warn params[:id]
|
|
||||||
if params[:id] == "rack-1.0.gemspec.rz"
|
|
||||||
halt 404
|
|
||||||
else
|
|
||||||
File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Artifice.activate_with(EndpointApiMissing)
|
|
|
@ -69,7 +69,7 @@ class BundlerVCRHTTP < Net::HTTP
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_name_for_key(key)
|
def file_name_for_key(key)
|
||||||
key.join("/").gsub(/[\:*?"<>|]/, "-")
|
File.join(*key).gsub(/[\:*?"<>|]/, "-")
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_pair_paths
|
def request_pair_paths
|
||||||
|
|
|
@ -19,16 +19,6 @@ module Gem
|
||||||
@local = new(ENV["BUNDLER_SPEC_PLATFORM"])
|
@local = new(ENV["BUNDLER_SPEC_PLATFORM"])
|
||||||
end
|
end
|
||||||
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
|
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
|
||||||
|
|
||||||
if ENV["BUNDLER_SPEC_PLATFORM"] == "ruby"
|
|
||||||
class << self
|
|
||||||
remove_method :finish_resolve
|
|
||||||
|
|
||||||
def finish_resolve
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV["BUNDLER_SPEC_GEM_SOURCES"]
|
if ENV["BUNDLER_SPEC_GEM_SOURCES"]
|
||||||
|
|
|
@ -88,7 +88,6 @@ module Spec
|
||||||
|
|
||||||
requires = options.delete(:requires) || []
|
requires = options.delete(:requires) || []
|
||||||
realworld = RSpec.current_example.metadata[:realworld]
|
realworld = RSpec.current_example.metadata[:realworld]
|
||||||
options[:verbose] = true if options[:verbose].nil? && realworld
|
|
||||||
|
|
||||||
artifice = options.delete(:artifice) do
|
artifice = options.delete(:artifice) do
|
||||||
if realworld
|
if realworld
|
||||||
|
@ -448,15 +447,6 @@ module Spec
|
||||||
ENV["BUNDLER_SPEC_PLATFORM"] = old if block_given?
|
ENV["BUNDLER_SPEC_PLATFORM"] = old if block_given?
|
||||||
end
|
end
|
||||||
|
|
||||||
def simulate_ruby_version(version)
|
|
||||||
return if version == RUBY_VERSION
|
|
||||||
old = ENV["BUNDLER_SPEC_RUBY_VERSION"]
|
|
||||||
ENV["BUNDLER_SPEC_RUBY_VERSION"] = version
|
|
||||||
yield if block_given?
|
|
||||||
ensure
|
|
||||||
ENV["BUNDLER_SPEC_RUBY_VERSION"] = old if block_given?
|
|
||||||
end
|
|
||||||
|
|
||||||
def simulate_windows(platform = mswin)
|
def simulate_windows(platform = mswin)
|
||||||
simulate_platform platform do
|
simulate_platform platform do
|
||||||
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
|
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
|
||||||
|
|
|
@ -119,7 +119,7 @@ module Spec
|
||||||
ENV["BUNDLE_PATH__SYSTEM"] = "true"
|
ENV["BUNDLE_PATH__SYSTEM"] = "true"
|
||||||
end
|
end
|
||||||
|
|
||||||
output = `#{Gem.ruby} #{File.expand_path("support/bundle.rb", Path.spec_dir)} install`
|
output = `#{Gem.ruby} #{File.expand_path("support/bundle.rb", Path.spec_dir)} install --verbose`
|
||||||
raise "Error when installing gems in #{gemfile}: #{output}" unless $?.success?
|
raise "Error when installing gems in #{gemfile}: #{output}" unless $?.success?
|
||||||
ensure
|
ensure
|
||||||
if path
|
if path
|
||||||
|
|
|
@ -339,10 +339,10 @@ class Gem::TestCase < Test::Unit::TestCase
|
||||||
ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache'
|
ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache'
|
||||||
|
|
||||||
@orig_ruby = if ENV['RUBY']
|
@orig_ruby = if ENV['RUBY']
|
||||||
ruby = Gem.ruby
|
ruby = Gem.ruby
|
||||||
Gem.ruby = ENV['RUBY']
|
Gem.ruby = ENV['RUBY']
|
||||||
ruby
|
ruby
|
||||||
end
|
end
|
||||||
|
|
||||||
@git = ENV['GIT'] || (win_platform? ? 'git.exe' : 'git')
|
@git = ENV['GIT'] || (win_platform? ? 'git.exe' : 'git')
|
||||||
|
|
||||||
|
@ -685,10 +685,10 @@ class Gem::TestCase < Test::Unit::TestCase
|
||||||
# Load a YAML string, the psych 3 way
|
# Load a YAML string, the psych 3 way
|
||||||
|
|
||||||
def load_yaml(yaml)
|
def load_yaml(yaml)
|
||||||
if YAML.respond_to?(:unsafe_load)
|
if Psych.respond_to?(:unsafe_load)
|
||||||
YAML.unsafe_load(yaml)
|
Psych.unsafe_load(yaml)
|
||||||
else
|
else
|
||||||
YAML.load(yaml)
|
Psych.load(yaml)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -696,10 +696,10 @@ class Gem::TestCase < Test::Unit::TestCase
|
||||||
# Load a YAML file, the psych 3 way
|
# Load a YAML file, the psych 3 way
|
||||||
|
|
||||||
def load_yaml_file(file)
|
def load_yaml_file(file)
|
||||||
if YAML.respond_to?(:unsafe_load_file)
|
if Psych.respond_to?(:unsafe_load_file)
|
||||||
YAML.unsafe_load_file(file)
|
Psych.unsafe_load_file(file)
|
||||||
else
|
else
|
||||||
YAML.load_file(file)
|
Psych.load_file(file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2022,6 +2022,8 @@ You may need to `bundle install` to install missing gems
|
||||||
ENV['SOURCE_DATE_EPOCH'] = old_epoch
|
ENV['SOURCE_DATE_EPOCH'] = old_epoch
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def ruby_install_name(name)
|
def ruby_install_name(name)
|
||||||
with_clean_path_to_ruby do
|
with_clean_path_to_ruby do
|
||||||
orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
|
orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
|
||||||
|
|
|
@ -252,7 +252,7 @@ class TestGemCommandManager < Gem::TestCase
|
||||||
Gem::Deprecate.skip_during do
|
Gem::Deprecate.skip_during do
|
||||||
@command_manager.process_args %w[query]
|
@command_manager.process_args %w[query]
|
||||||
end
|
end
|
||||||
assert_equal(//, check_options[:name])
|
assert_nil(check_options[:name])
|
||||||
assert_equal :local, check_options[:domain]
|
assert_equal :local, check_options[:domain]
|
||||||
assert_equal false, check_options[:details]
|
assert_equal false, check_options[:details]
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue