Brew doctor - "warning: unbrewed header files were found in /usr/local/include"?

HomebrewBrew Doctor

Homebrew Problem Overview


When I run brew doctor, the following error is thrown

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/curl/curl.h
    /usr/local/include/curl/curlbuild.h
    /usr/local/include/curl/curlrules.h
    /usr/local/include/curl/curlver.h
    /usr/local/include/curl/easy.h
    /usr/local/include/curl/mprintf.h
    /usr/local/include/curl/multi.h
    /usr/local/include/curl/stdcheaders.h
    /usr/local/include/curl/typecheck-gcc.h
    /usr/local/include/node/ares.h
    /usr/local/include/node/ares_version.h
    /usr/local/include/node/nameser.h
    /usr/local/include/node/node.h
    /usr/local/include/node/node_buffer.h
    /usr/local/include/node/node_internals.h
    /usr/local/include/node/node_object_wrap.h
    /usr/local/include/node/node_version.h
    /usr/local/include/node/openssl/opensslconf.h
    /usr/local/include/node/uv-private/ngx-queue.h
    /usr/local/include/node/uv-private/stdint-msvc2008.h
    /usr/local/include/node/uv-private/tree.h
    /usr/local/include/node/uv-private/uv-bsd.h
    /usr/local/include/node/uv-private/uv-darwin.h
    /usr/local/include/node/uv-private/uv-linux.h
    /usr/local/include/node/uv-private/uv-sunos.h
    /usr/local/include/node/uv-private/uv-unix.h
    /usr/local/include/node/uv-private/uv-win.h
    /usr/local/include/node/uv.h
    /usr/local/include/node/v8-debug.h
    /usr/local/include/node/v8-preparser.h
    /usr/local/include/node/v8-profiler.h
    /usr/local/include/node/v8-testing.h
    /usr/local/include/node/v8.h
    /usr/local/include/node/v8stdint.h
    /usr/local/include/node/zconf.h
    /usr/local/include/node/zlib.h

Would it be safe to delete these files? What is the optimal way to resolve this warning?‏‏‏‏‏‏

Homebrew Solutions


Solution 1 - Homebrew

It looks like you installed curl and nodejs without using homebrew.

You have two options:

  1. Do nothing except remember this forever, so that you don't think they are from homebrew and wonder why homebrew is complaining.
  2. Remove them and install nodejs and curl from homebrew.

1 is the easy way, until it isn't.

I recommend #2 because it is likely, in the future you will install something from homebrew which depends on curl and/or node and homebrew will attempt to install those dependencies. When building from source, wrong headers may get used and mismatch libraries being linked. This is not fun to debug.

If those non homebrew header files are there for a reason and you are compiling software with them, then you are probably able to put them back if you need them. If you aren't building software with them, then you don't need them. Go ahead and delete them for now.

Solution 2 - Homebrew

You can skip the stray header checks to make it easier to see if there are issues other than node/npm not playing nicely with homebrew

brew doctor `brew doctor --list-checks | grep -v stray_headers`

Solution 3 - Homebrew

It may be safe to leave those files in place unless you encounter build or link problems with other Homebrew formulas; brew doctor output is advisory, not normative.

If you don't think you have a reason to build against the versions of curl or node in /usr/local, you can remove those header files; you can always reinstall the newest version later with Homebrew.

Solution 4 - Homebrew

I would copy them into a file (tmpKill), and then run:

xargs -0 -n 1 rm -rf < <(tr \\n \\0 <tmpKill)

This makes it easy to kill them all. The leftmost command generates a set of lines on which the rm -rf command (which deletes the files) is run. The -n directive ensures that the command (rm -rf) is only run once per entry.

Solution 5 - Homebrew

I had this same error today (Nov 19 2021) and I found out this discussion on GitHub which helped fixing it. https://github.com/Homebrew/discussions/discussions/1512

I actually got 3 warnings: >Warning: Homebrew/homebrew-core was not tapped properly! Run: rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" brew tap homebrew/core

>Warning: Unbrewed header files were found in /usr/local/include. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

>Warning: Some taps are not on the default git origin branch and may not receive updates. If this is a surprise to you, check out the default branch with: git -C $(brew --repo homebrew/core) checkout master

I ran these 2 commands and it fixed the problem:

> rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
> brew tap homebrew/core

Solution 6 - Homebrew

This solution worked for me!

sbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do  sudo rm /usr/local/${f}; done

sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontdcView Question on Stackoverflow
Solution 1 - HomebrewjrwrenView Answer on Stackoverflow
Solution 2 - HomebrewtestuserView Answer on Stackoverflow
Solution 3 - HomebrewTim SmithView Answer on Stackoverflow
Solution 4 - HomebrewHaoZekeView Answer on Stackoverflow
Solution 5 - HomebrewReactingView Answer on Stackoverflow
Solution 6 - HomebrewCharles CarrasqueroView Answer on Stackoverflow