Merge RubyGems-3.3.17 and Bundler-2.3.17

This commit is contained in:
Hiroshi SHIBATA 2022-07-13 14:45:18 +09:00 committed by nagachika
parent a01f5ad1ec
commit 7ef68dd74a
67 changed files with 496 additions and 652 deletions

View file

@ -251,8 +251,10 @@ module Bundler
remembered_negative_flag_deprecation("no-deployment")
require_relative "cli/install"
Bundler.settings.temporary(:no_install => false) do
Install.new(options.dup).run
end
end
map aliases_for("install")
@ -297,8 +299,10 @@ module Bundler
def update(*gems)
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require_relative "cli/update"
Bundler.settings.temporary(:no_install => false) do
Update.new(options, gems).run
end
end
desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
long_desc <<-D

View file

@ -14,7 +14,7 @@ module Bundler
Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
setup_cache_all
install unless Bundler.settings[:no_install]
install
# TODO: move cache contents here now that all bundles are locked
custom_path = Bundler.settings[:path] if options[:path]

View file

@ -161,6 +161,8 @@ module Bundler
Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"]
Bundler.settings.set_command_option_if_given :no_install, options["no-install"]
Bundler.settings.set_command_option_if_given :clean, options["clean"]
normalize_groups if options[:without] || options[:with]

View file

@ -78,7 +78,7 @@ module Bundler
end
def x64_mingw?
Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os.start_with?("mingw") && Bundler.local_platform.cpu == "x64"
end
(KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|

View file

@ -122,7 +122,7 @@ module Bundler
end
def expanded_platforms
@expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq
@expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq
end
def should_include?

View file

@ -29,8 +29,11 @@ module Bundler
Bundler.ui.error error.message
Bundler.ui.trace error.orig_exception
when BundlerError
Bundler.ui.error error.message, :wrap => true
if Bundler.ui.debug?
Bundler.ui.trace error
else
Bundler.ui.error error.message, :wrap => true
end
when Thor::Error
Bundler.ui.error error.message
when LoadError

View file

@ -10,6 +10,7 @@ module Bundler
[Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],
[Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
[Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
[Gem::Platform.new("x64-mingw-ucrt"), Gem::Platform.new("x64-mingw-ucrt")],
[Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")],
].freeze

View file

@ -192,11 +192,7 @@ module Bundler
specs += base if base
found = specs.select do |spec|
next true if spec.source.is_a?(Source::Gemspec)
if base # allow all platforms when searching from a lockfile
dependency.matches_spec?(spec)
else
dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec)
end
end
found

View file

@ -12,6 +12,7 @@ module Bundler
end
File.open File.join(bundler_path, "setup.rb"), "w" do |file|
file.puts "require 'rbconfig'"
file.puts define_path_helpers
file.puts reverse_rubygems_kernel_mixin
paths.each do |path|
if Pathname.new(path).absolute?
@ -29,14 +30,20 @@ module Bundler
@specs.map do |spec|
next if spec.name == "bundler"
Array(spec.require_paths).map do |path|
gem_path(path, spec).sub(version_dir, '#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}')
gem_path(path, spec).
sub(version_dir, '#{RUBY_ENGINE}/#{Gem.ruby_api_version}').
sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
# This is a static string intentionally. It's interpolated at a later time.
end
end.flatten.compact
end
def version_dir
"#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}"
"#{RUBY_ENGINE}/#{Gem.ruby_api_version}"
end
def extensions_dir
%r{extensions/(?<platform>[^/]+)/#{Regexp.escape(Gem.extension_api_version)}}
end
def bundler_path
@ -55,6 +62,26 @@ module Bundler
raise Gem::InvalidSpecificationException.new(error_message)
end
def define_path_helpers
<<~'END'
unless defined?(Gem)
module Gem
def self.ruby_api_version
RbConfig::CONFIG["ruby_version"]
end
def self.extension_api_version
if 'no' == RbConfig::CONFIG['ENABLE_SHARED']
"#{ruby_api_version}-static"
else
ruby_api_version
end
end
end
end
END
end
def reverse_rubygems_kernel_mixin
<<~END
kernel = (class << ::Kernel; self; end)

View file

@ -84,7 +84,7 @@ module Bundler
else
ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version)
end
platform_object = Gem::Platform.new(platform)
platform_object = ruby_platform_materializes_to_ruby_platform? ? Gem::Platform.new(platform) : Gem::Platform.local
candidates = source.specs.search(search_object)
same_platform_candidates = candidates.select do |spec|
MatchPlatform.platforms_match?(spec.platform, platform_object)
@ -152,7 +152,7 @@ module Bundler
# explicitly add a more specific platform.
#
def ruby_platform_materializes_to_ruby_platform?
!Bundler.most_specific_locked_platform?(Gem::Platform::RUBY) || Bundler.settings[:force_ruby_platform]
!Bundler.most_specific_locked_platform?(generic_local_platform) || Bundler.settings[:force_ruby_platform]
end
end
end

View file

@ -41,7 +41,7 @@ Specify version requirements(s) for the added gem\.
Specify the group(s) for the added gem\. Multiple groups should be separated by commas\.
.
.TP
\fB\-\-source\fR, , \fB\-s\fR
\fB\-\-source\fR, \fB\-s\fR
Specify the source for the added gem\.
.
.TP

View file

@ -27,7 +27,7 @@ bundle add rails --group "development, test"
* `--group`, `-g`:
Specify the group(s) for the added gem. Multiple groups should be separated by commas.
* `--source`, , `-s`:
* `--source`, `-s`:
Specify the source for the added gem.
* `--require`, `-r`:

View file

@ -15,7 +15,6 @@ module Bundler
return true if Gem::Platform::RUBY == gemspec_platform
return true if local_platform == gemspec_platform
gemspec_platform = Gem::Platform.new(gemspec_platform)
return true if GemHelpers.generic(gemspec_platform) === local_platform
return true if gemspec_platform === local_platform
false

View file

@ -284,7 +284,7 @@ module Bundler
if specs_matching_requirement.any?
specs = specs_matching_requirement
matching_part = requirement_label
requirement_label = "#{requirement_label} #{requirement.__platform}"
requirement_label = "#{requirement_label}' with platform '#{requirement.__platform}"
end
message = String.new("Could not find gem '#{requirement_label}'#{extra_message} in #{source}#{cache_message}.\n")

View file

@ -216,11 +216,12 @@ module Gem
require "rubygems/platform"
class Platform
JAVA = Gem::Platform.new("java") unless defined?(JAVA)
MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64)
MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW)
X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW)
JAVA = Gem::Platform.new("java")
MSWIN = Gem::Platform.new("mswin32")
MSWIN64 = Gem::Platform.new("mswin64")
MINGW = Gem::Platform.new("x86-mingw32")
X64_MINGW = [Gem::Platform.new("x64-mingw32"),
Gem::Platform.new("x64-mingw-ucrt")].freeze
end
Platform.singleton_class.module_eval do

View file

@ -160,6 +160,8 @@ module Bundler
raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
end
return if Bundler.settings[:no_install]
if requires_sudo?
install_path = Bundler.tmp(spec.full_name)
bin_path = install_path.join("bin")

View file

@ -12,17 +12,19 @@ module Bundler
end
def for(dependencies, check = false, match_current_platform = false)
handled = []
# dep.name => [list, of, deps]
handled = Hash.new {|h, k| h[k] = [] }
deps = dependencies.dup
specs = []
loop do
break unless dep = deps.shift
next if handled.any? {|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
next if handled[dep.name].any? {|d| match_current_platform || d.__platform == dep.__platform } || dep.name == "bundler"
handled << dep
# use a hash here to ensure constant lookup time in the `any?` call above
handled[dep.name] << dep
specs_for_dep = spec_for_dependency(dep, match_current_platform)
specs_for_dep = specs_for_dependency(dep, match_current_platform)
if specs_for_dep.any?
specs.concat(specs_for_dep)
@ -171,12 +173,13 @@ module Bundler
@specs.sort_by(&:name).each {|s| yield s }
end
def spec_for_dependency(dep, match_current_platform)
specs_for_platforms = lookup[dep.name]
def specs_for_dependency(dep, match_current_platform)
specs_for_name = lookup[dep.name]
if match_current_platform
GemHelpers.select_best_platform_match(specs_for_platforms.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
GemHelpers.select_best_platform_match(specs_for_name.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
else
GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
specs_for_name_and_platform = GemHelpers.select_best_platform_match(specs_for_name, dep.__platform)
specs_for_name_and_platform.any? ? specs_for_name_and_platform : specs_for_name
end
end

View file

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

View file

@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
VERSION = "3.3.16".freeze
VERSION = "3.3.17".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@ -1323,8 +1323,9 @@ begin
rescue LoadError
# Ignored
rescue StandardError => e
path = e.backtrace_locations.reverse.find {|l| l.path.end_with?("rubygems/defaults/operating_system.rb") }.path
msg = "#{e.message}\n" \
"Loading the rubygems/defaults/operating_system.rb file caused an error. " \
"Loading the #{path} file caused an error. " \
"This file is owned by your OS, not by rubygems upstream. " \
"Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
"the problem and ask for help."

View file

@ -8,8 +8,9 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
def arguments # :nodoc:
args = <<-EOF
gemdir display the path where gems are installed
gempath display path used to search for gems
home display the path where gems are installed. Aliases: gemhome, gemdir, GEM_HOME
path display path used to search for gems. Aliases: gempath, GEM_PATH
user_gemhome display the path where gems are installed when `--user-install` is given. Aliases: user_gemdir
version display the gem format version
remotesources display the remote gem servers
platform display the supported gem platforms
@ -80,6 +81,8 @@ lib/rubygems/defaults/operating_system.rb
Gem.dir
when /^gempath/, /^path/, /^GEM_PATH/ then
Gem.path.join(File::PATH_SEPARATOR)
when /^user_gemdir/, /^user_gemhome/ then
Gem.user_dir
when /^remotesources/ then
Gem.sources.to_a.join("\n")
when /^platform/ then

View file

@ -17,7 +17,7 @@ class Gem::Ext::Builder
$1.downcase
end
def self.make(dest_path, results, make_dir = Dir.pwd)
def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil)
unless File.exist? File.join(make_dir, 'Makefile')
raise Gem::InstallError, 'Makefile not found'
end
@ -33,11 +33,18 @@ class Gem::Ext::Builder
# The installation of the bundled gems is failed when DESTDIR is empty in mswin platform.
destdir = (/\bnmake/i !~ make_program_name || ENV['DESTDIR'] && ENV['DESTDIR'] != "") ? 'DESTDIR=%s' % ENV['DESTDIR'] : ''
env = [destdir]
if sitedir
env << 'sitearchdir=%s' % sitedir
env << 'sitelibdir=%s' % sitedir
end
['clean', '', 'install'].each do |target|
# Pass DESTDIR via command line to override what's in MAKEFLAGS
cmd = [
*make_program,
destdir,
*env,
target,
].reject(&:empty?)
begin

View file

@ -268,20 +268,14 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
tmp_dest = Dir.mktmpdir(".gem.", extension_dir)
# Some versions of `mktmpdir` return absolute paths, which will break make
# if the paths contain spaces. However, on Ruby 1.9.x on Windows, relative
# paths cause all C extension builds to fail.
# if the paths contain spaces.
#
# As such, we convert to a relative path unless we are using Ruby 1.9.x on
# Windows. This means that when using Ruby 1.9.x on Windows, paths with
# spaces do not work.
#
# Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940
# As such, we convert to a relative path.
tmp_dest_relative = get_relative_path(tmp_dest.clone, extension_dir)
if tmp_dest_relative
full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
# TODO: remove in RubyGems 3
# TODO: remove in RubyGems 4
if Gem.install_extension_in_lib && lib_dir
FileUtils.mkdir_p lib_dir
FileUtils.cp_r ext_path, lib_dir, remove_destination: true
@ -291,7 +285,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
destent = ent.class.new(dest_path, ent.rel)
destent.exist? || FileUtils.mv(ent.path, destent.path)
end
end
ensure
FileUtils.rm_rf tmp_dest if tmp_dest
end

View file

@ -13,37 +13,18 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
tmp_dest = Dir.mktmpdir(".gem.", extension_dir)
# Some versions of `mktmpdir` return absolute paths, which will break make
# if the paths contain spaces. However, on Ruby 1.9.x on Windows, relative
# paths cause all C extension builds to fail.
# if the paths contain spaces.
#
# As such, we convert to a relative path unless we are using Ruby 1.9.x on
# Windows. This means that when using Ruby 1.9.x on Windows, paths with
# spaces do not work.
#
# Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940
# As such, we convert to a relative path.
tmp_dest_relative = get_relative_path(tmp_dest.clone, extension_dir)
Tempfile.open %w[siteconf .rb], extension_dir do |siteconf|
siteconf.puts "require 'rbconfig'"
siteconf.puts "dest_path = #{tmp_dest_relative.dump}"
%w[sitearchdir sitelibdir].each do |dir|
siteconf.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path"
siteconf.puts "RbConfig::CONFIG['#{dir}'] = dest_path"
end
siteconf.close
destdir = ENV["DESTDIR"]
begin
# workaround for https://github.com/oracle/truffleruby/issues/2115
siteconf_path = RUBY_ENGINE == "truffleruby" ? siteconf.path.dup : siteconf.path
require "shellwords"
cmd = Gem.ruby.shellsplit << "-I" << File.expand_path('../..', __dir__) <<
"-r" << get_relative_path(siteconf_path, extension_dir) << File.basename(extension)
cmd = Gem.ruby.shellsplit << "-I" << File.expand_path('../..', __dir__) << File.basename(extension)
cmd.push(*args)
begin
run(cmd, results, class_name, extension_dir) do |s, r|
mkmf_log = File.join(extension_dir, 'mkmf.log')
if File.exist? mkmf_log
@ -55,17 +36,14 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
FileUtils.mv mkmf_log, dest_path
end
end
siteconf.unlink
end
ENV["DESTDIR"] = nil
make dest_path, results, extension_dir
make dest_path, results, extension_dir, tmp_dest_relative
if tmp_dest_relative
full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
# TODO remove in RubyGems 3
# TODO remove in RubyGems 4
if Gem.install_extension_in_lib and lib_dir
FileUtils.mkdir_p lib_dir
entries = Dir.entries(full_tmp_dest) - %w[. ..]
@ -77,11 +55,8 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
destent = ent.class.new(dest_path, ent.rel)
destent.exist? or FileUtils.mv(ent.path, destent.path)
end
end
ensure
ENV["DESTDIR"] = destdir
siteconf.close!
end
end
results

View file

@ -401,6 +401,8 @@ class Gem::Indexer
File.utime newest_mtime, newest_mtime, dst_name
end
ensure
FileUtils.rm_rf @directory
end
##

View file

@ -136,7 +136,7 @@ RSpec.describe Bundler::Definition do
only_java (1.1-java)
PLATFORMS
#{lockfile_platforms_for(["java"] + local_platforms)}
#{lockfile_platforms_for(["java", specific_local_platform])}
DEPENDENCIES
only_java

View file

@ -104,7 +104,6 @@ RSpec.describe Bundler, "friendly errors" do
expect(Bundler.ui).to receive(:error).with(error.message, :wrap => true)
Bundler::FriendlyErrors.log_error(error)
end
it_behaves_like "Bundler.ui receive trace", Bundler::BundlerError.new
end
context "Thor::Error" do

View file

@ -792,7 +792,7 @@ RSpec.describe "bundle clean" do
should_not_have_gems "foo-1.0"
end
it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo do
it "doesn't remove extensions artifacts from bundled git gems after clean" do
build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0"))
@ -815,7 +815,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
end
it "removes extension directories", :ruby_repo do
it "removes extension directories" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@ -851,7 +851,7 @@ RSpec.describe "bundle clean" do
expect(simple_binary_extensions_dir).to exist
end
it "removes git extension directories", :ruby_repo do
it "removes git extension directories" do
build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0"))

View file

@ -217,7 +217,7 @@ RSpec.describe "bundle lock" do
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile = Bundler::LockfileParser.new(read_lockfile)
expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
expect(lockfile.platforms).to match_array([java, mingw, specific_local_platform].uniq)
end
it "supports adding new platforms with force_ruby_platform = true" do
@ -249,7 +249,7 @@ RSpec.describe "bundle lock" do
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile = Bundler::LockfileParser.new(read_lockfile)
expect(lockfile.platforms).to match_array(local_platforms.unshift("ruby").uniq)
expect(lockfile.platforms).to match_array(["ruby", specific_local_platform].uniq)
end
it "warns when adding an unknown platform" do
@ -262,16 +262,16 @@ RSpec.describe "bundle lock" do
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile = Bundler::LockfileParser.new(read_lockfile)
expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
expect(lockfile.platforms).to match_array([java, mingw, specific_local_platform].uniq)
bundle "lock --remove-platform java"
lockfile = Bundler::LockfileParser.new(read_lockfile)
expect(lockfile.platforms).to match_array(local_platforms.unshift(mingw).uniq)
expect(lockfile.platforms).to match_array([mingw, specific_local_platform].uniq)
end
it "errors when removing all platforms" do
bundle "lock --remove-platform #{local_platforms.join(" ")}", :raise_on_error => false
bundle "lock --remove-platform #{specific_local_platform}", :raise_on_error => false
expect(err).to include("Removing all platforms from the bundle is not allowed")
end

View file

@ -821,7 +821,7 @@ RSpec.describe "bundle outdated" do
expect(out).to end_with("Bundle up to date!")
end
it "reports that updates are available if the JRuby platform is used", :jruby do
it "reports that updates are available if the JRuby platform is used", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "laduradura", '= 5.15.2', :platforms => [:ruby, :jruby]

View file

@ -2,7 +2,7 @@
require "bundler/vendored_fileutils"
RSpec.describe "bundle pristine", :ruby_repo do
RSpec.describe "bundle pristine" do
before :each do
build_lib "baz", :path => bundled_app do |s|
s.version = "1.0.0"

View file

@ -8,6 +8,26 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
let(:x64_mingw_archs) do
if RUBY_PLATFORM == "x64-mingw-ucrt"
if Gem.rubygems_version >= Gem::Version.new("3.2.28")
["x64-mingw-ucrt", "x64-mingw32"]
else
["x64-mingw32", "x64-unknown"]
end
else
["x64-mingw32"]
end
end
let(:x64_mingw_gems) do
x64_mingw_archs.map {|p| "platform_specific (1.0-#{p})" }.join("\n ")
end
let(:x64_mingw_platforms) do
x64_mingw_archs.join("\n ")
end
it "should install runtime and development dependencies" do
build_lib("foo", :path => tmp.join("foo")) do |s|
s.write("Gemfile", "source :rubygems\ngemspec")
@ -168,7 +188,7 @@ RSpec.describe "bundle install from an existing gemspec" do
expect(out.scan(message).size).to eq(1)
end
it "should match a lockfile on non-ruby platforms with a transitive platform dependency", :jruby do
it "should match a lockfile on non-ruby platforms with a transitive platform dependency", :jruby_only do
build_lib("foo", :path => tmp.join("foo")) do |s|
s.add_dependency "platform_specific"
end
@ -328,12 +348,7 @@ RSpec.describe "bundle install from an existing gemspec" do
context "with a lockfile and some missing dependencies" do
let(:source_uri) { "http://localgemserver.test" }
context "previously bundled for Ruby" do
let(:platform) { "ruby" }
before do
skip "not installing for some reason" if Gem.win_platform?
build_lib("foo", :path => tmp.join("foo")) do |s|
s.add_dependency "rack", "=1.0.0"
end
@ -366,7 +381,7 @@ RSpec.describe "bundle install from an existing gemspec" do
L
end
context "using JRuby with explicit platform", :jruby do
context "using JRuby with explicit platform", :jruby_only do
before do
create_file(
tmp.join("foo", "foo-java.gemspec"),
@ -385,26 +400,13 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
context "using JRuby", :jruby do
it "should install" do
it "should install", :jruby do
results = bundle "install", :artifice => "endpoint"
expect(results).to include("Installing rack 1.0.0")
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
context "using Windows" do
it "should install" do
simulate_windows do
results = bundle "install", :artifice => "endpoint"
expect(results).to include("Installing rack 1.0.0")
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
end
context "bundled for ruby and jruby" do
context "bundled for multiple platforms" do
let(:platform_specific_type) { :runtime }
let(:dependency) { "platform_specific" }
before do
@ -434,6 +436,7 @@ RSpec.describe "bundle install from an existing gemspec" do
simulate_new_machine
simulate_platform("jruby") { bundle "install" }
simulate_platform(x64_mingw) { bundle "install" }
end
context "on ruby" do
@ -443,7 +446,7 @@ RSpec.describe "bundle install from an existing gemspec" do
end
context "as a runtime dependency" do
it "keeps java dependencies in the lockfile" do
it "keeps all platform dependencies in the lockfile" do
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
PATH
@ -457,10 +460,12 @@ RSpec.describe "bundle install from an existing gemspec" do
specs:
platform_specific (1.0)
platform_specific (1.0-java)
#{x64_mingw_gems}
PLATFORMS
java
ruby
#{x64_mingw_platforms}
DEPENDENCIES
foo!
@ -474,7 +479,7 @@ RSpec.describe "bundle install from an existing gemspec" do
context "as a development dependency" do
let(:platform_specific_type) { :development }
it "keeps java dependencies in the lockfile" do
it "keeps all platform dependencies in the lockfile" do
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
PATH
@ -487,10 +492,12 @@ RSpec.describe "bundle install from an existing gemspec" do
specs:
platform_specific (1.0)
platform_specific (1.0-java)
#{x64_mingw_gems}
PLATFORMS
java
ruby
#{x64_mingw_platforms}
DEPENDENCIES
foo!
@ -506,7 +513,7 @@ RSpec.describe "bundle install from an existing gemspec" do
let(:platform_specific_type) { :development }
let(:dependency) { "indirect_platform_specific" }
it "keeps java dependencies in the lockfile" do
it "keeps all platform dependencies in the lockfile" do
expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
PATH
@ -521,10 +528,12 @@ RSpec.describe "bundle install from an existing gemspec" do
platform_specific
platform_specific (1.0)
platform_specific (1.0-java)
#{x64_mingw_gems}
PLATFORMS
java
ruby
#{x64_mingw_platforms}
DEPENDENCIES
foo!
@ -608,7 +617,7 @@ RSpec.describe "bundle install from an existing gemspec" do
PLATFORMS
ruby
x64-mingw32
#{x64_mingw_platforms}
x86-mingw32
DEPENDENCIES
@ -665,7 +674,7 @@ RSpec.describe "bundle install from an existing gemspec" do
railties (6.1.4)
PLATFORMS
#{lockfile_platforms_for(["java"] + local_platforms)}
#{lockfile_platforms_for(["java", specific_local_platform])}
DEPENDENCIES
activeadmin!

View file

@ -92,7 +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")
end
it "complains with version and platform if pinned specs don't exist in the git repo", :jruby do
it "complains with version and platform if pinned specs don't exist in the git repo", :jruby_only do
build_git "only_java" do |s|
s.platform = "java"
end
@ -107,7 +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")
end
it "complains with multiple versions and platforms if pinned specs don't exist in the git repo", :jruby do
it "complains with multiple versions and platforms if pinned specs don't exist in the git repo", :jruby_only do
build_git "only_java", "1.0" do |s|
s.platform = "java"
end
@ -1206,11 +1206,12 @@ RSpec.describe "bundle install with git sources" do
expect(out).to include(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s)
end
it "does not use old extension after ref changes", :ruby_repo do
it "does not use old extension after ref changes" do
git_reader = build_git "foo", :no_default => true do |s|
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-RUBY
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
create_makefile("foo")
RUBY
s.write "ext/foo.c", "void Init_foo() {}"

View file

@ -50,7 +50,7 @@ RSpec.describe "bundle install across platforms" do
expect(the_bundle).to include_gems "platform_specific 1.0 JAVA"
end
it "pulls the pure ruby version on jruby if the java platform is not present in the lockfile and bundler is run in frozen mode", :jruby do
it "pulls the pure ruby version on jruby if the java platform is not present in the lockfile and bundler is run in frozen mode", :jruby_only do
lockfile <<-G
GEM
remote: #{file_uri_for(gem_repo1)}
@ -332,8 +332,6 @@ end
RSpec.describe "bundle install with platform conditionals" do
it "installs gems tagged w/ the current platforms" do
skip "platform issues" if Gem.win_platform?
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@ -402,8 +400,6 @@ RSpec.describe "bundle install with platform conditionals" do
end
it "installs gems tagged w/ the current platforms inline" do
skip "platform issues" if Gem.win_platform?
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "nokogiri", :platforms => :#{local_tag}
@ -422,8 +418,6 @@ RSpec.describe "bundle install with platform conditionals" do
end
it "installs gems tagged w/ the current platform inline" do
skip "platform issues" if Gem.win_platform?
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "nokogiri", :platform => :#{local_tag}

View file

@ -250,10 +250,11 @@ RSpec.describe "bundle install with specific platforms" do
end
end
it "installs sorbet-static, which does not provide a pure ruby variant, just fine on truffleruby", :truffleruby do
it "installs sorbet-static, which does not provide a pure ruby variant, just fine", :truffleruby do
skip "does not apply to Windows" if Gem.win_platform?
build_repo2 do
build_gem("sorbet-static", "0.5.6403") {|s| s.platform = "x86_64-linux" }
build_gem("sorbet-static", "0.5.6403") {|s| s.platform = "universal-darwin-20" }
build_gem("sorbet-static", "0.5.6403") {|s| s.platform = Bundler.local_platform }
end
gemfile <<~G
@ -266,8 +267,7 @@ RSpec.describe "bundle install with specific platforms" do
GEM
remote: #{file_uri_for(gem_repo2)}/
specs:
sorbet-static (0.5.6403-universal-darwin-20)
sorbet-static (0.5.6403-x86_64-linux)
sorbet-static (0.5.6403-#{Bundler.local_platform})
PLATFORMS
ruby
@ -283,54 +283,95 @@ RSpec.describe "bundle install with specific platforms" do
end
it "does not resolve if the current platform does not match any of available platform specific variants for a top level dependency" do
build_repo2 do
build_repo4 do
build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "x86_64-linux" }
build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "universal-darwin-20" }
end
gemfile <<~G
source "#{file_uri_for(gem_repo2)}"
source "#{file_uri_for(gem_repo4)}"
gem "sorbet-static", "0.5.6433"
G
simulate_platform "arm64-darwin-21" do
bundle "install", :raise_on_error => false
end
expect(err).to include <<~ERROR.rstrip
Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally.
error_message = <<~ERROR.strip
Could not find gem 'sorbet-static (= 0.5.6433)' with platform 'arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
The source contains the following gems matching 'sorbet-static (= 0.5.6433)':
* sorbet-static-0.5.6433-universal-darwin-20
* sorbet-static-0.5.6433-x86_64-linux
ERROR
simulate_platform "arm64-darwin-21" do
bundle "lock", :raise_on_error => false
end
expect(err).to include(error_message).once
# Make sure it doesn't print error twice in verbose mode
simulate_platform "arm64-darwin-21" do
bundle "lock --verbose", :raise_on_error => false
end
expect(err).to include(error_message).once
end
it "does not resolve if the current platform does not match any of available platform specific variants for a transitive dependency" do
build_repo2 do
build_repo4 do
build_gem("sorbet", "0.5.6433") {|s| s.add_dependency "sorbet-static", "= 0.5.6433" }
build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "x86_64-linux" }
build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "universal-darwin-20" }
end
gemfile <<~G
source "#{file_uri_for(gem_repo2)}"
source "#{file_uri_for(gem_repo4)}"
gem "sorbet", "0.5.6433"
G
simulate_platform "arm64-darwin-21" do
bundle "install", :raise_on_error => false
end
expect(err).to include <<~ERROR.rstrip
Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21', which is required by gem 'sorbet (= 0.5.6433)', in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally.
error_message = <<~ERROR.strip
Could not find gem 'sorbet-static (= 0.5.6433)' with platform 'arm64-darwin-21', which is required by gem 'sorbet (= 0.5.6433)', in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
The source contains the following gems matching 'sorbet-static (= 0.5.6433)':
* sorbet-static-0.5.6433-universal-darwin-20
* sorbet-static-0.5.6433-x86_64-linux
ERROR
simulate_platform "arm64-darwin-21" do
bundle "lock", :raise_on_error => false
end
expect(err).to include(error_message).once
# Make sure it doesn't print error twice in verbose mode
simulate_platform "arm64-darwin-21" do
bundle "lock --verbose", :raise_on_error => false
end
expect(err).to include(error_message).once
end
it "does not generate a lockfile if RUBY platform is forced and some gem has no RUBY variant available" do
build_repo4 do
build_gem("sorbet-static", "0.5.9889") {|s| s.platform = Gem::Platform.local }
end
gemfile <<~G
source "#{file_uri_for(gem_repo4)}"
gem "sorbet-static", "0.5.9889"
G
bundle "lock", :raise_on_error => false, :env => { "BUNDLE_FORCE_RUBY_PLATFORM" => "true" }
expect(err).to include <<~ERROR.rstrip
Could not find gem 'sorbet-static (= 0.5.9889)' with platform 'ruby' in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
The source contains the following gems matching 'sorbet-static (= 0.5.9889)':
* sorbet-static-0.5.9889-#{Gem::Platform.local}
ERROR
end
private

View file

@ -66,7 +66,7 @@ RSpec.describe "bundle install" do
end
end
context "with engine specified in symbol", :jruby do
context "with engine specified in symbol", :jruby_only do
it "does not raise any error parsing Gemfile" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"

View file

@ -1,12 +1,13 @@
# frozen_string_literal: true
RSpec.describe "installing a gem with native extensions", :ruby_repo do
RSpec.describe "installing a gem with native extensions" do
it "installs" do
build_repo2 do
build_gem "c_extension" do |s|
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle"
dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello"
@ -51,6 +52,7 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle"
dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello"
@ -95,6 +97,7 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle_#{n}"
dir_config(name)
raise "OMG" unless with_config("c_extension_#{n}") == "#{n}"
@ -147,6 +150,7 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E
require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle"
dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola"

View file

@ -187,11 +187,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1", "DEBUG" => "1" }
activated_groups = if local_platforms.any?
"net_b (1.0) (ruby), net_b (1.0) (#{local_platforms.join(", ")})"
else
"net_b (1.0) (ruby)"
end
activated_groups = "net_b (1.0) (ruby), net_b (1.0) (#{specific_local_platform})"
expect(out).to include(" net_b").
and include("BUNDLER: Starting resolution").

View file

@ -32,6 +32,21 @@ RSpec.shared_examples "bundle install --standalone" do
expect(out).to eq(expected_gems.values.join("\n"))
end
it "makes the gems available without bundler nor rubygems" do
testrb = String.new <<-RUBY
$:.unshift File.expand_path("bundle")
require "bundler/setup"
RUBY
expected_gems.each do |k, _|
testrb << "\nrequire \"#{k}\""
testrb << "\nputs #{k.upcase}"
end
sys_exec %(#{Gem.ruby} --disable-gems -w -e #{testrb.shellescape})
expect(out).to eq(expected_gems.values.join("\n"))
end
it "makes the gems available without bundler via Kernel.require" do
testrb = String.new <<-RUBY
$:.unshift File.expand_path("bundle")
@ -154,8 +169,8 @@ RSpec.shared_examples "bundle install --standalone" do
load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") }
expect(load_path_lines).to eq [
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/bar-1.0.0/lib")',
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/foo-1.0.0/lib")',
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/bar-1.0.0/lib")',
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/foo-1.0.0/lib")',
]
end
end
@ -190,7 +205,7 @@ RSpec.shared_examples "bundle install --standalone" do
end
end
describe "with gems with native extension", :ruby_repo do
describe "with gems with native extension" do
before do
bundle "config set --local path #{bundled_app("bundle")}"
install_gemfile <<-G, :standalone => true, :dir => cwd
@ -201,9 +216,13 @@ RSpec.shared_examples "bundle install --standalone" do
it "generates a bundle/bundler/setup.rb with the proper paths" do
expected_path = bundled_app("bundle/bundler/setup.rb")
extension_line = File.read(expected_path).each_line.find {|line| line.include? "/extensions/" }.strip
expect(extension_line).to start_with '$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/extensions/'
expect(extension_line).to end_with '/very_simple_binary-1.0")'
script_content = File.read(expected_path)
expect(script_content).to include("def self.ruby_api_version")
expect(script_content).to include("def self.extension_api_version")
extension_line = script_content.each_line.find {|line| line.include? "/extensions/" }.strip
platform = Gem::Platform.local
expect(extension_line).to start_with '$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/'
expect(extension_line).to end_with platform.to_s + '/#{Gem.extension_api_version}/very_simple_binary-1.0")'
end
end

View file

@ -205,7 +205,7 @@ RSpec.describe "global gem caching" do
end
describe "extension caching" do
it "works", :ruby_repo do
it "works" do
skip "gets incorrect ref in path" if Gem.win_platform?
build_git "very_simple_git_binary", &:add_c_extension

View file

@ -176,7 +176,7 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
it "re-installs gems whose extensions have been deleted", :ruby_repo do
it "re-installs gems whose extensions have been deleted" do
build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
end

View file

@ -982,7 +982,7 @@ RSpec.describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
#{lockfile_platforms_for(["java"] + local_platforms)}
#{lockfile_platforms_for(["java", specific_local_platform])}
DEPENDENCIES
rack

View file

@ -44,6 +44,10 @@ RSpec.describe "Bundler::GemHelpers#generic" do
expect(generic(pl("x64-mingw32"))).to eq(pl("x64-mingw32"))
expect(generic(pl("x86_64-mingw32"))).to eq(pl("x64-mingw32"))
end
it "converts 64-bit mingw UCRT platform variants into x64-mingw-ucrt" do
expect(generic(pl("x64-mingw-ucrt"))).to eq(pl("x64-mingw-ucrt"))
end
end
RSpec.describe "Gem::SourceIndex#refresh!" do

View file

@ -2,10 +2,6 @@
RSpec.describe "bundle platform" do
context "without flags" do
let(:bundle_platform_platforms_string) do
local_platforms.reverse.map {|pl| "* #{pl}" }.join("\n")
end
it "returns all the output" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@ -20,7 +16,7 @@ RSpec.describe "bundle platform" do
Your platform is: #{Gem::Platform.local}
Your app has gems that work on these platforms:
#{bundle_platform_platforms_string}
* #{specific_local_platform}
Your Gemfile specifies a Ruby version requirement:
* ruby #{RUBY_VERSION}
@ -43,7 +39,7 @@ G
Your platform is: #{Gem::Platform.local}
Your app has gems that work on these platforms:
#{bundle_platform_platforms_string}
* #{specific_local_platform}
Your Gemfile specifies a Ruby version requirement:
* ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
@ -64,7 +60,7 @@ G
Your platform is: #{Gem::Platform.local}
Your app has gems that work on these platforms:
#{bundle_platform_platforms_string}
* #{specific_local_platform}
Your Gemfile does not specify a Ruby version requirement.
G
@ -84,7 +80,7 @@ G
Your platform is: #{Gem::Platform.local}
Your app has gems that work on these platforms:
#{bundle_platform_platforms_string}
* #{specific_local_platform}
Your Gemfile specifies a Ruby version requirement:
* ruby #{not_local_ruby_version}
@ -305,7 +301,7 @@ G
expect(bundled_app_lock).to exist
end
it "installs fine with any engine", :jruby do
it "installs fine with any engine", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -351,7 +347,7 @@ G
should_be_engine_incorrect
end
it "doesn't install when engine version doesn't match", :jruby do
it "doesn't install when engine version doesn't match", :jruby_only do
install_gemfile <<-G, :raise_on_error => false
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -394,7 +390,7 @@ G
expect(out).to match(/\AResolving dependencies\.\.\.\.*\nThe Gemfile's dependencies are satisfied\z/)
end
it "checks fine with any engine", :jruby do
it "checks fine with any engine", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -445,7 +441,7 @@ G
should_be_engine_incorrect
end
it "fails when engine version doesn't match", :jruby do
it "fails when engine version doesn't match", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -511,7 +507,7 @@ G
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
it "updates fine with any engine", :jruby do
it "updates fine with any engine", :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
@ -547,7 +543,7 @@ G
should_be_ruby_version_incorrect
end
it "fails when ruby engine doesn't match", :jruby do
it "fails when ruby engine doesn't match", :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
@ -563,7 +559,7 @@ G
should_be_engine_incorrect
end
it "fails when ruby engine version doesn't match", :jruby do
it "fails when ruby engine version doesn't match", :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
@ -615,7 +611,7 @@ G
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
it "prints path if ruby version is correct for any engine", :jruby do
it "prints path if ruby version is correct for any engine", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rails"
@ -651,7 +647,7 @@ G
should_be_engine_incorrect
end
it "fails if engine version doesn't match", :bundler => "< 3", :jruby => true do
it "fails if engine version doesn't match", :bundler => "< 3", :jruby_only => true do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rails"
@ -699,7 +695,7 @@ G
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
end
it "copies the .gem file to vendor/cache when ruby version matches for any engine", :jruby do
it "copies the .gem file to vendor/cache when ruby version matches for any engine", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
@ -735,7 +731,7 @@ G
should_be_engine_incorrect
end
it "fails if the engine version doesn't match", :jruby do
it "fails if the engine version doesn't match", :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
@ -780,7 +776,7 @@ G
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
end
it "copies the .gem file to vendor/cache when ruby version matches any engine", :jruby do
it "copies the .gem file to vendor/cache when ruby version matches any engine", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
@ -816,7 +812,7 @@ G
should_be_engine_incorrect
end
it "fails if the engine version doesn't match", :jruby do
it "fails if the engine version doesn't match", :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
@ -859,7 +855,7 @@ G
expect(out).to include("0.9.1")
end
it "activates the correct gem when ruby version matches any engine", :jruby do
it "activates the correct gem when ruby version matches any engine", :jruby_only do
system_gems "rack-1.0.0", "rack-0.9.1", :path => default_bundle_path
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@ -896,7 +892,7 @@ G
should_be_engine_incorrect
end
# it "fails when the engine version doesn't match", :jruby do
# it "fails when the engine version doesn't match", :jruby_only do
# gemfile <<-G
# gem "rack", "0.9.1"
#
@ -947,7 +943,7 @@ G
expect(out).to include("0.9.1")
end
it "starts IRB with the default group loaded when ruby version matches", :readline, :jruby do
it "starts IRB with the default group loaded when ruby version matches", :readline, :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -992,7 +988,7 @@ G
should_be_engine_incorrect
end
it "fails when engine version doesn't match", :jruby do
it "fails when engine version doesn't match", :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -1047,7 +1043,7 @@ G
expect(bundled_app_lock).to exist
end
it "makes a Gemfile.lock if setup succeeds for any engine", :jruby do
it "makes a Gemfile.lock if setup succeeds for any engine", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "yard"
@ -1096,7 +1092,7 @@ G
should_be_engine_incorrect
end
it "fails when engine version doesn't match", :jruby do
it "fails when engine version doesn't match", :jruby_only do
install_gemfile <<-G, :raise_on_error => false
source "#{file_uri_for(gem_repo1)}"
gem "yard"
@ -1169,7 +1165,7 @@ G
expect(out).to match(Regexp.new(expected_output))
end
it "returns list of outdated gems when the ruby version matches for any engine", :jruby do
it "returns list of outdated gems when the ruby version matches for any engine", :jruby_only do
bundle :install
update_repo2 do
build_gem "activesupport", "3.0"
@ -1231,7 +1227,7 @@ G
should_be_engine_incorrect
end
it "fails when the engine version doesn't match", :jruby do
it "fails when the engine version doesn't match", :jruby_only do
update_repo2 do
build_gem "activesupport", "3.0"
update_git "foo", :path => lib_path("foo")
@ -1249,7 +1245,7 @@ G
should_be_engine_version_incorrect
end
it "fails when the patchlevel doesn't match", :jruby do
it "fails when the patchlevel doesn't match", :jruby_only do
update_repo2 do
build_gem "activesupport", "3.0"
update_git "foo", :path => lib_path("foo")
@ -1267,7 +1263,7 @@ G
should_be_patchlevel_incorrect
end
it "fails when the patchlevel is a fixnum", :jruby do
it "fails when the patchlevel is a fixnum", :jruby_only do
update_repo2 do
build_gem "activesupport", "3.0"
update_git "foo", :path => lib_path("foo")

View file

@ -291,7 +291,7 @@ RSpec.describe "Resolving platform craziness" do
describe "with mingw32" do
before :each do
@index = build_index do
platforms "mingw32 mswin32 x64-mingw32" do |platform|
platforms "mingw32 mswin32 x64-mingw32 x64-mingw-ucrt" do |platform|
gem "thin", "1.2.7", platform
end
gem "win32-api", "1.5.1", "universal-mingw32"
@ -312,7 +312,7 @@ RSpec.describe "Resolving platform craziness" do
should_resolve_as %w[thin-1.2.7-mingw32]
end
it "finds x64-mingw gems" do
it "finds x64-mingw32 gems" do
platforms "x64-mingw32"
dep "thin"
should_resolve_as %w[thin-1.2.7-x64-mingw32]
@ -329,6 +329,14 @@ RSpec.describe "Resolving platform craziness" do
dep "win32-api"
should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
end
if Gem.rubygems_version >= Gem::Version.new("3.2.28")
it "finds x64-mingw-ucrt gems" do
platforms "x64-mingw-ucrt"
dep "thin"
should_resolve_as %w[thin-1.2.7-x64-mingw-ucrt]
end
end
end
describe "with conflicting cases" do

View file

@ -86,7 +86,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
racc (1.5.2)
PLATFORMS
#{lockfile_platforms_for(["ruby"] + local_platforms)}
#{lockfile_platforms_for(["ruby", specific_local_platform])}
DEPENDENCIES
nokogiri (~> 1.11)
@ -145,7 +145,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
expect(the_bundle).not_to include_gems "nokogiri 1.11.1 #{Bundler.local_platform}"
end
it "will use the java platform if both generic java and generic ruby platforms are locked", :jruby do
it "will use the java platform if both generic java and generic ruby platforms are locked", :jruby_only do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "nokogiri"
@ -204,7 +204,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100"
end
it "allows specifying only-ruby-platform on jruby", :jruby do
it "allows specifying only-ruby-platform on jruby", :jruby_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "nokogiri"
@ -246,7 +246,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
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_only do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "platform_specific"

View file

@ -449,8 +449,6 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
end
it "requires gems pinned to multiple platforms, including the current one" do
skip "platform issues" if Gem.win_platform?
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"

View file

@ -827,7 +827,7 @@ end
expect(out).to eq("yay")
end
it "should clean $LOAD_PATH properly", :ruby_repo do
it "should clean $LOAD_PATH properly" do
gem_name = "very_simple_binary"
full_gem_name = gem_name + "-1.0"
ext_dir = File.join(tmp("extensions", full_gem_name))

View file

@ -74,6 +74,8 @@ RSpec.configure do |config|
ENV["BUNDLER_SPEC_RUN"] = "true"
ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"] = "true"
ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil
ENV["BUNDLE_APP_CONFIG"] = nil
ENV["BUNDLE_SILENCE_ROOT_WARNING"] = nil
ENV["RUBYGEMS_GEMDEPS"] = nil
ENV["XDG_CONFIG_HOME"] = nil
ENV["GEMRC"] = nil

View file

@ -121,6 +121,10 @@ module Spec
s.platform = "x64-mingw32"
end
build_gem "platform_specific" do |s|
s.platform = "x64-mingw-ucrt"
end
build_gem "platform_specific" do |s|
s.platform = "x86-darwin-100"
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 x86-darwin-100'"
@ -444,8 +448,7 @@ module Spec
write "ext/extconf.rb", <<-RUBY
require "mkmf"
# exit 1 unless with_config("simple")
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
extension_name = "#{name}_c"
if extra_lib_dir = with_config("ext-lib")

View file

@ -33,8 +33,8 @@ RSpec.configure do |config|
config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil?
config.filter_run_excluding :permissions => Gem.win_platform?
config.filter_run_excluding :readline => Gem.win_platform?
config.filter_run_excluding :jruby => RUBY_ENGINE != "jruby"
config.filter_run_excluding :truffleruby => RUBY_ENGINE != "truffleruby"
config.filter_run_excluding :jruby_only => RUBY_ENGINE != "jruby"
config.filter_run_excluding :truffleruby_only => RUBY_ENGINE != "truffleruby"
config.filter_run_excluding :man => Gem.win_platform?
config.filter_run_when_matching :focus unless ENV["CI"]

View file

@ -178,7 +178,7 @@ module Spec
begin
require '#{name}'
name_constant = '#{Spec::Builders.constantize(name)}'
name_constant = #{Spec::Builders.constantize(name)}
if #{version.nil?} || name_constant == '#{version}'
exit 64
else

View file

@ -55,13 +55,15 @@ module Spec
def local_tag
if RUBY_PLATFORM == "java"
:jruby
elsif ["x64-mingw32", "x64-mingw-ucrt"].include?(RUBY_PLATFORM)
:x64_mingw
else
:ruby
end
end
def not_local_tag
[:ruby, :jruby].find {|tag| tag != local_tag }
[:jruby, :x64_mingw, :ruby].find {|tag| tag != local_tag }
end
def local_ruby_engine
@ -74,7 +76,7 @@ module Spec
def not_local_engine_version
case not_local_tag
when :ruby
when :ruby, :x64_mingw
not_local_ruby_version
when :jruby
"1.6.1"
@ -90,15 +92,11 @@ module Spec
end
def lockfile_platforms
lockfile_platforms_for(local_platforms)
lockfile_platforms_for([specific_local_platform])
end
def lockfile_platforms_for(platforms)
platforms.map(&:to_s).sort.join("\n ")
end
def local_platforms
[specific_local_platform]
end
end
end

View file

@ -119,6 +119,12 @@ class Gem::TestCase < Test::Unit::TestCase
assert File.directory?(path), msg
end
def refute_directory_exists(path, msg = nil)
msg = build_message(msg, "Expected path '#{path}' not to be a directory")
assert_path_not_exist path
refute File.directory?(path), msg
end
# https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L188
def _synchronize
yield

View file

@ -25,6 +25,8 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_match %r{RUBY VERSION: \d+\.\d+\.\d+ \(.*\) \[.*\]}, @ui.output
assert_match %r{INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}},
@ui.output
assert_match %r{USER INSTALLATION DIRECTORY: #{Regexp.escape Gem.user_dir}},
@ui.output
assert_match %r{RUBYGEMS PREFIX: }, @ui.output
assert_match %r{RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}},
@ui.output
@ -63,6 +65,28 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_equal '', @ui.error
end
def test_execute_user_gemdir
@cmd.send :handle_options, %w[user_gemdir]
use_ui @ui do
@cmd.execute
end
assert_equal "#{Gem.user_dir}\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_user_gemhome
@cmd.send :handle_options, %w[user_gemhome]
use_ui @ui do
@cmd.execute
end
assert_equal "#{Gem.user_dir}\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_gempath
@cmd.send :handle_options, %w[gempath]

View file

@ -11,47 +11,23 @@ dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "bindgen"
version = "0.59.2"
version = "0.60.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"clap",
"env_logger",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"which",
]
[[package]]
@ -60,12 +36,6 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cexpr"
version = "0.6.0"
@ -92,21 +62,6 @@ dependencies = [
"libloading",
]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "custom-name-ext"
version = "0.1.0"
@ -114,46 +69,12 @@ dependencies = [
"rb-sys",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "env_logger"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -191,15 +112,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "log"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
version = "2.5.0"
@ -228,41 +140,42 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "proc-macro2"
version = "1.0.39"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.18"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rb-sys"
version = "0.9.4"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5465c5bd695ef70959b91b4ca9cfd515e9af012f6d9f0ae46f09fa4bcc3b722"
checksum = "104c5bcb9fa23bf3823124c003c516b22664fef50c4a481ff2d0e21b76e0f92c"
dependencies = [
"bindgen",
"cc",
"lazy_static",
"linkify",
"pkg-config",
"rb-sys-build",
]
[[package]]
name = "rb-sys-build"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cdf919b75ba95aa480159f3b20070cbec110d6c8a7af86b35844270069a4cb3"
dependencies = [
"regex",
"shell-words",
]
@ -301,58 +214,11 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "unicode-ident"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "which"
version = "4.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
dependencies = [
"either",
"lazy_static",
"libc",
]
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "winapi"
@ -370,15 +236,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"

View file

@ -1,9 +1,10 @@
[package]
name = "custom-name-ext"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
rb-sys = "0.9.4"
rb-sys = { version = "0.9.15", features = ["gem"] }

View file

@ -1,11 +1,8 @@
#[macro_use]
extern crate rb_sys;
use rb_sys::{rb_define_module, rb_define_module_function, rb_utf8_str_new, VALUE};
use std::ffi::CString;
ruby_extension!();
#[no_mangle]
unsafe extern "C" fn say_hello(_klass: VALUE) -> VALUE {
let cstr = CString::new("Hello world!").unwrap();

View file

@ -11,47 +11,23 @@ dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "bindgen"
version = "0.59.2"
version = "0.60.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"clap",
"env_logger",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"which",
]
[[package]]
@ -60,12 +36,6 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cexpr"
version = "0.6.0"
@ -92,61 +62,12 @@ dependencies = [
"libloading",
]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "env_logger"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -184,15 +105,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "log"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
version = "2.5.0"
@ -221,41 +133,42 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "proc-macro2"
version = "1.0.39"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.18"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rb-sys"
version = "0.9.4"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5465c5bd695ef70959b91b4ca9cfd515e9af012f6d9f0ae46f09fa4bcc3b722"
checksum = "104c5bcb9fa23bf3823124c003c516b22664fef50c4a481ff2d0e21b76e0f92c"
dependencies = [
"bindgen",
"cc",
"lazy_static",
"linkify",
"pkg-config",
"rb-sys-build",
]
[[package]]
name = "rb-sys-build"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cdf919b75ba95aa480159f3b20070cbec110d6c8a7af86b35844270069a4cb3"
dependencies = [
"regex",
"shell-words",
]
@ -301,58 +214,11 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "unicode-ident"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "which"
version = "4.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
dependencies = [
"either",
"lazy_static",
"libc",
]
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "winapi"
@ -370,15 +236,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"

View file

@ -1,9 +1,10 @@
[package]
name = "rust_ruby_example"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
rb-sys = "0.9.4"
rb-sys = { version = "0.9.15", features = ["gem"] }

View file

@ -1,4 +1,3 @@
#[macro_use]
extern crate rb_sys;
use rb_sys::{
@ -7,8 +6,6 @@ use rb_sys::{
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_long};
ruby_extension!();
#[inline]
unsafe fn cstr_to_string(str: *const c_char) -> String {
CStr::from_ptr(str).to_string_lossy().into_owned()

View file

@ -103,6 +103,8 @@ class TestGemIndexer < Gem::TestCase
assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
refute_directory_exists @indexer.directory
end
def test_generate_index_modern
@ -342,6 +344,8 @@ class TestGemIndexer < Gem::TestCase
assert_includes pre_specs_index, @d2_1_a_tuple
refute_includes pre_specs_index, @d2_1_tuple
refute_directory_exists @indexer.directory
end
end

View file

@ -737,9 +737,7 @@ class TestGemPackage < Gem::Package::TarTestCase
file = 'foo//file.rb'.dup
file.taint if RUBY_VERSION < '2.7'
destination = @destination.sub '/', '//'
destination = package.install_location file, destination
destination = package.install_location file, @destination
assert_equal File.join(@destination, 'foo', 'file.rb'), destination
refute destination.tainted? if RUBY_VERSION < '2.7'

View file

@ -16,7 +16,7 @@ class GemTest < Gem::TestCase
output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", { :err => [:child, :out] }).strip
assert !$?.success?
assert_includes output, "undefined local variable or method `intentionally_not_implemented_method'"
assert_includes output, "Loading the rubygems/defaults/operating_system.rb file caused an error. " \
assert_includes output, "Loading the #{operating_system_rb_at(path)} file caused an error. " \
"This file is owned by your OS, not by rubygems upstream. " \
"Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
"the problem and ask for help."
@ -53,16 +53,19 @@ class GemTest < Gem::TestCase
def util_install_operating_system_rb(content)
dir_lib = Dir.mktmpdir("test_operating_system_lib", @tempdir)
dir_lib_arg = File.join dir_lib
dir_lib_arg = File.join dir_lib, "lib"
dir_lib_rubygems_defaults_arg = File.join dir_lib_arg, "lib", "rubygems", "defaults"
FileUtils.mkdir_p dir_lib_rubygems_defaults_arg
operating_system_rb = operating_system_rb_at(dir_lib_arg)
operating_system_rb = File.join dir_lib_rubygems_defaults_arg, "operating_system.rb"
FileUtils.mkdir_p File.dirname(operating_system_rb)
File.open(operating_system_rb, 'w') {|f| f.write content }
File.join dir_lib_arg, "lib"
dir_lib_arg
end
def operating_system_rb_at(dir)
File.join dir, "rubygems", "defaults", "operating_system.rb"
end
def ruby_with_rubygems_and_fake_operating_system_in_load_path(operating_system_path)

View file

@ -33,6 +33,8 @@ PLATFORMS
java
ruby
universal-java-11
universal-java-18
x64-mingw-ucrt
x64-mingw32
x86_64-darwin-20
x86_64-linux
@ -51,4 +53,4 @@ DEPENDENCIES
webrick (~> 1.6)
BUNDLED WITH
2.3.16
2.3.17

View file

@ -47,6 +47,8 @@ PLATFORMS
arm64-darwin-20
arm64-darwin-21
universal-java-11
universal-java-18
x64-mingw-ucrt
x86_64-darwin-19
x86_64-darwin-20
x86_64-linux
@ -60,4 +62,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
2.3.16
2.3.17

View file

@ -53,6 +53,8 @@ PLATFORMS
arm64-darwin-20
arm64-darwin-21
universal-java-11
universal-java-18
x64-mingw-ucrt
x86_64-darwin-19
x86_64-darwin-20
x86_64-linux
@ -66,4 +68,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
2.3.16
2.3.17

View file

@ -26,6 +26,8 @@ PLATFORMS
java
ruby
universal-java-11
universal-java-18
x64-mingw-ucrt
x64-mingw32
x86_64-darwin-20
x86_64-linux
@ -41,4 +43,4 @@ DEPENDENCIES
webrick (= 1.7.0)
BUNDLED WITH
2.3.16
2.3.17