[GHC] #6133: ghc dies when I use a package.conf in $GHC_PACKAGE_PATH

GHC cvs-ghc at haskell.org
Tue May 29 16:24:06 CEST 2012


#6133: ghc dies when I use a package.conf in $GHC_PACKAGE_PATH
--------------------------------+-------------------------------------------
 Reporter:  gfxmonk             |          Owner:                  
     Type:  bug                 |         Status:  new             
 Priority:  normal              |      Component:  ghc-pkg         
  Version:  7.0.4               |       Keywords:                  
       Os:  Unknown/Multiple    |   Architecture:  Unknown/Multiple
  Failure:  Compile-time crash  |       Testcase:                  
Blockedby:                      |       Blocking:                  
  Related:                      |  
--------------------------------+-------------------------------------------

Comment(by duncan):

 So yes, the real problem here is the poor error message.

 When you use cabal register --gen-pkg-config= you make a package
 registration file. This is not a ghc package database, it is the input for
 an element of such a database. You insert the package registration info
 into an existing ghc package database using ghc-pkg register.

 So what you really want to do is:
 {{{
 cabal register --gen-pkg-config="$BUILDDIR/foo.pkg" --builddir="$BUILDDIR"
 ghc-pkg init $BUILDDIR/package.conf
 ghc-pkg register --package-conf=$BUILDDIR/package.conf foo.pkg

 ghc / ghci -package-conf $BUILDDIR/package.conf ...
 }}}

 The thing that is used with `ghc -package-conf` or equivalently with the
 `GHC_PACKAGE_PATH` var is a ghc-pkg database.

 The format used by ghc-pkg register, ghc-pkg describe and cabal register
 is the human readable one, and is described by the Cabal spec. The ghc-pkg
 database format is a ghc specififc implementation detail and is not
 intended for people to look at.

 If you're interested, the ghc-pkg databases come in two internal formats
 (though you never need to mess with their internal details). One is as a
 single file using Haskell read/show format. The other is as a directory
 containing one file per package plus a binary cache.

 So the reason you get your error is that ghc looks at the file you've
 given, determines that it's not a directory but an old-style single file
 db, and tries to read it using `read` which fails because what you've
 actually got in the file is the package registration info in the format
 standardised by Cabal.

 So ghc should be using `reads` rather than `read` and then it can emit a
 specific error message to say that the given file is not in the format
 created by ghc-pkg.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6133#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list