Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem::Ext::Builder.run
run(command, results, command_name = nil, dir = Dir.pwd, env = {}) { |status, results| ... }
lib/rubygems/ext/builder.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/ext/builder.rb, line 89
def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {})
verbose = Gem.configuration.really_verbose
begin
rubygems_gemdeps = ENV["RUBYGEMS_GEMDEPS"]
ENV["RUBYGEMS_GEMDEPS"] = nil
if verbose
puts("current directory: #{dir}")
p(command)
end
results << "current directory: #{dir}"
results << shelljoin(command)
require "open3"
# Set $SOURCE_DATE_EPOCH for the subprocess.
# Under Ruby::Box defined?($gvar) does not see assignments made inside the
# box, so mkmf have_devel? never memoizes and recurses until SystemStackError
# (https://bugs.ruby-lang.org/issues/22283).
# Drop $RUBY_BOX last so no caller can restore it.
build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env).merge("RUBY_BOX" => nil)
# A single-element command would be parsed as a shell command line,
# splitting an unquoted command path containing spaces. Use the
# [cmdname, argv0] form to keep exec semantics.
command = [[command.first, command.first]] if command.size == 1
output, status = begin
Open3.popen2e(build_env, *command, chdir: dir) do |stdin, stdouterr, wait_thread|
stdin.close
output = String.new
while line = stdouterr.gets
output << line
if verbose
print line
end
end
[output, wait_thread.value]
end
rescue StandardError => error
raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
end
unless verbose
results << output
end
ensure
ENV["RUBYGEMS_GEMDEPS"] = rubygems_gemdeps
end
unless status.success?
results << "Building has failed. See above output for more information on the failure." if verbose
end
yield(status, results) if block_given?
unless status.success?
exit_reason =
if status.exited?
", exit code #{status.exitstatus}"
elsif status.signaled?
", uncaught signal #{status.termsig}"
end
raise Gem::InstallError, "#{command_name || class_name} failed#{exit_reason}"
end
end
No documentation available