ghc-pkg bug? possible cabal workaround?

Simon Marlow simonmarhaskell at
Fri Aug 11 06:38:07 EDT 2006

Isaac Jones wrote:
> Heya Simon.
> I've noticed that in ghc 6.4.2, ghc-pkg doesn't create the file (or
> maybe just the directory) when trying to register a package:
> rm  -r ~/.ghc/i386-linux-6.4.2
> /usr/bin/ghc-pkg update .installed-pkg-config --user
> ghc-pkg.bin: /home/ijones/.ghc/i386-linux-6.4.2/package.conf: getPermissions: does not exist (No such file or directory)
> Cabal could try to create the file & directory w/ something like what
> you have in ghc-pkg plus createDirectoryIfMissing, but I'm a bit
> nervous of using the System.Info stuff since I know it's pretty new.
> I'd like to keep cabal working w/ ghc 6.2.  We can probably solve this
> by creating a ghc 6.3 version of
> Distribution.GHCPackageConfig.maybeCreateLocalPackageConfig and
> calling it around line 149 of Distribution.Simple.Register.
> Here's how ghc-pkg generates the filename:
>   appdir <- getAppUserDataDirectory "ghc"
>   let
> 	subdir = targetARCH ++ '-':targetOS ++ '-':version
> 	archdir   = appdir `joinFileName` subdir
> 	user_conf = archdir `joinFileName` "package.conf"
>   user_exists <- doesFileExist user_conf
> I'm not sure where the bug is in ghc-pkg; it's not obvious to me, but
> it'll probably be obvious to you.  Should we implement a cabal
> workaround?  Has anyone complained about this?

This is strange.  If you look a bit further down in ghc-pkg's Main.hs,
there's this:

   when (not user_exists && user_conf `elem` final_stack) $ do
	putStrLn ("Creating user package database in " ++ user_conf)
	createDirectoryIfMissing True archdir
	writeFile user_conf emptyPackageConfig

So it is supposed to create the user package database if it doesn't
exist, directories and all.  Something has gone wrong here, I'm not sure
what.  Maybe try strace to see what ghc-pkg is doing?


More information about the cabal-devel mailing list