Daniel Gröber edited this page Jun 21, 2017 · 19 revisions

Known issues related to Cabal

Known issues related to Stack

It's not working

Make sure the dist/setup-config file doesn't exist in your project directory (the directory also containing your *.cabal file). When this file exists ghc-mod assumes you want to use cabal-install instead of Stack.

Most common Stack related issue

Most ghc-mod+Stack issues have to do with a GHC version mismatch.

ghc-mod once compiled is bound to one version of GHC since we link against the GHC API library. This used to not be a very big problem but since Stack made it exceedingly easy to use more than one version of GHC without even realising.

To confirm you are in fact suffering from this issue check if your Stack resolver uses a different GHC version from what ghc-mod was linked with, for example:

$ ghc-mod --version
ghc-mod version compiled by GHC 7.10.2


$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 7.8.4


Many users report success with starting their editors/IDEs or shells with stack exec inside the project they are working on after installing ghc-mod locally inside that project, for example:

$ cd my/super/cool/project/
$ stack install ghc-mod
$ stack exec -- emacs

The install command only needs to be run once unless you want to upgrade the ghc-mod version in use for that project. The stack exec command will run Emacs (or your editor of choice) with a modified environment which (among other things) adds the project-local binary installation directory to PATH.

We are working on a more permanent fix for this, see ghc-mod Issue: Implement worker/wrapper split, support multiple GHC versions.

readPackageDb: inappropriate type

ghc-mod: $HOME/.stack/snapshots/x86_64-linux/lts-2.22/7.8.4/pkgdb/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not a ghc-pkg db file, wrong file magic number)

See Most common Stack related issue

cannot satisfy -package-id ... is unusable due to missing or recursive dependencies

ghc-mod: <command line>: cannot satisfy -package-id aeson- 
    aeson- is unusable due to missing or recursive dependencies:
      attoparsec- base- <...>
    (use -v for more information)

Same root cause as above: Most common Stack related issue.

Failed to load interface for ...

Failed to load interface for ‘Some.Module’ There are files missing in the ‘package-1.2.3’ 
package,try running 'ghc-pkg check'

Same root cause as above: Most common Stack related issue

cabal-helper-wrapper: ghc: [...]: does not exist

Full error message:

cabal-helper-wrapper: ghc: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory) 

cabal-helper needs a working ghc executable at runtime to build it's wrapper component, when using only Stack's builtin GHC there is no ghc on $PATH hence this error.

To fix this simply add one of the paths in the output of the following command to your $PATH environment variable.

printf '%s\n' ~/.stack/programs/*/ghc-*/bin/

See https://github.com/DanielG/ghc-mod/issues/660