4

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?

Thanks!

Edit:

I followed these steps [1]:

$ cabal --v
cabal-install version 1.20.0.3
using version 1.20.0.2 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.
Prelude> 

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"
  '(progn
     (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"))

(custom-set-variables
  '(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)
Nicolas
  • 41
  • 1
  • 3
  • 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? –  Oct 25 '14 at 06: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`… –  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 `1.20.0.3`. –  Nov 05 '14 at 11:44
  • @Nicolas Have you solved this yet? Is there a problem with the answer I provided? –  Feb 24 '15 at 17:03

1 Answers1

4

On my system (Fedora 20) the default cabal version that comes with the haskell-platform package is 1.16.0.2. 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.