Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
serhiip opened this issue Jun 28, 2020 · 6 comments
Open

Comments

@serhiip
Copy link

serhiip commented Jun 28, 2020

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
Copy link

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
Copy link
Owner

luite commented Feb 19, 2024

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

@maurges
Copy link

maurges commented Aug 23, 2024

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
Copy link
Owner

luite commented Aug 23, 2024

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

@maurges
Copy link

maurges commented Aug 24, 2024

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. Failed to install it on macOS Mojave rjeczalik/notify#165 (comment)
  2. Failure to install on macOS 10.14 Mojave with R 3.5.1 r-lib/fs#150 (comment)
  3. Mac OS Build Failed - v1.8.17 ethereum/go-ethereum#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

@HeinrichApfelmus
Copy link

HeinrichApfelmus commented Sep 15, 2024

I have the same error on macOS Sonoma 14.6.1.

I'm using nix flakes. Following the tips above, I have solved my problem by putting the following in my flake.nix:

        devShells.default = pkgs.mkShell {
          buildInputs = [
            pkgs.ghc
          ] ++ lib.optionals pkgs.stdenv.isDarwin ([
            pkgs.darwin.apple_sdk.frameworks.Cocoa
            pkgs.darwin.apple_sdk.frameworks.CoreServices
            pkgs.darwin.objc4.all
          ]);
        };

Here, pkgs is bound to nixpkgs with overlays as usual. The key point is to specify the required frameworks, Cocoa and CoreServices, explicitly.

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

That's alright — I think that the problem has to do with the installation of the MacOS SDKs. When starting XCode 15 for the first time, you'll get a question whether you want to install additional tools. If you answer "yes", and select "MacOS", then you'll eventually end up with the latest version of the SDKs installed here: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk. This needs to be connected to the Cabal frameworks: stanza somehow, and this is where things fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants