Dependencies in user repository

Dear all, I'm having trouble getting Cabal to find packages installed in my user repository. When I run ghc-pkg list manually, I can see all the required packages, listed in the section for my user repository. When I run ghci I can import said packages as well. Yet when I run ghc on the Setup.hs file of a package which requires said packages, it tells me that the dependencies are missing. It works when I use --package-db to explicitely point it to the user package.conf. Am I missing an extra flag or something like that to make it take the packages in the user repository into account? I'm using Cabal version 1.6.0.1. Thanks, Lars

On Mon, Dec 1, 2008 at 1:40 PM, Lars Kotthoff
Dear all,
I'm having trouble getting Cabal to find packages installed in my user repository.
When I run ghc-pkg list manually, I can see all the required packages, listed in the section for my user repository. When I run ghci I can import said packages as well. Yet when I run ghc on the Setup.hs file of a package which requires said packages, it tells me that the dependencies are missing.
You probably want to use: runghc Setup configure --user Hope that helps, -Judah

On Mon, 2008-12-01 at 21:40 +0000, Lars Kotthoff wrote:
Dear all,
I'm having trouble getting Cabal to find packages installed in my user repository.
When I run ghc-pkg list manually, I can see all the required packages, listed in the section for my user repository. When I run ghci I can import said packages as well. Yet when I run ghc on the Setup.hs file of a package which requires said packages, it tells me that the dependencies are missing.
It works when I use --package-db to explicitely point it to the user package.conf. Am I missing an extra flag or something like that to make it take the packages in the user repository into account? I'm using Cabal version 1.6.0.1.
It should just work with the --user option, so we'll need more details. What ghc version are you using exactly? 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? Mind you, if it was getting the wrong location then I'd expect reading it to fail, if the file did not exist. For ghc-6.8.x Cabal calls ghc-pkg list and parses the output to find the location of the package db files. Then it loads those files directly. For ghc-6.10.x Cabal calls ghc-pkg dump with --global and/or --user and parses the output. Duncan

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. Lars

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

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.
I'm using a wrapper script around ghc-pkg which sets the proper paths.
So to see if we're getting the same views I think we should add some debugging printing into this function:
Here's the gory details when running setup with -v3 and added debug: <snip> Reading installed packages... ("../../../release/bin/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 "========================" ["/usr/lib/ghc-6.8.3/package.conf","/home/lars/dev/mhailist/release/package.conf"] Just "/usr/lib/ghc-6.8.3/package.conf" Just "/home/lars/dev/mhailist/release/package.conf" Setup.hs: At least the following dependencies are missing: dlist >=0.2 It seems that despite calling the right thing and getting the right stuff it doesn't find it :( Lars
participants (3)
-
Duncan Coutts
-
Judah Jacobson
-
Lars Kotthoff