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)
6
  • 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?
    – user2005
    Commented Oct 25, 2014 at 6:36
  • Hi @rekado I have added the information you asked. Thanks!
    – Nicolas
    Commented Oct 25, 2014 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
    Commented Oct 25, 2014 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
    Commented Oct 25, 2014 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.
    – user2005
    Commented Nov 5, 2014 at 11:44

1 Answer 1

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.

2
  • 2
    this answer should be marked as accepted. Commented Nov 14, 2014 at 1:19
  • exec-path-from-shell is a package that helps you set the path of your Emacs shell to your user path. Commented Aug 9, 2015 at 4:13

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.