From 19d87bf15f61fd5a814ca7abc7f1dc3c59846434 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jul 2018 10:49:55 +0100 Subject: [PATCH] link: when refusing link display keg only caveats These are a bit easier to follow and have been recently improved. Inspired by conversation in #4441. --- Library/Homebrew/cmd/link.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb index dac871ade3..4d0d8e3155 100644 --- a/Library/Homebrew/cmd/link.rb +++ b/Library/Homebrew/cmd/link.rb @@ -13,6 +13,7 @@ #: If `--force` (or `-f`) is passed, Homebrew will allow keg-only formulae to be linked. require "ostruct" +require "caveats" module Homebrew module_function @@ -52,14 +53,16 @@ module Homebrew if keg_only if HOMEBREW_PREFIX.to_s == "/usr/local" - if keg.to_formula.keg_only_reason.reason == :provided_by_macos && + f = keg.to_formula + caveats = Caveats.new(f) + + if f.keg_only_reason.reason == :provided_by_macos && (MacOS.version >= :mojave || MacOS::Xcode.version >= "10.0" || MacOS::CLT.version >= "10.0") opoo <<~EOS Refusing to link macOS-provided software: #{keg.name} - Instead, pass the full include/library paths to your compiler e.g.: - -I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib + #{caveats.keg_only_text(skip_reason: true).strip} EOS next end @@ -69,8 +72,7 @@ module Homebrew Refusing to link: #{keg.name} Linking keg-only #{keg.name} means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's #{keg.name}. - Instead, pass the full include/library paths to your compiler e.g.: - -I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib + #{caveats.keg_only_text(skip_reason: true).strip} EOS next end