From 4cae6a724e6d684eb157dd6d7328755694f228b2 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 23 Mar 2017 08:42:27 +0000 Subject: [PATCH] link: tell users of `brew link --force` about opt. If people are force-linking keg-only things they should probably be told that they can add the opt prefix to their PATH instead. --- Library/Homebrew/cmd/link.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb index 98cf98bf77..293f09eefe 100644 --- a/Library/Homebrew/cmd/link.rb +++ b/Library/Homebrew/cmd/link.rb @@ -44,6 +44,7 @@ module Homebrew elsif keg_only && !ARGV.force? opoo "#{keg.name} is keg-only and must be linked with --force" puts "Note that doing so can interfere with building software." + puts_keg_only_path_message(keg) next elsif mode.dry_run && mode.overwrite puts "Would remove:" @@ -53,6 +54,7 @@ module Homebrew elsif mode.dry_run puts "Would link:" keg.link(mode) + puts_keg_only_path_message(keg) if keg_only next end @@ -69,10 +71,25 @@ module Homebrew else puts "#{n} symlinks created" end + + if keg_only && !ARGV.homebrew_developer? + puts_keg_only_path_message(keg) + end end end end + def puts_keg_only_path_message(keg) + bin = keg/"bin" + sbin = keg/"sbin" + return if !bin.directory? && !sbin.directory? + + opt = HOMEBREW_PREFIX/"opt/#{keg.name}" + puts "\nIf you need to have this software first in your PATH instead consider running:" + puts " #{Utils::Shell.prepend_path_in_shell_profile(opt)}/bin" if bin.directory? + puts " #{Utils::Shell.prepend_path_in_shell_profile(opt)}/sbin" if sbin.directory? + end + def keg_only?(rack) Formulary.from_rack(rack).keg_only? rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError