
#12395: Misleading GHCi errors when package is installed -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: new Priority: high | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #11536 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): I think the answer is, "You shouldn't use cabal install, full stop. But you *especially* shouldn't use it on code you are editing and recompiling." Here's what's happening: 1. When you cabal install the package, it gets added to the user package database. This means that if you run ghci without any flags, all of the modules from this package are available for import. 2. When you ghci Main.hs, it first looks to see if there's a local B.hs. There is none, so then it looks to see if any exposed packages in the databases its using (including the user one) have B. The one that cabal install'ed is there, so it uses that! And so now you have two versions of A in scope: one that came from the cabal install'ed package, and one that was locally interpreted by bytecode. I think GHC's error messages here could be a lot better. But that's what's happening. If you unregister the installed package (ghc-pkg unregister) you'll stop picking up the installed copy. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12395#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler