1

I installed haskell-mode and I want to launch the REPL GHCi with the command C-c C-z.

However, on typing C-c C-z, it shows error Could not find any installation of GHC.

enter image description here

And when I use same command again, it launches a new window with what looks like ghci. But when I try to type and execute something, it shows an error "haskell-process" has died as below. (If it matters at all, there is a tests.cabal in the directory where the current open file resides)

enter image description here

If I enter y then it throws the same error as above about GHC not being found.

Now I have my GHC, Stack, Cabal, and HLS installations managed through GHCup. Therefore by default, I only have the ghcup path in the system PATH variable.

Since many places online said that there needs to be the ghc path in the PATH, I added the line export PATH=$PATH:/home/axiom/.ghcup/bin/ghc to my .bashrc. But this didn't fix anything.

Further, I looked for other solutions and tried two more things:

I added the following lines in my .emacs.d/init.el :

(setenv "PATH" (concat "/home/axiom/.ghcup/bin/ghc" (getenv "PATH")))
(setq exec-path (append '("/home/axiom/.ghcup/bin/ghc") exec-path))

Adding this also didn't solve anything.

Then I replaced the above lines with (setq haskell-process-path-ghci "/home/axiom/.ghcup/bin/ghc") and this didn't help either.

I think the error Could not find any installation of GHC. is being returned from a piece of code in this file https://github.com/haskell/haskell-mode/blob/master/haskell-customize.el but I am not able to figure out how to fix my system according to what the haskell-mode code is trying to do before throwing the above error.

3

2 Answers 2

1

I had the same issue after switching to ghcup.

As the comments pointed out, using directories to ghci rather than the executable itself solves the problem:

(let ((my-ghcup-path (expand-file-name "~/.ghcup/bin")))
  (setenv "PATH" (concat my-ghcup-path ":" (getenv "PATH")))
  (add-to-list 'exec-path my-ghcup-path))

(tested under Ubuntu 22.04)

-1

Yeah, the tinlyx's solution also works on my MacBook Air M1 with Emacs installed with homebrew (specifically GNU Emacs 29.4 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2024-08-03) And GHC(i) from GHCup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.