darcs

Message5203

Author duncan.coutts
Recipients beschmi, dagit, daveroundy, duncan, duncan.coutts, tommy
Date 2008-07-10.23:21:00
Issue Issue941 Checking for modules provided by packages fails with multiple providers
Content
On Tue, 2008-07-08 at 21:26 +0000, David Roundy wrote:
> David Roundy <daveroundy@gmail.com> added the comment:
> 
> On Wed, Jul 2, 2008 at 6:51 AM, Duncan <bugs@darcs.net> wrote:
> >
> > Duncan <duncan@haskell.org> added the comment:
> >
> > The key bit is:
> >
> > configure:5165: checking for module Control.Monad.Error
> > configure:5186: ghc  -threaded -package regex-compat -package HTTP -package
> > QuickCheck  -o conftest conftest.hs
> >
> > conftest.hs:1:0:
> >    Failed to load interface for `Control.Monad.Error':
> >      it was found in multiple packages: mtl-tf-0.1 mtl-1.1.0.0
> > configure:5189: $? = 1
> > configure: failed program was:
> > import Control.Monad.Error
> > main = seq (strMsg "foo" :: String) (putStr "Hello world.\n")
> >
> > -- this file generated by TRY-COMPILE-GHC
> > end of failed program.
> > configure:5222: ghc  -threaded -package regex-compat -package HTTP -package
> > QuickCheck -package mtl  -o conftest conftest.hs
> >
> > conftest.hs:1:0:
> >    Failed to load interface for `Control.Monad.Error':
> >      it was found in multiple packages: mtl-tf-0.1 mtl-1.1.0.0
> > configure:5225: $? = 1
> > configure: failed program was:
> > import Control.Monad.Error
> > main = seq (strMsg "foo" :: String) (putStr "Hello world.\n")
> >
> > -- this file generated by TRY-COMPILE-GHC
> > end of failed program.
> > configure:5238: result: no; and neither in package mtl
> > configure:5240: error: Cannot find Control.Monad.Error; try installing package mtl?
> >
> > So when ghc/ghci finds the module in multiple packages then it complains. The
> > solution is to look in a specific package and not in all packages. This can be
> > done by hiding all the packages you're not interested in with the
> > -hide-all-packages ghc flag. eg:
> 
> I'm confused.  We did specify that we wanted to use the package mtl,
> why do we also have to tell ghc not to use any packages at all? Is the
> real problem that both packages start with mtl? To me, that sounds
> more reasonable than adding --hide-all-packages, but I'm not really
> clear as to what the effect of --hide-all-packages is.  ghc doesn't
> normally look in any packages that aren't specified on the
> command-line (although ghci does).

You're right it's odd. I would have expected it to only look in the
packages given by -package flags (+ hard-wired packages like base) when
not in --make or ghci mode. However that does not seem to be the current
ghc behaviour. It seems to look in all packages for modules for
compiling but then only the given ones for linking (nice inconsistency).

So to really make it only look in the given packages it looks like
-hide-all-packages is necessary. Of course that also means having to
explicitly add -package base since -hide-all-packages really means what
it says (it otherwise cannot find the Prelude).

Duncan
History
Date User Action Args
2008-07-10 23:21:00duncan.couttscreate
2008-07-10 23:21:05duncan.couttslinkissue941 messages
2008-07-10 23:21:05duncan.couttssetrecipients: + duncan.coutts