Cabal woes on iMac

[Apologies if this is not the right place for such questions. If so, where should they go?]

I’m attempting to install QuickCheck via cabal on an iMac, but I’m getting a strange error.

The system complains that it cannot find ghc, even though ghc is in the specified place.

Any suggestions on how to fix? Thank you for your help. Go well, – P

philipwadler@Philips-iMac ~ % ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
philipwadler@Philips-iMac ~ % .ghcup/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
philipwadler@Philips-iMac ~ % ~/.ghcup/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
philipwadler@Philips-iMac ~ % pwd
/Users/philipwadler

philipwadler@Philips-iMac ~ % cabal install QuickCheck
Resolving dependencies…
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):

  • splitmix-0.1.0.4 (lib) (requires build)
  • random-1.2.1.1 (lib) (requires build)
  • QuickCheck-2.14.2 (lib) (requires build)
    Starting splitmix-0.1.0.4 (lib)
    Failed to build splitmix-0.1.0.4. The failure occurred during the configure
    step.
    Build log (
    /Users/philipwadler/.cabal/logs/ghc-8.10.7/spltmx-0.1.0.4-a1adbba1.log ):
    Configuring library for splitmix-0.1.0.4…
    cabal-3.6.2.0: Cannot find the program ‘ghc’. User-specified path
    ‘.ghcup/bin/ghc’ does not refer to an executable and the program is not on the
    system path.
    cabal: Failed to build splitmix-0.1.0.4 (which is required by
    QuickCheck-2.14.2). See the build log above for details.
    philipwadler@Philips-iMac ~ %
1 Like

Could it be cabal is taking some environment variable you accidentally set?

Would you be able to try:

$ set | grep -i ghc

to see if anything coming up?

1 Like

Thanks for the suggestion. See below. Any help gratefully received!

philipwadler@Philips-iMac ~ % set | grep -i ghc
PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.ghcup/bin
path=( /opt/homebrew/bin /opt/homebrew/sbin /usr/local/bin /usr/bin /bin /usr/sbin /sbin .ghcup/bin )

Ah, that’s it

“:.ghcup/bin” is a relative path, it should not be in $PATH variable.

You should look into where it is set, most likely in ~/.bashrc and change it to a absolute path.

1 Like

Thanks very much! I made the fix you suggested, and also fixed an issue with the llvm version. However, it now complains about opt. Any suggestions?

philipwadler@dhcp-91-153 ~ % echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/philipwadler/.ghcup/bin

philipwadler@dhcp-91-153 ~ % brew install llvm@12
[lots omitted]

philipwadler@dhcp-91-153 ~ % cabal install QuickCheck
Resolving dependencies…
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):

  • splitmix-0.1.0.4 (lib) (requires build)
  • random-1.2.1.1 (lib) (requires build)
  • QuickCheck-2.14.2 (lib) (requires build)
    Starting splitmix-0.1.0.4 (lib)
    Building splitmix-0.1.0.4 (lib)

Failed to build splitmix-0.1.0.4.
Build log (
/Users/philipwadler/.cabal/logs/ghc-8.10.7/spltmx-0.1.0.4-a1adbba1.log ):
Configuring library for splitmix-0.1.0.4…
Preprocessing library for splitmix-0.1.0.4…
Building library for splitmix-0.1.0.4…

: error:
Warning: Couldn’t figure out LLVM version!
Make sure you have installed LLVM between [9 and 13)

: error:
Warning: Couldn’t figure out LLVM version!
Make sure you have installed LLVM between [9 and 13)

: error:
Warning: Couldn’t figure out LLVM version!
Make sure you have installed LLVM between [9 and 13)

: error:
Warning: Couldn’t figure out LLVM version!
Make sure you have installed LLVM between [9 and 13)
[1 of 4] Compiling Data.Bits.Compat ( src-compat/Data/Bits/Compat.hs, dist/build/Data/Bits/Compat.o, dist/build/Data/Bits/Compat.dyn_o )

: error:
Warning: Couldn’t figure out LLVM version!
Make sure you have installed LLVM between [9 and 13)
ghc: could not execute: opt
cabal: Failed to build splitmix-0.1.0.4 (which is required by
QuickCheck-2.14.2). See the build log above for details.

Oh, wait. Stupid me. I failed to note that it was still complaining about the LLVM version. Found the fix with a search, which is to add “/opt/homebrew/opt/llvm@12/bin” to the front of the PATH.

It works now! Thank you for your help.

2 Likes