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:
  • 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: If it's a brew cask problem please file this issue at 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:

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
HEAD: c6acab66feb63743fe69b38dab7dc7b90710e838
Last commit: 2 hours ago
Core tap ORIGIN:
Core tap HEAD: 537f3703aa41c550edbaaf28dd280c6ec929f946
Core tap last commit: 34 minutes ago
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/
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.14-x86_64
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/ and CLI tools: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include.


% which 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"

% cat /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14/libxml-2.0.pc 

Name: libXML
Version: 2.9.4
Description: libXML library version2.
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:

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, 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:

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...
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...
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...
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...
brew SSL error when downloading from
As a temporary workaround brew config output brew doctor output The brew doctor above contains no Wa...
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...
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 ...
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...
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...
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...
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. ...
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...
homebrew openjdk Cask adoptopenjdk8 exists in multiple taps
I think AdoptOpenJDK8 should be removed from the homebrew-cask-versions repo Somone(TM) should proba...
homebrew core Permissions issue when linking python3
Same as your problem This works for me. Gist Logs:
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...
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...
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...
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...
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 ...
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...
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...
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...
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...
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...
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...
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...
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...
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...
devilutionX Diablo Hellfire support
We had a grate second hackathon 64bit support is now done and the road ahead is more clear Hellfire ...
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...
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 ...
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...
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...
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...
homebrew core mu --with-emacs compile fails on macOS Sierra 10.12.3
Solution without Mono Here is recipe to build it without Mono -
flutter Multiple commands produce '/build/ios/Debug-iphonesimulator/
I was able to fix it by opening the Runner workspace project in Xcode 10 Then navigate to File ...
flutter App Store iOS submission fails: The bundle 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...
flutter '' 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 file is: flutter doctor: ...
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 ...
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...
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...
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...
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...
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 ...
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 ...
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 ...
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...
flutter Making Network http error SocketException: Failed host lookup
@hoc081098 Double-check / make sure you have <uses-permission android:name=android.permission.INTERN...