I'm trying to set up haskell-mode following this instructions

[0] https://github.com/haskell/haskell-mode/wiki/Haskell-Interactive-Mode-Setup

[1] http://tim.dysinger.net/posts/2014-02-18-haskell-with-emacs.html

but when I try to bring the REPL in a .hs file I'm getting the following error:

Starting inferior `cabal repl' process using cabal ...
-> :set prompt "\4"
-> Prelude.putStrLn ""
-> :set -v1
<- cabal: unrecognised command: repl (try --help)

Event: "exited abnormally with code 1

I have the "cabal repl" working.

Do you know what I'm missing?



I followed these steps [1]:

$ cabal --v
cabal-install version
using version of the Cabal library 

$ cabal install happy alex
$ cabal install ghc-mod structured-haskell-mode stylish-haskell

$ mkdir haskell-hello
$ cd haskell-hello
$ cabal init
$ touch LICENSE
$ cabal sandbox init

$ perl -p -i -e 's/^.*main-is.*$/  main-is: Main.hs/' haskell-hello.cabal
$ echo 'main = putStrLn "hello world"' > Main.hs
$ cabal install
$ ./.cabal-sandbox/bin/haskell-hello
  hello world

Then I open the Main.hs in Emacs. In haskell-mode I try to open a REPL with haskell-process-load-or-reload or haskell-interactive-bring but this error appears:

<- cabal: unrecognised command: repl (try --help)

I have cabal repl working:

$ cabal repl
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.

Edit 2:

When I eval

(process-lines "cabal repl")

I have the following result

apply: Searching for program: no such file or directory, cabal repl

Edit 3:

My haskell configuration on .emacs:

;; haskell
(require-package 'haskell-mode)

(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

(eval-after-load "haskell-mode"
     (define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left)
     (define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right)))

(define-key haskell-mode-map [f7] 'haskell-navigate-imports)

(custom-set-variables '(haskell-stylish-on-save t))

(add-hook 'haskell-mode-hook 'interactive-haskell-mode)

(custom-set-variables '(haskell-process-type 'cabal-repl))

(setq haskell-ghci-program-name "cabal")
(setq haskell-ghci-program-args '("repl"))

  '(haskell-process-suggest-remove-import-lines t)
  '(haskell-process-auto-import-loaded-modules t)
  '(haskell-process-log t))

(define-key haskell-mode-map (kbd "C-c C-g") 'haskell-interactive-bring)
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
(define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
(define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
(define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
(define-key haskell-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
(define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal)
(define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)
  • 1
    what exactly have you been doing before this error? What is your Haskell-related configuration up to this point? What does "bring the REPL in a .hs file" mean? – rekado Oct 25 '14 at 6:36
  • Hi @rekado I have added the information you asked. Thanks! – Nicolas Oct 25 '14 at 14:13
  • 1
    @Nicolas Would you mind to add the output of M-: (process-lines "cabal repl")? Probably your Emacs uses another, outdated cabal – user227 Oct 25 '14 at 18:45
  • @lunaryorn I have added the eval output. Do I need to install something especially for emacs? I have only installed haskell-mode on emacs and the rest of the packages with cabal. I have added also my haskell configuration. – Nicolas Oct 25 '14 at 20:29
  • @Nicolas: please show the output of (process-lines "cabal" "--v"). This should give you the version of the cabal binary Emacs uses. This should include the string – rekado Nov 5 '14 at 11:44

On my system (Fedora 20) the default cabal version that comes with the haskell-platform package is After installing the latest cabal-install (cabal install cabal-install), I have a new cabal binary in ~/.cabal/bin/cabal.

If I don't do any particular configuration in Emacs, haskell-interactive-bring will fail with the same error you report. When I correct the path to the cabal binary, though, everything works just fine:

(setq haskell-process-path-cabal "~/.cabal/bin/cabal")

Make sure that Emacs uses the correct cabal executable. If it does not, try setting haskell-process-path-cabal.

  • 2
    this answer should be marked as accepted. – Erik Kaplun Nov 14 '14 at 1:19
  • exec-path-from-shell is a package that helps you set the path of your Emacs shell to your user path. – sam boosalis Aug 9 '15 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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