After upgrading to macOS Ventura, cannot open GHCi, install versions of Haskell on GHCup, or compile a .hs file

Against my better judgement, I went ahead and upgraded my macOS version to Ventura. I use a 2021 M1 Pro machine. Below are the various errors I encounter when trying the various actions listed in this post’s title.

Opening GHCi

% ghci
GHCi, version 9.4.2: https://www.haskell.org/ghc/  :? for help
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
`gcc' failed in phase `gcc'. (Exit code: 1)

Installing GHC versions on GHCup

[ Info  ] Installing GHC (this may take a while)
[ ghc-configure ] not found (too old?)
[ ghc-configure ] checking for gcc... gcc
[ ghc-configure ] checking whether the C compiler works... no
[ ghc-configure ] configure: error: in `/Users/myusername/.ghcup/tmp/ghcup-1e1054df9ffa4cb3/ghc-9.4.3-aarch64-apple-darwin':
[ ghc-configure ] configure: error: C compiler cannot create executables
[ ghc-configure ] See `config.log' for more details
[ Error ] Process "sh" with arguments ["./configure",
[ ...   ]                              "--prefix=/Users/myusername/.ghcup/ghc/9.4.3",
[ ...   ]                              "--disable-ld-override"] failed with exit code 77.
[ Error ] Also check the logs in /Users/myusername/.ghcup/logs

Compiling a file

% ghc test.hs
[1 of 2] Compiling Main             ( test.hs, test.o )

<no location info>: error:
    Warning: Couldn't figure out C compiler information!
             Make sure you're using GNU gcc, or clang
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

<no location info>: error:
    `gcc' failed in phase `Assembler'. (Exit code: 1)

Request for help

It looks like a C compiler problem, but I don’t know what else to do. I’m personally not in a hurry because I have another machine on which to use Haskell, but it is somewhat unfortunate and inconvenient to be unable to use GHC on this particular machine at the moment.

Does anyone know what I could try to make things work again? Thank you.

You’ll need to re-install the command line tools.

Running the following command in a terminal

xcode-select --install

should start the install process.

4 Likes

That did the trick, thank you so much!