Skip to content

Commit

Permalink
link: stop unneeded force linking on Mojave/CLT 10.
Browse files Browse the repository at this point in the history
People are getting in the habit of force-linking things like `zlib` to
fix linking/include issues on Mojave (which doesn't install headers to
`/usr/include` by default). This way lies madness so encourage people to
instead pass the correct compiler flags instead.
  • Loading branch information
MikeMcQuaid committed Jul 9, 2018
1 parent b350fe0 commit 2f181b3
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions Library/Homebrew/cmd/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,27 @@ def link

ARGV.kegs.each do |keg|
keg_only = Formulary.keg_only?(keg.rack)
if HOMEBREW_PREFIX.to_s == "/usr/local" && keg_only &&
keg.name.start_with?("openssl", "libressl")
opoo <<~EOS
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
EOS
next
if HOMEBREW_PREFIX.to_s == "/usr/local" && keg_only
if keg.name.start_with?("openssl", "libressl")
opoo <<~EOS
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
EOS
next
elsif (MacOS.version >= :mojave ||
MacOS::Xcode.version >= "10.0" ||
MacOS::CLT.version >= "10.0") &&
dep_f.keg_only_reason.reason == :provided_by_macos
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
EOS
next
end
elsif keg.linked?
opoo "Already linked: #{keg}"
puts "To relink: brew unlink #{keg.name} && brew link #{keg.name}"
Expand Down

3 comments on commit 2f181b3

@keyurp1987
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting the below error which started happening after brew was updated to latest version with the changes above.

undefined local variable or method `dep_f' for Homebrew:Module

@ilovezfs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyurp1987 thanks for reporting this. It's now fixed. In the future, please open an issue and fill out the issue template to make sure your observations don't escape our notice.

@keyurp1987
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilovezfs Thanks for the quick fix. Yes I will create the issue to get the attention in future.

Please sign in to comment.