I am using Haskell version 7.8.4 on (X)Ubuntu 15.10, with Cabal-Install 1.18 both installed through apt
. I have not attempted to install anything Haskell-related by hand on this machine. I set up a cabal sandbox, fetched and installed a module only to discover that ghc
doesn't seem to be picking it up. ghc -v
seems to suggest that I have two versions of the cabal library that are mutually shadowing each other. How does this work?
I am starting out with an empty directory /tmp/haskell-example
then I do a cabal sandbox init
.
$ cabal sandbox init
Writing a default package environment file to
/tmp/haskell-example/cabal.sandbox.config
Creating a new sandbox at /tmp/haskell-example/.cabal-sandbox
then I install natural-numbers
because I want to use the Data.Natural
module in a program. This operation succeeds.
$ cabal install natural-numbers
Resolving dependencies...
Notice: installing into a sandbox located at
/tmp/haskell-example/.cabal-sandbox
Configuring natural-numbers-0.1.2.0...
Building natural-numbers-0.1.2.0...
Installed natural-numbers-0.1.2.0
I can verify that the Data.Natural
module has indeed been installed to the cabal sandbox.
$ ls /tmp/haskell-example/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/natural-numbers-0.1.2.0
Data
libHSnatural-numbers-0.1.2.0.a
libHSnatural-numbers-0.1.2.0-ghc7.8.4.so
$ ls /tmp/haskell-example/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/natural-numbers-0.1.2.0/Data
Natural.dyn_hi
Natural.hi
then I create a simple Main.hs
file that imports Data.Natural
but does not use it.
module Main where
import Data.Natural
main = putStrLn "Hello World"
When I try to ghc Main.hs
I see the following :
$ ghc Main.hs
Main.hs:3:8:
Could not find module ‘Data.Natural’
Use -v to see a list of the files searched for.
With the verbose flag enabled, it seems as if my cabal is getting shadowed by a later cabal, which is in turn shadowing the earlier cabal. Why is this happening?
$ ghc -v Main.hs
Glasgow Haskell Compiler, Version 7.8.4, stage 2 booted by GHC version 7.8.4
Using binary package database: /usr/lib/ghc/package.conf.d/package.cache
hiding package Cabal-1.18.1.5 to avoid conflict with later version Cabal-1.22.1.1
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-ec14d2f6075975a2ce9112eae431c8e1
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-de4898ebdc5ab81cedce89121ae9ac84
wired-in package base mapped to base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-c1976a420ad8b9b589eee08844c59ba2
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
hiding package Cabal-1.18.1.5 to avoid conflict with later version Cabal-1.22.1.1
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-ec14d2f6075975a2ce9112eae431c8e1
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-de4898ebdc5ab81cedce89121ae9ac84
wired-in package base mapped to base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-c1976a420ad8b9b589eee08844c59ba2
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *Main.hs
Main.hs:3:8:
Could not find module ‘Data.Natural’
Locations searched:
Data/Natural.hs
Data/Natural.lhs
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
$HOME/.cabal
and/tmp/haskell-example/.cabal-sandbox
, but no.cabal
file. What would I need to do to update it? – Dagoncabal init
inside your project is creatingfoo.cabal
file which describes all needed dependencies, and you need to add them manually. Assuming your project namefoo
.For example, github.com/sigrlami/pollock/blob/master/pollock.cabal – Mastersinger