2016-04-25 17:58:50 +01:00
|
|
|
module Homebrew
|
|
|
|
module Diagnostic
|
|
|
|
class Checks
|
2016-09-07 09:11:06 +01:00
|
|
|
def development_tools_checks
|
2016-07-04 18:35:03 +01:00
|
|
|
%w[
|
2016-09-18 19:57:19 +01:00
|
|
|
check_for_unsupported_macos
|
2016-07-04 18:35:03 +01:00
|
|
|
check_for_bad_install_name_tool
|
|
|
|
check_for_installed_developer_tools
|
|
|
|
check_xcode_license_approved
|
|
|
|
check_for_osx_gcc_installer
|
2016-09-15 17:54:47 +10:00
|
|
|
check_xcode_8_without_clt_on_el_capitan
|
2016-11-05 10:38:39 -04:00
|
|
|
check_xcode_up_to_date
|
|
|
|
check_clt_up_to_date
|
|
|
|
check_for_other_package_managers
|
|
|
|
].freeze
|
2016-07-04 18:35:03 +01:00
|
|
|
end
|
|
|
|
|
2016-09-07 09:11:06 +01:00
|
|
|
def fatal_development_tools_checks
|
2016-11-05 10:38:39 -04:00
|
|
|
%w[
|
|
|
|
check_xcode_minimum_version
|
|
|
|
check_clt_minimum_version
|
|
|
|
].freeze
|
|
|
|
end
|
2016-11-05 10:39:00 -04:00
|
|
|
|
|
|
|
def build_error_checks
|
|
|
|
(development_tools_checks + %w[
|
|
|
|
check_for_unsupported_macos
|
|
|
|
]).freeze
|
2016-08-30 03:54:24 +01:00
|
|
|
end
|
|
|
|
|
2016-09-18 19:57:19 +01:00
|
|
|
def check_for_unsupported_macos
|
2016-04-25 17:58:50 +01:00
|
|
|
return if ARGV.homebrew_developer?
|
|
|
|
|
|
|
|
who = "We"
|
|
|
|
if OS::Mac.prerelease?
|
|
|
|
what = "pre-release version"
|
|
|
|
elsif OS::Mac.outdated_release?
|
|
|
|
who << " (and Apple)"
|
|
|
|
what = "old version"
|
|
|
|
else
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-09-18 19:57:19 +01:00
|
|
|
You are using macOS #{MacOS.version}.
|
2016-04-25 17:58:50 +01:00
|
|
|
#{who} do not provide support for this #{what}.
|
|
|
|
You may encounter build failures or other breakages.
|
2016-06-14 21:23:56 +01:00
|
|
|
Please create pull-requests instead of filing issues.
|
2016-04-25 17:58:50 +01:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2016-07-16 21:03:12 +01:00
|
|
|
def check_xcode_up_to_date
|
2016-11-05 10:36:52 -04:00
|
|
|
return unless MacOS::Xcode.outdated?
|
2016-04-25 17:58:50 +01:00
|
|
|
|
2017-02-17 21:53:30 +00:00
|
|
|
# Travis CI images are going to end up outdated so don't complain when
|
2017-02-19 15:39:52 +00:00
|
|
|
# `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
|
2017-02-17 22:03:04 +00:00
|
|
|
# repository. This only needs to support whatever CI provider
|
2017-02-17 21:53:30 +00:00
|
|
|
# Homebrew/brew is currently using.
|
2017-02-17 21:27:40 +00:00
|
|
|
return if ENV["TRAVIS"]
|
2016-11-26 13:09:59 +00:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
message = <<~EOS
|
2016-10-02 17:30:08 +01:00
|
|
|
Your Xcode (#{MacOS::Xcode.version}) is outdated.
|
|
|
|
Please update to Xcode #{MacOS::Xcode.latest_version} (or delete it).
|
2016-09-09 22:10:43 +01:00
|
|
|
#{MacOS::Xcode.update_instructions}
|
|
|
|
EOS
|
|
|
|
|
2016-08-30 03:54:24 +01:00
|
|
|
if OS::Mac.prerelease?
|
2016-09-09 22:10:43 +01:00
|
|
|
current_path = Utils.popen_read("/usr/bin/xcode-select", "-p")
|
2017-10-15 02:28:32 +02:00
|
|
|
message += <<~EOS
|
2016-08-30 03:54:24 +01:00
|
|
|
If #{MacOS::Xcode.latest_version} is installed, you may need to:
|
2016-09-09 22:10:43 +01:00
|
|
|
sudo xcode-select --switch /Applications/Xcode.app
|
|
|
|
Current developer directory is:
|
|
|
|
#{current_path}
|
2016-08-30 03:54:24 +01:00
|
|
|
EOS
|
|
|
|
end
|
2016-09-09 22:10:43 +01:00
|
|
|
message
|
2016-07-16 21:03:12 +01:00
|
|
|
end
|
2016-04-25 17:58:50 +01:00
|
|
|
|
2016-07-16 21:03:12 +01:00
|
|
|
def check_clt_up_to_date
|
2016-11-05 10:36:52 -04:00
|
|
|
return unless MacOS::CLT.outdated?
|
2016-04-25 17:58:50 +01:00
|
|
|
|
2017-04-02 17:24:33 +01:00
|
|
|
# Travis CI images are going to end up outdated so don't complain when
|
|
|
|
# `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
|
|
|
|
# repository. This only needs to support whatever CI provider
|
|
|
|
# Homebrew/brew is currently using.
|
|
|
|
return if ENV["TRAVIS"]
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-07-16 21:03:12 +01:00
|
|
|
A newer Command Line Tools release is available.
|
|
|
|
#{MacOS::CLT.update_instructions}
|
|
|
|
EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
end
|
|
|
|
|
2016-09-15 17:54:47 +10:00
|
|
|
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
|
2016-11-05 10:36:52 -04:00
|
|
|
return unless MacOS.version == :el_capitan
|
|
|
|
return unless MacOS::Xcode.version >= "8"
|
2016-09-15 17:54:47 +10:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-09-15 17:54:47 +10:00
|
|
|
You have Xcode 8 installed without the CLT;
|
2016-09-18 19:57:19 +01:00
|
|
|
this causes certain builds to fail on OS X El Capitan (10.11).
|
2016-09-15 17:54:47 +10:00
|
|
|
Please install the CLT via:
|
|
|
|
sudo xcode-select --install
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2016-11-05 10:36:13 -04:00
|
|
|
def check_xcode_minimum_version
|
2016-12-18 15:31:15 -08:00
|
|
|
return unless MacOS::Xcode.below_minimum_version?
|
2016-11-05 10:36:13 -04:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-11-05 10:36:13 -04:00
|
|
|
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
|
2016-12-18 15:31:15 -08:00
|
|
|
return unless MacOS::CLT.below_minimum_version?
|
2016-11-05 10:36:13 -04:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-11-05 10:36:13 -04:00
|
|
|
Your Command Line Tools are too outdated.
|
|
|
|
#{MacOS::CLT.update_instructions}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2016-04-25 17:58:50 +01:00
|
|
|
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"
|
|
|
|
|
|
|
|
fix_advice = if MacOS.version >= :mavericks
|
|
|
|
"Please run `xcode-select --install` to install the CLT."
|
|
|
|
elsif MacOS.version >= :lion
|
|
|
|
"Please install the CLT or Xcode #{MacOS::Xcode.latest_version}."
|
|
|
|
else
|
|
|
|
"Please install Xcode #{MacOS::Xcode.latest_version}."
|
|
|
|
end
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
You seem to have osx-gcc-installer installed.
|
|
|
|
Homebrew doesn't support osx-gcc-installer. It causes many builds to fail and
|
|
|
|
is an unlicensed distribution of really old Xcode files.
|
|
|
|
#{fix_advice}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_for_stray_developer_directory
|
|
|
|
# if the uninstaller script isn't there, it's a good guess neither are
|
|
|
|
# any troublesome leftover Xcode files
|
|
|
|
uninstaller = Pathname.new("/Developer/Library/uninstall-developer-folder")
|
|
|
|
return unless ((MacOS::Xcode.version || "0") >= "4.3") && uninstaller.exist?
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
You have leftover files from an older version of Xcode.
|
|
|
|
You should delete them using:
|
|
|
|
#{uninstaller}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_for_bad_install_name_tool
|
|
|
|
return if MacOS.version < "10.9"
|
|
|
|
|
|
|
|
libs = Pathname.new("/usr/bin/install_name_tool").dynamically_linked_libraries
|
|
|
|
|
|
|
|
# otool may not work, for example if the Xcode license hasn't been accepted yet
|
|
|
|
return if libs.empty?
|
|
|
|
return if libs.include? "/usr/lib/libxcselect.dylib"
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
You have an outdated version of /usr/bin/install_name_tool installed.
|
|
|
|
This will cause binary package installations to fail.
|
|
|
|
This can happen if you install osx-gcc-installer or RailsInstaller.
|
2016-09-18 19:57:19 +01:00
|
|
|
To restore it, you must reinstall macOS or restore the binary from
|
2016-04-25 17:58:50 +01:00
|
|
|
the OS packages.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_for_other_package_managers
|
|
|
|
ponk = MacOS.macports_or_fink
|
|
|
|
return if ponk.empty?
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
You have MacPorts or Fink installed:
|
|
|
|
#{ponk.join(", ")}
|
|
|
|
|
|
|
|
This can cause trouble. You don't have to uninstall them, but you may want to
|
|
|
|
temporarily move them out of the way, e.g.
|
|
|
|
|
|
|
|
sudo mv /opt/local ~/macports
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_ruby_version
|
2017-09-21 14:27:17 +01:00
|
|
|
ruby_version = "2.3.3"
|
|
|
|
return if RUBY_VERSION == ruby_version
|
2017-09-15 08:06:58 +01:00
|
|
|
return if ARGV.homebrew_developer? && OS::Mac.prerelease?
|
2016-04-25 17:58:50 +01:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew
|
|
|
|
is developed and tested on Ruby #{ruby_version}, and may not work correctly
|
|
|
|
on other Rubies. Patches are accepted as long as they don't cause breakage
|
|
|
|
on supported Rubies.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_xcode_prefix
|
|
|
|
prefix = MacOS::Xcode.prefix
|
|
|
|
return if prefix.nil?
|
|
|
|
return unless prefix.to_s.include?(" ")
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
Xcode is installed to a directory with a space in the name.
|
|
|
|
This will cause some formulae to fail to build.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_xcode_prefix_exists
|
|
|
|
prefix = MacOS::Xcode.prefix
|
|
|
|
return if prefix.nil? || prefix.exist?
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
The directory Xcode is reportedly installed to doesn't exist:
|
|
|
|
#{prefix}
|
|
|
|
You may need to `xcode-select` the proper path if you have moved Xcode.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_xcode_select_path
|
|
|
|
return if MacOS::CLT.installed?
|
2016-11-12 11:31:27 +00:00
|
|
|
return unless MacOS::Xcode.installed?
|
2016-04-25 17:58:50 +01:00
|
|
|
return if File.file?("#{MacOS.active_developer_dir}/usr/bin/xcodebuild")
|
|
|
|
|
|
|
|
path = MacOS::Xcode.bundle_path
|
|
|
|
path = "/Developer" if path.nil? || !path.directory?
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
Your Xcode is configured with an invalid path.
|
|
|
|
You should change it to the correct path:
|
|
|
|
sudo xcode-select -switch #{path}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_for_bad_curl
|
|
|
|
return unless MacOS.version <= "10.8"
|
|
|
|
return if Formula["curl"].installed?
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
The system curl on 10.8 and below is often incapable of supporting
|
|
|
|
modern secure connections & will fail on fetching formulae.
|
|
|
|
|
|
|
|
We recommend you:
|
|
|
|
brew install curl
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_for_unsupported_curl_vars
|
|
|
|
# Support for SSL_CERT_DIR seemed to be removed in the 10.10.5 update.
|
|
|
|
return unless MacOS.version >= :yosemite
|
|
|
|
return if ENV["SSL_CERT_DIR"].nil?
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
SSL_CERT_DIR support was removed from Apple's curl.
|
|
|
|
If fetching formulae fails you should:
|
|
|
|
unset SSL_CERT_DIR
|
2017-04-22 16:28:07 +01:00
|
|
|
and remove it from #{Utils::Shell.profile} if present.
|
2016-04-25 17:58:50 +01:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_xcode_license_approved
|
|
|
|
# If the user installs Xcode-only, they have to approve the
|
|
|
|
# license or no "xc*" tool will work.
|
2017-06-10 20:12:55 +03:00
|
|
|
return unless `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$CHILD_STATUS.success?
|
2016-04-25 17:58:50 +01:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-04-25 17:58:50 +01:00
|
|
|
You have not agreed to the Xcode license.
|
|
|
|
Builds will fail! Agree to the license by opening Xcode.app or running:
|
|
|
|
sudo xcodebuild -license
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2017-11-05 12:12:39 +00:00
|
|
|
def check_xquartz_up_to_date
|
|
|
|
return unless MacOS::XQuartz.outdated?
|
2016-04-25 17:58:50 +01:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-10-02 17:30:08 +01:00
|
|
|
Your XQuartz (#{installed_version}) is outdated.
|
2016-10-26 21:45:15 -04:00
|
|
|
Please install XQuartz #{latest_version} (or delete the current version).
|
|
|
|
XQuartz can be updated using Homebrew-Cask by running
|
|
|
|
brew cask reinstall xquartz
|
2016-04-25 17:58:50 +01:00
|
|
|
EOS
|
|
|
|
end
|
2016-07-05 11:02:16 +10:00
|
|
|
|
|
|
|
def check_for_beta_xquartz
|
2017-11-05 12:12:39 +00:00
|
|
|
return unless MacOS::XQuartz.version.to_s.include?("beta")
|
2016-07-05 11:02:16 +10:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-07-06 16:22:15 +02:00
|
|
|
The following beta release of XQuartz is installed: #{MacOS::XQuartz.version}
|
2016-07-05 11:02:16 +10:00
|
|
|
|
2016-07-06 16:22:15 +02:00
|
|
|
XQuartz beta releases include address sanitization, and do not work with
|
|
|
|
all software; notably, wine will not work with beta releases of XQuartz.
|
|
|
|
We recommend only installing stable releases of XQuartz.
|
2016-07-05 11:02:16 +10:00
|
|
|
EOS
|
|
|
|
end
|
2017-05-27 13:34:59 +01:00
|
|
|
|
|
|
|
def check_filesystem_case_sensitive
|
|
|
|
dirs_to_check = [
|
|
|
|
HOMEBREW_PREFIX,
|
|
|
|
HOMEBREW_REPOSITORY,
|
|
|
|
HOMEBREW_CELLAR,
|
|
|
|
HOMEBREW_TEMP,
|
|
|
|
]
|
|
|
|
case_sensitive_dirs = dirs_to_check.select do |dir|
|
|
|
|
# We select the dir as being case-sensitive if either the UPCASED or the
|
|
|
|
# downcased variant is missing.
|
|
|
|
# Of course, on a case-insensitive fs, both exist because the os reports so.
|
|
|
|
# In the rare situation when the user has indeed a downcased and an upcased
|
|
|
|
# dir (e.g. /TMP and /tmp) this check falsely thinks it is case-insensitive
|
|
|
|
# but we don't care because: 1. there is more than one dir checked, 2. the
|
|
|
|
# check is not vital and 3. we would have to touch files otherwise.
|
|
|
|
upcased = Pathname.new(dir.to_s.upcase)
|
|
|
|
downcased = Pathname.new(dir.to_s.downcase)
|
|
|
|
dir.exist? && !(upcased.exist? && downcased.exist?)
|
|
|
|
end
|
|
|
|
return if case_sensitive_dirs.empty?
|
|
|
|
|
|
|
|
volumes = Volumes.new
|
|
|
|
case_sensitive_vols = case_sensitive_dirs.map do |case_sensitive_dir|
|
|
|
|
volumes.get_mounts(case_sensitive_dir)
|
|
|
|
end
|
|
|
|
case_sensitive_vols.uniq!
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2017-05-27 13:34:59 +01:00
|
|
|
The filesystem on #{case_sensitive_vols.join(",")} appears to be case-sensitive.
|
|
|
|
The default macOS filesystem is case-insensitive. Please report any apparent problems.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_homebrew_prefix
|
|
|
|
return if HOMEBREW_PREFIX.to_s == "/usr/local"
|
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2017-05-27 13:34:59 +01:00
|
|
|
Your Homebrew's prefix is not /usr/local.
|
|
|
|
You can install Homebrew anywhere you want but some bottles (binary packages)
|
|
|
|
can only be used with a /usr/local prefix and some formulae (packages)
|
|
|
|
may not build correctly with a non-/usr/local prefix.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_which_pkg_config
|
|
|
|
binary = which "pkg-config"
|
|
|
|
return if binary.nil?
|
|
|
|
|
|
|
|
mono_config = Pathname.new("/usr/bin/pkg-config")
|
|
|
|
if mono_config.exist? && mono_config.realpath.to_s.include?("Mono.framework")
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2017-05-27 13:34:59 +01:00
|
|
|
You have a non-Homebrew 'pkg-config' in your PATH:
|
|
|
|
/usr/bin/pkg-config => #{mono_config.realpath}
|
|
|
|
|
|
|
|
This was most likely created by the Mono installer. `./configure` may
|
|
|
|
have problems finding brew-installed packages using this other pkg-config.
|
|
|
|
|
|
|
|
Mono no longer installs this file as of 3.0.4. You should
|
|
|
|
`sudo rm /usr/bin/pkg-config` and upgrade to the latest version of Mono.
|
|
|
|
EOS
|
|
|
|
elsif binary.to_s != "#{HOMEBREW_PREFIX}/bin/pkg-config"
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2017-05-27 13:34:59 +01:00
|
|
|
You have a non-Homebrew 'pkg-config' in your PATH:
|
|
|
|
#{binary}
|
|
|
|
|
|
|
|
`./configure` may have problems finding brew-installed packages using
|
|
|
|
this other pkg-config.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2016-04-25 17:58:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|