30

I try to install xdebug on MacOs Mojave but get this error

/private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: 'php.h' file not found

Command Line Tools are installed.

3 Answers 3

68

I ran into this trying to compile xdebug on my system, I had to do the following to get it to work

0) Check that you have the file /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg on your system.

1) If not, install the command line tools (I had installed them at one point, but the files under /Library/Developer/CommandLineTools/ were missing so I must have deleted it...)

xcode-select --install

2) Reinstall the header files

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Credit to @donatJ - https://stackoverflow.com/a/52612102/649915

Sign up to request clarification or add additional context in comments.

1 Comment

You, sir, saved my day. Do the headers and CommandLineTools get erased intentionally after updating to Mojave or is it a bug? I never had this issue before and I'm quite sure I didn't delete them.
14
brew doctor

and then

brew link --overwrite php

helped me.

4 Comments

gave me Error: No such keg: /usr/local/Cellar/php
using home-brew is okay if you are using hombrew, otherwise use the system via xcode-select --install (@steven's answer). Personally, I am not a fan of hb.
brew link --force --overwrite php72 works. Replace 72 with whichever version of PHP you would like to use.
brew link --force --overwrite [email protected] worked well in Catalina
10

Headers aren't installed for Mojave.

To install the headers:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

I was having the same issue and this fixed it for me.

1 Comment

This worked, but I had to disable SIP first. Then install the headers, run PECL to install what I wanted and as the last step enable SIP again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.