Error building git and other formulae

I can install formulae that do not need compilation, such as C++ header only libraries, and I can also install casks. But when I try to install formulae that need building I get an error like this for missing system header files:

git-credential-osxkeychain.c:4:10: fatal error: 'Security/Security.h' file not found

This is the full log from /Users/aacirino/Library/Logs/Homebrew/git/02.make:

2020-05-16 21:10:04 -0300

make
CC=clang
CFLAGS=
LDFLAGS=

clang -c  git-credential-osxkeychain.c
git-credential-osxkeychain.c:4:10: fatal error: 'Security/Security.h' file not found
#include <Security/Security.h>
         ^
1 error generated.
make: *** [git-credential-osxkeychain.o] Error 1

HOMEBREW_VERSION: 2.2.16-69-g9fcaa46
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9fcaa46cdf04652e95668737a23ab248a8b7a73f
Last commit: 21 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 58382ad77f8f3c05318d24d54839f23aa7b70817
Core tap last commit: 40 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_MAKE_JOBS: 4
CPU: quad-core 64-bit core2
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 8.0 build 800
Git: 2.26.2 => /usr/local/bin/git
Curl: 7.43.0 => /usr/bin/curl
Java: 13.0.2
macOS: 10.11.6-x86_64
CLT: 8.2.0.0.1.1480973914
Xcode: 8.2.1

HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j4
CMAKE_PREFIX_PATH: /usr/local
CMAKE_INCLUDE_PATH: /usr/include/libxml2
CMAKE_LIBRARY_PATH: /System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
PKG_CONFIG_PATH: /usr/local/opt/pcre2/lib/pkgconfig
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.11
HOMEBREW_GIT: git
ACLOCAL_PATH: /usr/local/share/aclocal
PATH: /usr/local/Homebrew/Library/Homebrew/shims/mac/super:/usr/local/opt/gettext/bin:/usr/local/opt/pcre2/bin:/usr/bin:/bin:/usr/sbin:/sbin

Any help will be immensely welcome.

Thanks in advance

You’re using a very old macOS version and newer software might not work with that anymore.

I understand that and unfortunately in this specific case I can’t upgrade the OS. The issue is that brew’s behavior has been inconsistent since there are installations that run as intended.

That has very little to do with homebrew. Since we only support the versions that Apple supports we don’t keep 10.11 in mind when updating software and that software might have also dropped support for 10.11.

brew used to work until I made some changes to my system, removed brew and tried to install it again. I would like to know how I can debug the installation procedure since it seems that brew isn’t setting the development environment adequately.

you mean brew install --debug <name>?

I was unable to use the debug output to find a possible problem with the formula. I followed the backtrace as much as I considered useful in several different ruby files and found nothing that could be affecting my environment to the point that make will not be able, under brew, to build git. Please keep in mind that I downloaded the latest git source and built it using make && sudo make install as usual and it is installed and working : which git yields /usr/local/bin/git. My default environment should be the same for brew to build git, but the brew environment seems to be ignoring the macos frameworks path. Please take a look at the output below for the command brew install --debug git:

Last 15 lines from /Users/aacirino/Library/Logs/Homebrew/git/02.make:
2020-05-19 13:00:57 -0300

make
CC=clang
CFLAGS=
LDFLAGS=

clang -c  git-credential-osxkeychain.c
git-credential-osxkeychain.c:4:10: fatal error: 'Security/Security.h' file not found
#include <Security/Security.h>
         ^
1 error generated.
make: *** [git-credential-osxkeychain.o] Error 1
/usr/bin/curl --version
/usr/libexec/java_home --xml --failfast
/usr/libexec/java_home --xml --failfast
/usr/local/Homebrew/Library/Homebrew/debrew.rb:13:in `raise'
BuildError: Failed executing: make CC=clang CFLAGS= LDFLAGS=
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action: 3
/usr/local/Homebrew/Library/Homebrew/debrew.rb:13:in `raise'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2013:in `block in system'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1951:in `open'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1951:in `system'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/git.rb:104:in `block in install'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/fileutils.rb:128:in `chdir'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/fileutils.rb:128:in `cd'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/git.rb:103:in `install'
/usr/local/Homebrew/Library/Homebrew/debrew.rb:24:in `block in install'
/usr/local/Homebrew/Library/Homebrew/debrew.rb:94:in `debrew'
/usr/local/Homebrew/Library/Homebrew/debrew.rb:24:in `install'
/usr/local/Homebrew/Library/Homebrew/build.rb:152:in `block (2 levels) in install'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1173:in `block in brew'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2156:in `block (2 levels) in stage'
/usr/local/Homebrew/Library/Homebrew/utils.rb:474:in `with_env'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2155:in `block in stage'
/usr/local/Homebrew/Library/Homebrew/resource.rb:111:in `block in unpack'
/usr/local/Homebrew/Library/Homebrew/resource.rb:185:in `block in mktemp'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:57:in `block in run'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:57:in `chdir'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:57:in `run'
/usr/local/Homebrew/Library/Homebrew/resource.rb:184:in `mktemp'
/usr/local/Homebrew/Library/Homebrew/resource.rb:106:in `unpack'
/usr/local/Homebrew/Library/Homebrew/resource.rb:81:in `stage'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/forwardable.rb:230:in `stage'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2131:in `stage'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1166:in `brew'
/usr/local/Homebrew/Library/Homebrew/build.rb:123:in `block in install'
/usr/local/Homebrew/Library/Homebrew/utils.rb:474:in `with_env'
/usr/local/Homebrew/Library/Homebrew/build.rb:118:in `install'
/usr/local/Homebrew/Library/Homebrew/build.rb:202:in `<main>'

Homebrew extensively filters the build environment. People have the weirdest things as part of their setup so it’s needed. It’s possible that outdated framework paths are also filtered in that setup, you could probably test that using brew sh

Thank you for the help. I did use brew sh and the regular combo ./configure && make && make install /usr/local/bin worked flawlessly as I had previously built git. But brew install git still does not install git due to the path issue.

Does it break when you reproduce the steps in the formula? Because brew install git does quite a bit more than just ./configure && make && make install /usr/local/bin

I had to add this flag to my environment:

export CFLAGS="-F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/"

now git compiles and brew works as intended. Thank you for your help.