luite / hfsevents

Haskell bindings for the OS X FSEvents API - Event based filesystem monitoring
BSD 3-Clause "New" or "Revised" License
21 stars 7 forks source link

fatal error: 'CoreServices/CoreServices.h' file not found OS X Catalina #14

Open serhiip opened 4 years ago

serhiip commented 4 years ago

I am facing an above issue when running cabal install hfsevents. This is very similar to #3

Error message I get:

Resolving dependencies...
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
 - hfsevents-0.1.6 (lib) (requires build)
Starting     hfsevents-0.1.6 (lib)
Building     hfsevents-0.1.6 (lib)

Failed to build hfsevents-0.1.6.
Build log ( /Users/serhiip/.cabal/logs/ghc-8.10.1/hfsvnts-0.1.6-e6f8b654.log
):
Configuring library for hfsevents-0.1.6..
Preprocessing library for hfsevents-0.1.6..
Building library for hfsevents-0.1.6..
[1 of 1] Compiling System.OSX.FSEvents ( System/OSX/FSEvents.hs, dist/build/System/OSX/FSEvents.o, dist/build/System/OSX/FSEvents.dyn_o )

cbits/c_fsevents.m:1:10: error:
     fatal error: 'CoreServices/CoreServices.h' file not found
  |
1 | #include <CoreServices/CoreServices.h>
  |          ^
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
`cc' failed in phase `C Compiler'. (Exit code: 1)
cabal: Failed to build hfsevents-0.1.6. See the build log above for details.

I have Xcode freshly installed and I am able to locate header file at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Headers/CoreServices.h

but defining this env var (in my .zshrc) like this doesn't help

export CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Headers/"

UPD: log of cabal install with -v3 https://pastebin.com/FDygnfQB

georgefst commented 3 years ago

I got there with: nix-shell -p darwin.apple_sdk.frameworks.CoreServices -p darwin.objc4.all -p darwin.apple_sdk.frameworks.Cocoa

Apologies for this being a Nix-only solution, but it should give you some idea.

luite commented 6 months ago

Does anyone still see this problem? I've never encountered it (I get my GHC installs from GHCup usually).

maurges commented 1 week ago

I still see this, but I don't only see this in haskell, but in other languages for similar packages too, so I think it's an environment problem. And the solution with nix shell works for me still.

luite commented 1 week ago

I'm still interested in learning how to reproduce this, since I don't see it here with my ghcup based install.

maurges commented 1 week ago

I believe this is related to the fact that I never installed xcode. When looking for similar errors online, they all are resolved by installing xcode/command line tools or running xcode-select. Examples:

  1. https://github.com/rjeczalik/notify/issues/165#issuecomment-426110790
  2. https://github.com/r-lib/fs/issues/150#issuecomment-436027795
  3. https://github.com/ethereum/go-ethereum/issues/17940
  4. https://discuss.ocaml.org/t/build-dune-doesnt-work/13326/10
  5. https://elixirforum.com/t/problem-using-devbox-with-phoenix-error-cant-find-executable-mac-listener/59835 - solved with nix for a change, ha
  6. Surprisingly, this same issue we're in was on the first page of search