2

I'm trying to use Posgres and a cabal sandbox for a new project. I've got postgresql-simple installed, as evidenced by installation outputs:

$ cabal install postgresql-simple
Resolving dependencies...
All the requested packages are already installed:
postgresql-simple-0.4.10.0
Use --reinstall if you want to reinstall anyway.
Notice: installing into a sandbox located at
/Users/inaimathi/projects/hs-test/.cabal-sandbox

but when I try to import the library in ghci, I get the error

ghci
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
Prelude> import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple

<no location info>:
    Could not find module ‘Database.PostgreSQL.Simple’
    It is not a module in the current program, or in any known package.
Prelude> 

Can anyone point out what I'm doing wrong?

Inaimathi
  • 13,853
  • 9
  • 49
  • 93

1 Answers1

1

You need to start GHCi with a -package-db=... flag pointing to /Users/inaimathi/projects/hs-test/.cabal-sandbox

so ghci -package-db=/Users/inaimathi/projects/hs-test/.cabal-sandbox or thereabouts...

Arnon
  • 2,237
  • 15
  • 23
  • That gives me the error `/Users/inaimathi/projects/hs-test/.cabal-sandbox/package.cache: openBinaryFile: does not exist (No such file or directory)`, after which `ghci` exits. I had to do `ghci -package-db .cabal-sandbox/x86_64-osx-ghc-7.10.1-packages.conf.d` (the last part being architecture specific). [This answer](http://stackoverflow.com/a/17054974/190887) helped. – Inaimathi Jul 04 '15 at 13:37
  • Yup, hence my 'or thereabouts...', couldn't check what the answer was for a Mac... – Arnon Jul 04 '15 at 13:39