Linuxbrew / brew

:beer::penguin: The Homebrew package manager for Linux
https://linuxbrew.sh
BSD 2-Clause "Simplified" License
2.66k stars 237 forks source link

`brew info llvm` fails when using homebrew/brew #796

Closed jonchang closed 6 years ago

jonchang commented 6 years ago
 $ brew config
HOMEBREW_VERSION: 1.7.1-224-ga985f0a
ORIGIN: https://github.com/homebrew/brew.git
HEAD: a985f0a5d0cd7e73ea6cafe842a08aba82cee4b5
Last commit: 33 hours ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: 97c75f4951594304ad99ae2bcdca6525cec05cfd
Core tap last commit: 6 hours ago
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_REPOSITORY: /home/linuxbrew/.linuxbrew
HOMEBREW_CELLAR: /home/linuxbrew/.linuxbrew/Cellar
HOMEBREW_CACHE: /home/jonchang/.cache/Homebrew
HOMEBREW_AUTO_UPDATE_SECS: 43200
HOMEBREW_DEVELOPER: 1
HOMEBREW_NO_EMOJI: 1
HOMEBREW_VISUAL: /home/linuxbrew/.linuxbrew/bin/vim
CPU: 48-core 64-bit haswell
Homebrew Ruby: 2.3.7 => /home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.3.7/bin/ruby
Clang: N/A
Git: 2.18.0 => /home/linuxbrew/.linuxbrew/bin/git
Curl: 7.29.0 => /usr/bin/curl
Java: N/A
Kernel: Linux 3.10.0-862.3.2.el7.x86_64 x86_64 GNU/Linux
OS: CentOS Linux release 7.5.1804 (Core) 
Host glibc: 2.17
/usr/bin/gcc: 4.8.5
glibc: 2.23
gcc: 5.5.0_4
xorg: 20170115_1

brew info llvm fails with:

Error: uninitialized constant OS::Mac::CLT Please report this bug: https://github.com/Linuxbrew/brew/wiki/troubleshooting /home/linuxbrew/.linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/llvm.rb:259:in build_libcxx?' /home/linuxbrew/.linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/llvm.rb:409:incaveats' /home/linuxbrew/.linuxbrew/Library/Homebrew/caveats.rb:17:in caveats' /home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/forwardable.rb:202:inempty?' /home/linuxbrew/.linuxbrew/Library/Homebrew/cmd/info.rb:181:in info_formula' /home/linuxbrew/.linuxbrew/Library/Homebrew/cmd/info.rb:58:inblock in print_info' /home/linuxbrew/.linuxbrew/Library/Homebrew/cmd/info.rb:52:in each' /home/linuxbrew/.linuxbrew/Library/Homebrew/cmd/info.rb:52:ineach_with_index' /home/linuxbrew/.linuxbrew/Library/Homebrew/cmd/info.rb:52:in print_info' /home/linuxbrew/.linuxbrew/Library/Homebrew/cmd/info.rb:41:ininfo' /home/linuxbrew/.linuxbrew/Library/Homebrew/brew.rb:87:in `

'

sjackman commented 6 years ago

On Linuxbrew/brew, we stub out OS::Mac::CLT.installed? to return true on Linux. https://github.com/Linuxbrew/brew/blob/27df53693f594e1b42c09ecfa6e68ca709d937fe/Library/Homebrew/os/linux.rb#L22-L28 We could try sending that patch upstream to Homebrew/brew. It seems dirty though. Better I think would be to patch the formulae to guard OS::Mac::CLT.installed? with if/unless OS.mac?. There are 29 such formulae that also have Linux bottles.

For example…

diff --git a/Formula/llvm.rb b/Formula/llvm.rb
index c7bdbedb2f..7f354713ff 100644
--- a/Formula/llvm.rb
+++ b/Formula/llvm.rb
@@ -256,7 +256,7 @@ class Llvm < Formula
   end

   def build_libcxx?
-    build.with?("libcxx") || !MacOS::CLT.installed?
+    build.with?("libcxx") || (OS.mac? && !MacOS::CLT.installed?)
   end

   # Clang cannot find system headers if Xcode CLT is not installed
jonchang commented 6 years ago

I have a list of 77 formula that fail brew info for similar reasons. I'll open a pull request over at linuxbrew/core with that fix.

jonchang commented 6 years ago

There's a lot of depends_on :xcode. It might make more sense to make depends_on :xcode to imply depends_on :macos.

sjackman commented 6 years ago

There's a few formulae that have depends_on :xcode that do have depends_on :xcode but also have a bottle for x86_64_linux, such as libmxml.rb. I'm inclined to change depends_on :xcode to depends_on :xcode if OS.mac? where needed. 79 formulae have depends_on :xcode

jonchang commented 6 years ago

I just did a blanket change with sed, see https://github.com/Linuxbrew/homebrew-core/pull/8862

iMichka commented 6 years ago

I think depends on Xcode does not imply Xcode is needed on Linux. It just means that you need Xcode on Mac.

maxim-belkin commented 6 years ago

Good job, everyone! 🎉