82

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?‏‏‏‏‏‏

IKavanagh
  • 5,704
  • 11
  • 38
  • 44
T_Conroy
  • 4,380
  • 9
  • 43
  • 92

5 Answers5

79

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.

Community
  • 1
  • 1
jrwren
  • 15,914
  • 5
  • 32
  • 52
  • I've recently gotten into developing with NodeJS, which I installed through the packaged binary on the nodejs.org site. I don't recall explicitly installing Curl, but it'd be useful to have. If I uninstall my nodejs and re-install it through Homebrew, will that break anything or will it be a clean swap? – T_Conroy Oct 17 '14 at 15:13
  • It *should* work. Try it. If it doesn't work, you can copy these headers back or reinstall the packaged binary. If it helps, I can confirm that I do have node from homebrew and those headers are there. I don't have curl from homebrew or those curl headers. – jrwren Oct 17 '14 at 21:05
  • I think the problem is I updated curl with the binaries off the curl homepage, and it placed these headers in here. Is there any way to tell Brew to ignore them? I tried installing curl through homebrew instead but I can't seem to set the brew curl as the "default" curl, path changes had no effect, – T_Conroy Oct 29 '14 at 15:19
  • @Prefix There is no way to tell homebrew to ignore them. If you aren't compiling with those curl headers, it is safe to remove them. You can set brew curl as the default by making sure /usr/local/bin is in your path before /usr/bin. See http://stackoverflow.com/a/10343891/16998 – jrwren Oct 29 '14 at 17:33
  • I deleted the curl header files, and adjusted my path ( it is now: `/Users/Tom/.nvm/v0.10.33/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin` -- however, when I enter `curl` into the terminal, I am given error: `dyld: Library not loaded: /usr/local/lib/libcurl.4.dylib Referenced from: /usr/local/bin/curl Reason: Incompatible library version: curl requires version 8.0.0 or later, but libcurl.4.dylib provides version 7.0.0` – T_Conroy Oct 29 '14 at 18:24
  • @Prefix what does brew doctor say? try brew unlink curl; brew link curl. If you get no errors, that should work. If you do get errors, resolve them. – jrwren Oct 29 '14 at 20:12
  • I get "Warning: curl is keg-only and must be linked with --force" after unlinking/relinking. So I ran `brew link curl --force`, and now I'm getting the error I last posted about. :/ – T_Conroy Oct 30 '14 at 04:29
  • 1
    @Prefix did brew doctor ever complain about /usr/local/lib/libcurl.4.dylib? I'm guessing that it is left from the curl homepage binary package. ls -l /usr/local/lib/libcurl.4.dylib should show it is a symlink. If it is not a symlink, then it is likely from the curl homepage package. If it is a symlink, then something is wrong with that package. Also, look at output of `otool -L /usr/local/bin/curl`. It should link libcurl.4.dylib from Cellar/curl..., not from /usr/local/lib. Try brew unlink curl ; rm /usr/local/bin/curl ; brew link --force curl. – jrwren Oct 30 '14 at 13:38
  • The problem is I don't want to update Node to the latest every time there's an update, and I am upgrading all the apps in brew and I install those apps with brew where I want them latest. If only there was a way to exclude some apps from auto upgrade in brew. – amar Jan 23 '21 at 04:39
7

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`
testuser
  • 79
  • 1
  • 1
  • Nice, thanks! I've used a version that also ignores unexpected dylibs and static libs, not just includes: `brew doctor $(brew doctor --list-checks | grep -vE 'check_for_stray_(dylibs|static_libs|headers)')` – waldyrious Dec 13 '16 at 12:25
3

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.

Tim Smith
  • 5,548
  • 1
  • 22
  • 30
0

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 is run. The -n directive ensures that the command (rm -rf) is only run once per entry.

HaoZeke
  • 329
  • 4
  • 12
-12

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.*
Community
  • 1
  • 1
  • I find this solution very scary. I made a comment elaborating but hadn't noticed this solution was copied from an answer to a different question, so I've moved my comment there. – Don Hatch Apr 24 '15 at 01:50