Dependencies in user repository

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Wed Dec 3 06:18:42 EST 2008


On Wed, 2008-12-03 at 08:47 +0000, Lars Kotthoff wrote:
> > It should just work with the --user option, so we'll need more details.
> > What ghc version are you using exactly?
> 
> 6.8.3.
> 
> > If it's ghc-6.8.x, is the file for the user package db reported by
> > ghc-pkg list correct? What is the output of ghc-pkg list?
> 
> /usr/lib/ghc-6.8.3/package.conf:
>     Cabal-1.2.4.0, Cabal-1.6.0.1, HUnit-1.2.0.0, array-0.1.0.0,
>     base-3.0.2.0, binary-0.4.4, bytestring-0.9.0.1.1,
>     containers-0.1.0.2, directory-1.0.0.1, filepath-1.1.0.0,
>     (ghc-6.8.3), haskell98-1.0.1.0, hpc-0.5.0.1, html-1.0.1.1,
>     mtl-1.1.0.2, old-locale-1.0.0.0, old-time-1.0.0.0,
>     packedstring-0.1.0.0, parsec-2.1.0.0, pretty-1.0.0.0,
>     process-1.0.0.1, random-1.0.0.0, readline-1.0.1.0,
>     regex-base-0.93.1, regex-compat-0.92, regex-posix-0.93.2, rts-1.0,
>     template-haskell-2.2.0.0, time-1.1.2.0, unix-2.3.0.1
> /home/lars/dev/mhailist/release/package.conf:
>     binary-0.4.2, dlist-0.4.1
> 
> The required but not found dependency is dlist-0.4.1.
> 
> It looks to me as if cabal isn't parsing the second part of the output (the one
> from the user repository). If I require the specific version of binary in there,
> it also complains that it wasn't able to find it.

Right. So I'd like to get to the bottom of this because it's rather odd.
I'd fully expect this to work. Would you mind making a couple local
changes in Cabal and running it again?

I'm also wondering how you configure ghc and ghc-pkg to look in this
alternate location for the user package db, and if that carries over to
what cabal sees when it calls ghc-pkg.

So to see if we're getting the same views I think we should add some
debugging printing into this function:

It's in Cabal-1.6.0.1 in Distribution/Simple/GHC.hs line 387:

getInstalledPackages' verbosity packagedbs conf = do
    str <- rawSystemProgramStdoutConf verbosity ghcPkgProgram conf ["list"]
    let pkgFiles = [ init line | line <- lines str, last line == ':' ]
        dbFile packagedb = case (packagedb, pkgFiles) of
          (GlobalPackageDB, global:_)      -> return $ Just global
          (UserPackageDB,  _global:user:_) -> return $ Just user
          (UserPackageDB,  _global:_)      -> return $ Nothing
          (SpecificPackageDB specific, _)  -> return $ Just specific
          _ -> die "cannot read ghc-pkg package listing"
    pkgFiles' <- mapM dbFile packagedbs
    sequence [ withFileContents file $ \content -> do
                  pkgs <- readPackages file content
                  return (db, pkgs)
             | (db , Just file) <- zip packagedbs pkgFiles' ]

You can see that it calls "ghc-pkg list" and then looks for the lines
ending in ':', which we expect to be the names of the package files.

Then depending on which package db's the user has asked for, global,
global+user, or just a specific package db we select the appropriate
file names.

I suggest you add this debug printing:

getInstalledPackages' verbosity packagedbs conf = do
    str <- rawSystemProgramStdoutConf verbosity ghcPkgProgram conf ["list"]
    let pkgFiles = [ init line | line <- lines str, last line == ':' ]
        dbFile packagedb = case (packagedb, pkgFiles) of
          (GlobalPackageDB, global:_)      -> return $ Just global
          (UserPackageDB,  _global:user:_) -> return $ Just user
          (UserPackageDB,  _global:_)      -> return $ Nothing
          (SpecificPackageDB specific, _)  -> return $ Just specific
          _ -> die "cannot read ghc-pkg package listing"

+   print "========================"
+   putStr str
+   print "========================"
+   print pkgFiles
+   print =<< dbFile GlobalPackageDB
+   print =<< dbFile UserPackageDB

    pkgFiles' <- mapM dbFile packagedbs
    sequence [ withFileContents file $ \content -> do
                  pkgs <- readPackages file content
                  return (db, pkgs)
             | (db , Just file) <- zip packagedbs pkgFiles' ]


After this you'll need to reinstall the Cabal lib and then re-run runghc
Setup configure --user in the package directory you were using
previously.

Then we should look at the output. For example I get:

"========================"
/usr/local/lib64/ghc-6.8.2/package.conf:
    Cabal-1.2.3.0, array-0.1.0.0, base-3.0.1.0, bytestring-0.9.0.1,
    containers-0.1.0.1, directory-1.0.0.0, filepath-1.1.0.0,
    (ghc-6.8.2), haskell98-1.0.1.0, hpc-0.5.0.0, old-locale-1.0.0.0,
    old-time-1.0.0.0, packedstring-0.1.0.0, pretty-1.0.0.0,
    process-1.0.0.0, random-1.0.0.0, readline-1.0.1.0, rts-1.0,
    template-haskell-2.2.0.0, unix-2.3.0.0
/home/duncan/.ghc/x86_64-linux-6.8.2/package.conf:
    {AGI-1.2.2}, ALUT-2.1.0.0, {ASN1-0.0.1.1}, ArrayRef-0.1.2,

[...snip 100 lines of packages...]

    {yhccore-0.9}, zlib-0.4.0.4, zlib-0.5.0.0
"========================"
["/usr/local/lib64/ghc-6.8.2/package.conf","/home/duncan/.ghc/x86_64-linux-6.8.2/package.conf"]
Just "/usr/local/lib64/ghc-6.8.2/package.conf"
Just "/home/duncan/.ghc/x86_64-linux-6.8.2/package.conf"


Duncan



More information about the cabal-devel mailing list