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.0.0/lib/rubygems/ext/builder.rb, line 88
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.
build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env)
output, status = begin
Open3.popen2e(build_env, *command, chdir: dir) do |_stdin, stdouterr, wait_thread|
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