ErikR
ErikR

Reputation: 52059

ghc-mod can't find a user installed module

I have a situation where ghc-mod can't find a module installed in my ~/.ghc/ directory.

The program (foo.hs) is just:

import Control.Monad.Loops
main = undefined

ghci loads foo.hs without any errors.

ghc-pkg list produces the output:

/Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/package.conf.d
    Cabal-1.18.1.4
    GLURaw-1.4.0.1
    ...
~/.ghc/x86_64-darwin-7.8.3/package.conf.d:
    ...
    monad-loops-0.4.2.1

but ghc-mod check foo.hs errors out with:

x.hs:4:8:Could not find module ‘Control.Monad.Loops’Perhaps you meant  Control.Monad.Cont (from mtl-2.1.3.1)  Control.Monad.List (from mtl-2.1.3.1)  Control.Monad.Trans (from mtl-2.1.3.1)Use -v to see a list of the files searched for.

ghc-mod is located in ~/Library/Haskell/bin and ghc-mod -v emits:

ghc-mod version 5.0.1.2 compiled by GHC 7.8.3
...

What's kinda odd is that I don't get an error when loading foo.hs in Emacs under haskell-mode, and presumable that also uses ghc-mod.

Is there a way to debug this further and/or configure ghc-mod to look in my ~/.ghc directory?

Upvotes: 0

Views: 868

Answers (1)

ErikR
ErikR

Reputation: 52059

The answer is that ghc-mod will look for a cabal.sandbox.config file in all parent directories of the current working directory and use that if it finds one, and that was hiding my ~/.ghc package directory.

Upvotes: 1

Related Questions