Add a snapshot of ENV to BuildError and show some flags with the stack trace.

This commit is contained in:
Adam Vandenberg 2010-03-10 13:29:57 -08:00
parent 07934ce3ab
commit 485d480722
2 changed files with 20 additions and 2 deletions

View File

@ -60,4 +60,10 @@ class ExecutionError <RuntimeError
end end
class BuildError <ExecutionError class BuildError <ExecutionError
attr :env
def initialize cmd, args = [], es = nil
super
@env = ENV.to_hash
end
end end

View File

@ -66,6 +66,12 @@ X11 installed? #{x11_installed?}
EOS EOS
end end
def dump_build_env env
%w[CC CXX LD CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MAKEFLAGS].each do |k|
puts "#{k}: #{env[k]}"
end
end
begin begin
require 'brew.h' require 'brew.h'
@ -374,10 +380,16 @@ rescue Interrupt => e
rescue BuildError => e rescue BuildError => e
e.backtrace[1] =~ %r{Library/Formula/(.+)\.rb:(\d+)} e.backtrace[1] =~ %r{Library/Formula/(.+)\.rb:(\d+)}
formula_name = $1 formula_name = $1
puts "http://github.com/mxcl/homebrew/blob/master/Library/Formula/#{formula_name}.rb#L#{$2}" error_line = $2
puts "Exit status: #{e.exit_status}"
puts
puts "http://github.com/mxcl/homebrew/blob/master/Library/Formula/#{formula_name}.rb#L#{error_line}"
puts
ohai "Environment" ohai "Environment"
dump_config dump_config
puts "Exit status: #{e.exit_status}" puts
ohai "Build Flags"
dump_build_env e.env
onoe e onoe e
puts PLEASE_REPORT_BUG puts PLEASE_REPORT_BUG
# this feature can be slow (depends on network conditions and if github is up) # this feature can be slow (depends on network conditions and if github is up)