Solvedbrew pkg-config files on >=10.14 assume headers in /usr/include

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh
  • ran a brew command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew config and brew doctor and included their output with your issue?
% 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: The following directories do not exist:
/usr/local/sbin

You should create these directories and change their ownership to your account.
  sudo mkdir -p /usr/local/sbin
  sudo chown -R $(whoami) /usr/local/sbin
% brew config
HOMEBREW_VERSION: 1.7.6-143-gc6acab6
ORIGIN: https://github.com/Homebrew/brew
HEAD: c6acab66feb63743fe69b38dab7dc7b90710e838
Last commit: 2 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 537f3703aa41c550edbaaf28dd280c6ec929f946
Core tap last commit: 34 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1000
Git: 2.17.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.14-x86_64
CLT: 10.0.0.0.1.1535735448
Xcode: 10.0
XQuartz: 2.7.11 => /opt/X11

To help us debug your issue please explain:

  • What you were trying to do (and why)
    I tried to build a package which uses pkg-config from Homebrew.

  • What happened (include command output)
    I met an error when build:

fatal error: 'libxml/tree.h' file not found
#include <libxml/tree.h>
         ^~~~~~~~~~~~~~~
1 error generated.

It looks like pkg-config from Homebrew is not providing the correct include directory of libs shipping with macOS(Xcode and CLI tools). As the release note of Xcode 10, header files which were under /usr/include no longer exists and been moved to Xcode: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include and CLI tools: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include.

output:

% which pkg-config
/usr/local/bin/pkg-config

% pkg-config --cflags --libs "libxml-2.0 > 2.6.17"
-I/usr/include/libxml2 -lxml2

% pkg-config --variable pcfiledir "libxml-2.0 > 2.6.17"
/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14

% cat /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14/libxml-2.0.pc 
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
modules=1

Name: libXML
Version: 2.9.4
Description: libXML library version2.
Requires:
Libs: -L${libdir} -lxml2
Libs.private: -lz -lpthread -licucore -lm
Cflags: -I${includedir}/libxml2

I tested only with libxml2 but I believe this issue affect all libs which have pkg-config file from Homebrew Library/Homebrew/os/mac/pkgconfig/10.14, they are: libcurl.pc, libexslt.pc, libxml-2.0.pc, libxslt.pc, sqlite3.pc, zlib.pc.

  • What you expected to happen
% pkg-config --cflags --libs "libxml-2.0 > 2.6.17"

should gives the correct path to the header files under Xcode or CLI tools.

  • Step-by-step reproduction instructions (by running brew commands)
  1. brew install pkg-config
  2. pkg-config --cflags --libs "libxml-2.0 > 2.6.17"
47 Answers

✔️Accepted Answer

Looks like there's a significant issue with the way SwiftPM handles pkg-config. It incorrectly handles *.pc files directly so that PKG_CONFIG_SYSTEM_INCLUDE_PATH (be it the environment variable or the baked in default) is not appropriately applied. It attempts to mimic what pkg-config does but this implementation is incomplete: https://github.com/apple/swift-package-manager/blob/d433df8bfca5e3df498b3300c2b6aee222154cd4/Sources/PackageLoading/Target%2BPkgConfig.swift#L244

The SwiftPM issue has fatal effects on macOS due to systems headers no longer being at /usr/include since Mojave (SwiftPM only filters /usr/include still).

This isn't however something macOS specific. There are multiarch Linux distros that rely on this. There's also other variables commonly used in places on Linux like PKG_CONFIG_ALLOW_SYSTEM_LIBS. SwiftPM fails to recognise any of this.

There is a general issue covering the topic at https://bugs.swift.org/browse/SR-6317, filed internally as rdar://problem/40235197.

I'll look into deleting cflags entirely until the Swift issue is fixed.

Other Answers:

Hi folks, it looks like this also broke building Go packages that depend on pkg-config for CGO dependencies.

Some sample output from a Go project:

❯ go test ./...
# /usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config --cflags  -- opus opus opus opusfile opus opusfile
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 6: /pkg-config/bin/pkg-config: No such file or directory
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 6: exec: /pkg-config/bin/pkg-config: cannot execute: No such file or directory
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config: exit status 126

Looks like HOMEBREW_OPT isn’t set. I’d love to help—how best to?

I don't know what is going on, but export HOMEBREW_OPT=/usr/local/opt in ~/.bash_profile worked for me

@pgrenaud @mkalvas Run brew upgade imagemagick/brew upgrade imagemagick@6 and try again. Should work now.

Related Issues:

114
brew MBP M1 fails to 'brew update' and 'brew upgrade'
Your Homebrew-installed git is probably broken This seems to have come up a bunch of times but I hav...
82
brew Brew update error
You will only need to execute this once and you'll be okay afterwards Hi today i run brew update wit...
58
brew brew cleanup fails when cask is defined in multiple taps
@MikeMcQuaid Yes we absolutely need to fix this In the meantime the issue can be worked around by re...
52
brew Brew update fails with Permission denied (publickey).
@bm5k figured it out for 10.12 which uses ssh-agent now (cool) Just ssh-add ~/.ssh/<your rsa file> A...
38
brew SSL error when downloading from homebrew.bintray.com
As a temporary workaround brew config output brew doctor output The brew doctor above contains no Wa...
33
brew brew update : Bad file descriptor (Errno::EBADF)
I had the same issue my problem was that I run a sudo command that probably affected some permission...
20
brew Homebrew does not work on Big Sur (10.16/11.0)
In addition to installing XCode 12.2 I had to to get brew upgrade/brew install to work on Big Sur ...
19
brew Homebrew doesn't allow side-by-side Xcode 8.3.3 and 9.0 installations
OK Please try this: I have both 8.3.3 and 9.0 installed on MacOS High Sierra When running brew upgra...
14
brew Broken vim after perl upgrade
I met this issue too when I had ran brew upgrade,so I tried: brew uninstall --ignore-dependencies pe...
4
brew pkg-config files on >=10.14 assume headers in /usr/include
Looks like there's a significant issue with the way SwiftPM handles pkg-config Please note we will c...
3
brew Fatal error on outdated xcode
@DomT4 FYI Travis sets CI as well so you could just use that instead of both TRAVIS and CIRCLECI. ...
40
brew brew update failed with "Error: Git must be installed and in your PATH!"
Possibly related: I reproduced the same on High Sierra and after performing the HOMEBREW_NO_ENV_FILT...
224
homebrew openjdk Cask adoptopenjdk8 exists in multiple taps
I think AdoptOpenJDK8 should be removed from the homebrew-cask-versions repo Somone(TM) should proba...
71
homebrew core Permissions issue when linking python3
Same as your problem This works for me. Gist Logs: https://gist.github.com/37a31433396016024e15632df...
34
homebrew core "module 'enum' has no attribute 'IntFlag'" when installing python3
@deering59 Make sure that nowhere in your shell configuration files PYTHONPATH is set to point to yo...
33
kerl Can't install Erlang-24 due to openssl issues
TL;DR: read the last part I encountered the very same problem After inspecting both config.log and o...
22
homebrew core Upgrading to Ruby 2.4.1_1 breaks gem command.
Oh hey! That solved it! So both: and seems to do the trick! Thanks!! Ran brew update and retried you...
19
homebrew cask What to do regarding java development casks
Edit 2: added link to AdoptOpenJDK migration guide; December 2020 deadline for Oracle JDK 8 availabi...
18
homebrew core Formula php@5.6 not working on macOS 10.14 (Mojave)
I was able to track the issue down to the packaged OPcache extension Please note we will close your ...
18
homebrew core Failed to set locale category
Currently I've just added export LC_ALL in my .bash_profile. Please note we will close your issue wi...
18
mas High Sierra Exception error
Thanks for the updates and details everyone Sorry it has been broken for so long but I'm looking int...
17
homebrew core Upgrading to Xcode CLT 11.0 broke GCC 9
This is a bug in the C library that comes with the updated Xcode To fix it I just upgraded the Xcode...
16
homebrew core First issues with macOS 10.13 High Sierra
@kylebrowning you can brew install --force-bottle foo for anything you're having trouble building an...
15
homebrew cask VirtualBox Cask 6.0.8 Broken and Partial Fails Installation
BTW For those having this problem and need an immediate resolution Boot into Recovery with Command-R...
14
homebrew cask Bug report: Problem uninstalling the wireshark cask
@vitorgalvao same issue reported in @alireza's last comment Digging a bit further: this complete seq...
14
homebrew cask brew cask zap command failed and the output is weird
I've experienced it too And it is not the first time that Software Update messed my CLT installation...
14
linuxbrew core glibc: Requires GCC 4.7 or later
OK Is it currently supported to install glibc on rather old systems without root access? I am workin...
9
homebrew core wireguard doesn't start anymore
Dug a bit deeper and realized this is already fixed by commit WireGuard/wireguard-tools@457f96b on J...
9
devilutionX Diablo Hellfire support
We had a grate second hackathon 64bit support is now done and the road ahead is more clear Hellfire ...
8
homebrew core brew install neovim --HEAD fails on macOS Monterey
Can confirm that worked for me In case anyone else needs the steps: brew gist-logs <formula> link OR...
7
homebrew core Segmentation fault with curl-openssl
@mbence Thanks for the input! Could you please let me know can I revert to that version? I tried to ...
6
homebrew core qt5 fails to build on macOS 10.11 & 12
Not a solution but if anyone lands here trying to install Qt5 on macOS Sierra and you just want to g...
6
homebrew services brew services - Unknown command: services
Run brew update this is now fixed by a new Homebrew/brew tag. The latest commit breaks brew services...
5
homebrew core libtiff source no longer available (new patch level)
Some fairly strange errors there For a start you've apparently got a mirror pointing to a .deb which...
4
homebrew core mu --with-emacs compile fails on macOS Sierra 10.12.3
Solution without Mono Here is recipe to build it without Mono - https://gist.github.com/KryDos/d306d...
459
flutter Multiple commands produce '/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework
I was able to fix it by opening the Runner workspace project in Xcode 10 Then navigate to File ...
449
flutter App Store iOS submission fails: The bundle Runner.app/Frameworks/App.framework does not support the minimum OS Version specified in the Info.plist
After doing a flutter clean changing MinimumOSVersion (inside /ios/Flutter/AppframeworkInfo.plist) t...
418
flutter 'com.android.support:appcompat-v7' has different version for the compile (26.1.0) and runtime (27.0.1) classpath
is like this i receive an error when i run flutter run My gradle.build file is: flutter doctor: ...
409
flutter Why does my text not wrap?
You have to wrap Column in a flexible Without flexible the column's width is not constrained to the ...
383
flutter Unexpected top padding in ListView put inside scaffold with no appBar
Yeah this is intentional If you put a widget before the ListView you should wrap the ListView with a...
358
atom Sometimes opening a file, Atom does not open in a new tab
This feature is called Pending Pane Items (formerly known as Preview Tabs) – this allows you to quic...
315
flutter Missing xcode dependency: Python module "six"
try python2.x -m pip install six by @humblerookie's suggest or brew reinstall python@2 pip install s...
285
flutter flutter messaging: set the notification icon
Hey guys I fought with this for the better part of a day For some strange reason there are no tutori...
281
flutter Issue with cloud_firestore - Cannot fit requested classes in a single dex file.
As a workaround you can try enabling mutlidex for Android App by following Enable multidex for apps ...
279
valet In Brew.php line 187: Unable to determine linked PHP.
I've had the same problem tonight I try methods: composer global update install php 72 brew upgrade ...
265
flutter D8: Program type already present: io.flutter.BuildConfig
@smrucv I received the same error but after flutter clean and flutter packages get everything works ...
250
238
flutter Introduction of characters package causes crash on flutter run for preexisting Flutter applications
In my case I resolved the issue with flutter clean After e0ed12c I get this error when building: @ju...
221
flutter Making Network http error SocketException: Failed host lookup
@hoc081098 Double-check / make sure you have <uses-permission android:name=android.permission.INTERN...