0

I installed ghc and cabal-install on Ubuntu using this way. When I install a package using cabal sandbox init and cabal install thepackage, the installation runs fine, but the package is not found in GHC (message: "It is not a module in the current program, or in any known package."). I have spent a couple of hours in trying to solve this problem, unsuccessfully. I took a look at this post, but it is for Windows, this post, but it doesn't help me, this FAQ, but I tried with and without the --global option, and the result is the same. Some info about my installation:

$ which cabal
/opt/cabal/1.22/bin/cabal
$ which ghc
/opt/ghc/7.10.3/bin/ghc

I have a ~/.ghc folder, but it is empty. It looks like the installed packages are in the folder ~/.cabal/packages/hackage.haskell.org and ~/.cabal-sandbox/lib/x86_64-linux-ghc-7.10.3.

Community
  • 1
  • 1
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
  • If you're within the sandbox then the installed packages should be in something like `./.cabal-sandox` – pdexter Jul 21 '16 at 13:31
  • [This answer](https://stackoverflow.com/questions/28631925/haskell-package-installed-but-not-found?noredirect=1&lq=1) is __not__ windows specific. You have to use `cabal exec ghc` to use things in the sandbox. – Zeta Jul 21 '16 at 13:53
  • @Zeta You're right, it works with `cabal exec ghci` ! Thank you ! – Stéphane Laurent Jul 21 '16 at 13:58
  • @Zeta but it doesn't work if I run `cabal exec ghci` from a folder different than `~/` .... – Stéphane Laurent Jul 21 '16 at 14:01
  • @StéphaneLaurent: You can only use the packages in the sandbox where you've installed them, e.g. `cd path/to/wd; cabal install package1 package2; cabal exec ghci`. You need to either symlink the cabal-sandbox, or use a command line option for that. If that's too much of a hassle, use [`stack`](http://haskellstack.org). – Zeta Jul 21 '16 at 14:01
  • @Zeta That's annoying... And how to run `ghc` with options ? `cabal exec ghc -O ...` : "unrecognized 'exec' option `-O'". – Stéphane Laurent Jul 21 '16 at 14:05
  • @StéphaneLaurent: That's another question ("How can I use GHC with a cabal sandbox not installed in the current directory?"), and the answer would be [`-package-db`](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#package-databases). You're aware that there is documentation out there, right? :D – Zeta Jul 21 '16 at 14:08
  • @Zeta That's the second day I spend my time with this problem and I've lost my patience with all these documentations which look like Chinese for me... ;-) I'll continue another day. Thanks for your help. – Stéphane Laurent Jul 21 '16 at 14:21
  • 1
    @StéphaneLaurent, you're welcome, and [here is your explanation](http://stackoverflow.com/q/38507261/1139697). – Zeta Jul 21 '16 at 14:40

0 Answers0