Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
40.8k stars 9.58k forks source link

sub-dependency installation doesn't take installed package config into account #3988

Closed rfc6919 closed 6 years ago

rfc6919 commented 6 years ago

I'm not sure if this is another manifestation of #3615, if so close as dupe.

To help us debug your issue please explain:

Install a package variant and not pull in un-required dependencies.

example: liquid-dsp requires fftw. fftw requires gcc by default, but if built --without-fortran does not require gcc.

install fftw --without-fortran

mbp:~ rfc6919$ brew install fftw --without-fortran
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
planck
==> Downloading http://fftw.org/fftw-3.3.7.tar.gz
Already downloaded: /Users/rfc6919/Library/Caches/Homebrew/fftw-3.3.7.tar.gz
==> ./configure --enable-single --enable-shared --prefix=/opt/brew/Cellar/fftw/3.3.7_1 --enable-threads --disable-fortran --enable-s
==> make install
==> make clean
==> ./configure --enable-shared --prefix=/opt/brew/Cellar/fftw/3.3.7_1 --enable-threads --disable-fortran --enable-sse2 --enable-avx
==> make install
==> make clean
==> ./configure --enable-long-double --enable-shared --prefix=/opt/brew/Cellar/fftw/3.3.7_1 --enable-threads --disable-fortran
==> make install
🍺  /opt/brew/Cellar/fftw/3.3.7_1: 52 files, 17.1MB, built in 6 minutes 16 seconds

fftw is installed, gcc and its dependencies are not

mbp:~ rfc6919$ brew list | egrep 'liquid-dsp|fftw|gcc|gmp|isl|libmpc|mpfr'
fftw
gmp

install liquid-dsp. brew does not try to re-install fftw, but does pull in the un-required sub-dependencies

mbp:~ rfc6919$ brew install liquid-dsp
==> Installing dependencies for liquid-dsp: mpfr, libmpc, isl, gcc
==> Installing liquid-dsp dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-4.0.1.high_sierra.bottle.tar.gz
...

brew would understand that fftw is already installed (and is not broken), and that there is no valid dep chain to gcc

Note: in the brew doctor output below, prior to installing fftw the only warning is a non-/usr/local install prefix. After installing fftw, brew believes "Some installed formulae are missing dependencies" and wants to install gcc, isl, libmpc, and mpfr, although these are not actually required. I believe the non-/usr/local prefix isn't relevant as the problem is is brew's internal dependency resolution, not any package build or execution.

brew config

mbp:~ rfc6919$ brew config
HOMEBREW_VERSION: 1.5.12
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 85ebe88094f9095871b6ad752077ee1100b20328
Last commit: 5 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 9d13915487b6c817b0dd551b46243e8e95286774
Core tap last commit: 41 minutes ago
HOMEBREW_PREFIX: /opt/brew
HOMEBREW_REPOSITORY: /opt/brew
HOMEBREW_CELLAR: /opt/brew/Cellar
HOMEBREW_CELLAR: /opt/brew/Cellar
HOMEBREW_PREFIX: /opt/brew
HOMEBREW_REPOSITORY: /opt/brew
HOMEBREW_RUBY_WARNINGS: -W0
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.0 build 900
Git: 2.14.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /opt/brew/opt/python/libexec/bin/python => /opt/brew/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Java: N/A
macOS: 10.13.3-x86_64
Xcode: 9.2
CLT: 9.2.0.0.1.1510905681
X11: 2.7.11 => /opt/X11

brew doctor (prior to installing fftw)

mbp:~ rfc6919$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: 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.

brew doctor (after installing fftw --without-fortran)

mbp:~ rfc6919$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: 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.

Warning: Some installed formulae are missing dependencies.
You should `brew install` the missing dependencies:
  brew install gcc isl libmpc mpfr

Run `brew missing` for more details.
MikeMcQuaid commented 6 years ago

I'm afraid the depends_on "gcc" if build.with?("fortran") || build.with?("openmp") in fftw is the issue. Dependencies specified like this (which I'm going to write a brew audit --strict check for) display the issues you've mentioned. Unfortunately this isn't really fixable because of some horrible Homebrew internals. I'm sorry to close this but just so you know: I am slowly trying to work towards such things being less of an issue.