I'm trying to get emacs haskell-mode working with a cabal project. Whenever I try to compile or load a file interactively I get the following output in the haskell-process-log
compiling (via (C-c C-c)):
cabal.exe: No targets given and there is no package in the current directory.
and when loading (via (C-c C-l)):
cabal.exe: Unrecognised target syntax for ' --ghc-option=-ferror-spans'
Set up:
Windows 10,
GHC 8.10.2,
Cabal 3.2.0.0,
emacs 27.1,
haskell-mode 20201120.755
My emacs init file has the following:
(require 'haskell-interactive-mode)
(require 'haskell-process)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(eval-after-load "haskell-mode"
'(define-key haskell-mode-map (kbd "C-c C-c") 'haskell-compile))
(eval-after-load "haskell-cabal"
'(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-compile))
With a simple Haskell project, created by running cabal init
i.e. with a Main.hs
:
module Main where
main :: IO ()
main = putStrLn "Hello, Haskell!"
and my-project.cabal
:
cabal-version: >=1.10
-- Initial package description 'my-project.cabal' generated by
-- 'cabal init'. For further documentation, see
-- http://haskell.org/cabal/users-guide/
name: my-project
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file: LICENSE
author: ################
maintainer: ##################
-- copyright:
-- category:
build-type: Simple
extra-source-files: CHANGELOG.md, README.md
executable my-project
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.14 && <4.15
hs-source-dirs:
default-language: Haskell2010
If I try to compile via C-c C-c
I get the following in the haskell-process-log
buffer:
cabal.exe: No targets given and there is no package in the current directory.
Use the target 'all' for all packages in the project or specify packages or
components by name or location. See 'cabal build --help' for more details on
target options.
If I try to load via C-c C-l
the haskell process immediately dies prompting me to restart and the haskell-process-log displays:
cabal.exe: Unrecognised target syntax for ' --ghc-option=-ferror-spans'.
with '(haskell-process-log t)
and '(haskell-process-show-debug-tips t)
set within my init file custom vars this changes to:
("Starting inferior `cabal repl' process using cabal ..." "my-project" nil "cabal" "repl" " --ghc-option=-ferror-spans")
-> Prelude.putStrLn ""
:set -v1
:set +c
-> :set prompt "4"
-> :set prompt-cont "λ| "
<- cabal.exe: Unrecognised target syntax for ' --ghc-option=-ferror-spans'.
Event: "exited abnormally with code 1 "
Process reset.
Everything works fine in emacs when working on a lone haskell file, i.e. not inside a cabal project.
Compilation and cabal repl
within the cabal project via command line also works fine.
I've been searching through the docs and googling for a solid day and a half now. Any help would be appreciated.