Dominic Cooney
Dominic Cooney

Reputation: 6535

How do I get ghci to see packages I installed from cabal?

I've installed the such-and-such a package using cabal, and I can build a program that depends on it using cabal build. But when I load the same program in ghci, ghci complains that it "Could not find module `such-and-such'".

I'm surprised this doesn't "just work." How do I tell ghci where to find the packages I've installed with cabal?

Here's my setup: I'm using GHC 6.10.4 on Mac OS X 10.6.3, cabal-install version 0.6.2 using version 1.6.0.3 of the Cabal library.

Upvotes: 34

Views: 11306

Answers (3)

jpaugh
jpaugh

Reputation: 7035

Use cabal repl to ask cabal to open the GHCi interpreter with all the right settings for your project.

Upvotes: 4

Norman Ramsey
Norman Ramsey

Reputation: 202465

You need

ghci -package such-and-such

And to double-check that such-and-such is truly visible to GHC, run ghc-pkg list | grep such-and-such.

Upvotes: 24

sclv
sclv

Reputation: 38893

ghc-pkg list on the command line will tell you what your installed packages are. The installed package might be hidden, in which case you can reveal it with ghc-pkg expose {pkg-id}.

Upvotes: 15

Related Questions