From 4015d0465a975aaac26d5a47395ab61e29d1702f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:35:39 -0400 Subject: [PATCH 1/9] xcode: add checks for Xcode/CLT minimum versions. --- Library/Homebrew/os/mac/xcode.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 9f49162d5e..f081d4382b 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -25,6 +25,17 @@ module OS end end + def minimum_version + case MacOS.version + when "10.12" then "8.0" + else "2.0" + end + end + + def minimum_version? + version < minimum_version + end + def prerelease? # TODO: bump to version >= "8.3" after Xcode 8.2 is stable. version >= "8.2" @@ -205,6 +216,17 @@ module OS end end + def minimum_version + case MacOS.version + when "10.12" then "8.0.0" + else "4.0.0" + end + end + + def minimum_version? + version < minimum_version + end + def outdated? if MacOS.version >= :mavericks version = Utils.popen_read("#{MAVERICKS_PKG_PATH}/usr/bin/clang --version") From bccd792bbffaf0c219f402d893be4c5c0d284d97 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:36:13 -0400 Subject: [PATCH 2/9] diagnostic: add checks for minimum Xcode/CLT versions. --- Library/Homebrew/extend/os/mac/diagnostic.rb | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 0ac95bfd98..883565749a 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -104,6 +104,27 @@ module Homebrew EOS end + def check_xcode_minimum_version + return unless MacOS::Xcode.installed? + return unless MacOS::Xcode.minimum_version? + + <<-EOS.undent + Your Xcode (#{MacOS::Xcode.version}) is too outdated. + Please update to Xcode #{MacOS::Xcode.latest_version} (or delete it). + #{MacOS::Xcode.update_instructions} + EOS + end + + def check_clt_minimum_version + return unless MacOS::CLT.installed? + return unless MacOS::CLT.minimum_version? + + <<-EOS.undent + Your Command Line Tools are too outdated. + #{MacOS::CLT.update_instructions} + EOS + end + def check_for_osx_gcc_installer return unless MacOS.version < "10.7" || ((MacOS::Xcode.version || "0") > "4.1") return unless DevelopmentTools.clang_version == "2.1" From 6359c75a2dea3673284bc5f9b00d1ed790469e7b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:36:52 -0400 Subject: [PATCH 3/9] os/mac/diagnostic: split some unless conditions. --- Library/Homebrew/extend/os/mac/diagnostic.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 883565749a..6649865ba1 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -62,7 +62,8 @@ module Homebrew end def check_xcode_up_to_date - return unless MacOS::Xcode.installed? && MacOS::Xcode.outdated? + return unless MacOS::Xcode.installed? + return unless MacOS::Xcode.outdated? message = <<-EOS.undent Your Xcode (#{MacOS::Xcode.version}) is outdated. @@ -83,7 +84,8 @@ module Homebrew end def check_clt_up_to_date - return unless MacOS::CLT.installed? && MacOS::CLT.outdated? + return unless MacOS::CLT.installed? + return unless MacOS::CLT.outdated? <<-EOS.undent A newer Command Line Tools release is available. @@ -94,7 +96,8 @@ module Homebrew def check_xcode_8_without_clt_on_el_capitan return unless MacOS::Xcode.without_clt? # Scope this to Xcode 8 on El Cap for now - return unless MacOS.version == :el_capitan && MacOS::Xcode.version >= "8" + return unless MacOS.version == :el_capitan + return unless MacOS::Xcode.version >= "8" <<-EOS.undent You have Xcode 8 installed without the CLT; From b38f5b3e7d597fe8fa9611f142ac253b94614c88 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:38:39 -0400 Subject: [PATCH 4/9] diagnostic: only make minimum Xcode/CLT version checks fatal. Also: freeze the relevant arrays. --- Library/Homebrew/diagnostic.rb | 5 +++-- Library/Homebrew/extend/os/mac/diagnostic.rb | 19 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 3a2d0d76dd..23c626edd8 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -86,12 +86,13 @@ module Homebrew def development_tools_checks %w[ check_for_installed_developer_tools - ] + ].freeze end def fatal_development_tools_checks %w[ - ] + ].freeze + end end def check_for_installed_developer_tools diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 6649865ba1..a60dd2d052 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -10,19 +10,18 @@ module Homebrew check_xcode_license_approved check_for_osx_gcc_installer check_xcode_8_without_clt_on_el_capitan - ] + check_xcode_up_to_date + check_clt_up_to_date + check_for_other_package_managers + ].freeze end def fatal_development_tools_checks - if MacOS.version >= :sierra && ENV["CI"].nil? - %w[ - check_xcode_up_to_date - check_clt_up_to_date - ] - else - %w[ - ] - end + %w[ + check_xcode_minimum_version + check_clt_minimum_version + ].freeze + end end def check_for_unsupported_macos From 262eaca56e9efbb21a20be2fe83af563c9b9289e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:39:00 -0400 Subject: [PATCH 5/9] diagnostic: add build error checks. --- Library/Homebrew/diagnostic.rb | 4 ++++ Library/Homebrew/extend/os/mac/diagnostic.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 23c626edd8..63ac008f0f 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -93,6 +93,10 @@ module Homebrew %w[ ].freeze end + + def build_error_checks + (development_tools_checks + %w[ + ]).freeze end def check_for_installed_developer_tools diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index a60dd2d052..0f37e8af57 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -22,6 +22,11 @@ module Homebrew check_clt_minimum_version ].freeze end + + def build_error_checks + (development_tools_checks + %w[ + check_for_unsupported_macos + ]).freeze end def check_for_unsupported_macos From 83af084079d8c334ad346ae6baf8e5135e65057a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:40:07 -0400 Subject: [PATCH 6/9] exceptions: use specific build error checks. --- Library/Homebrew/exceptions.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 7aecbe494f..834ef91aca 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -367,8 +367,11 @@ class BuildError < RuntimeError end require "diagnostic" - unsupported_macos = Homebrew::Diagnostic::Checks.new.check_for_unsupported_macos - opoo unsupported_macos if unsupported_macos + checks = Homebrew::Diagnostic::Checks.new + checks.build_error_checks.each do |check| + next if out.nil? + ofail out + end end end From 6c9ca906af240a3112a5775c9fc6f5359a0cb537 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:40:23 -0400 Subject: [PATCH 7/9] install: only check fatal development tools checks. --- Library/Homebrew/cmd/install.rb | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index dcf46e5fab..16639c4aac 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -223,25 +223,12 @@ module Homebrew def check_development_tools checks = Diagnostic::Checks.new - all_development_tools_checks = checks.development_tools_checks + - checks.fatal_development_tools_checks - all_development_tools_checks.each do |check| + checks.fatal_development_tools_checks.each do |check| out = checks.send(check) next if out.nil? - if checks.fatal_development_tools_checks.include?(check) - odie out - else - opoo out - end + ofail out end - end - - def check_macports - return if MacOS.macports_or_fink.empty? - - opoo "It appears you have MacPorts or Fink installed." - puts "Software installed with other package managers causes known problems for" - puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again." + exit 1 if Homebrew.failed? end def check_cellar @@ -283,8 +270,5 @@ module Homebrew # another formula. In that case, don't generate an error, just move on. rescue CannotInstallFormulaError => e ofail e.message - rescue BuildError - check_macports - raise end end From c7de142800e2bc8fe169aa8bf53de88b65d5784e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 10:58:19 -0400 Subject: [PATCH 8/9] os: don't tell people to report unsupported version issues. --- Library/Homebrew/os.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb index b49bbff644..f6fe1eb811 100644 --- a/Library/Homebrew/os.rb +++ b/Library/Homebrew/os.rb @@ -13,7 +13,10 @@ module OS if OS.mac? require "os/mac" - ISSUES_URL = "https://git.io/brew-troubleshooting".freeze + # Don't tell people to report issues on unsupported versions of macOS. + if !OS::Mac.prerelease? && !OS::Mac.outdated_release? + ISSUES_URL = "https://git.io/brew-troubleshooting".freeze + end PATH_OPEN = "/usr/bin/open".freeze # compatibility ::MACOS_FULL_VERSION = OS::Mac.full_version.to_s.freeze From a1e798d964599230800a12172aec0d70299937cd Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 5 Nov 2016 15:39:25 -0400 Subject: [PATCH 9/9] exceptions: reorder output based on importance. --- Library/Homebrew/exceptions.rb | 51 +++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 834ef91aca..3d9b24034f 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -327,22 +327,9 @@ class BuildError < RuntimeError end def dump - if !ARGV.verbose? - puts - puts Formatter.error(Formatter.url(OS::ISSUES_URL), label: "READ THIS") - if formula.tap - case formula.tap.name - when "homebrew/boneyard" - puts "#{formula} was moved to homebrew-boneyard because it has unfixable issues." - puts "Please do not file any issues about this. Sorry!" - else - if issues_url = formula.tap.issues_url - puts "If reporting this issue please do so at (not Homebrew/brew):" - puts " #{Formatter.url(issues_url)}" - end - end - end - else + puts + + if ARGV.verbose? require "system_config" require "build_environment" @@ -360,7 +347,37 @@ class BuildError < RuntimeError puts logs.map { |fn| " #{fn}" }.join("\n") end end + + if formula.tap && formula.tap.name == "homebrew/boneyard" + onoe <<-EOS.undent + #{formula} was moved to homebrew-boneyard because it has unfixable issues. + Please do not file any issues about this. Sorry! + EOS + return + end + + if formula.tap + if formula.tap.official? + puts Formatter.error(Formatter.url(OS::ISSUES_URL), label: "READ THIS") + elsif issues_url = formula.tap.issues_url + puts <<-EOS.undent + If reporting this issue please do so at (not Homebrew/brew or Homebrew/core): + #{Formatter.url(issues_url)} + EOS + else + puts <<-EOS.undent + If reporting this issue please do so to (not Homebrew/brew or Homebrew/core): + #{formula.tap} + EOS + end + else + puts <<-EOS.undent + Do not report this issue to Homebrew/brew or Homebrew/core! + EOS + end + puts + if issues && !issues.empty? puts "These open issues may also help:" puts issues.map { |i| "#{i["title"]} #{i["html_url"]}" }.join("\n") @@ -369,7 +386,9 @@ class BuildError < RuntimeError require "diagnostic" checks = Homebrew::Diagnostic::Checks.new checks.build_error_checks.each do |check| + out = checks.send(check) next if out.nil? + puts ofail out end end