Search code examples
haskellcabal

Issue using Hoe from cabal sandbox - System.Random not found


I'm trying to use the Hoe utility from a cabal sandbox and am presented with the following error:

lyndon@endpin ~/Haskell-Sandboxes/hoe-1.0.1 ./.cabal-sandbox/bin/hoe head
compile error: <no location info>:
    Could not find module ‘System.Random’
    Use -v to see a list of the files searched for.

I believe that this is due to Hoe using Hint to interpret expressions at runtime, and as part of this, expecting to be able to load globally installed modules. However, since I'm using a cabal-sandbox, modules are only installed locally.

I've attempted to look for any environment variables I can use to specify the location of the random module as ./.cabal-sandbox/lib/x86_64-osx-ghc-7.8.3/random-1.1, however nothing obvious has appeared.

22070308 suggested that HASKELL_PACKAGE_SANDBOX might help, but it doesn't seem to.


Solution

  • I actually just came across the solution

    Setting GHC_PACKAGE_PATH to include the sandbox, and the default package location:

    lyndon@endpin ~/Haskell-Sandboxes/hoe-1.0.1 find ~/ghc_versions/ghc-7.8.3/ | grep package.cache
    /Users/lyndon/ghc_versions/ghc-7.8.3//lib/ghc-7.8.3/package.conf.d/package.cache
    lyndon@endpin ~/Haskell-Sandboxes/hoe-1.0.1 GHC_PACKAGE_PATH=~/ghc_versions/ghc-7.8.3//lib/ghc-7.8.3/package.conf.d:./.cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d ./.cabal-sandbox/bin/hoe head
    asdf
    'a'