commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.98k stars 842 forks source link

stack repl confused by locally unpacked hackage lib #4049

Open robinp opened 6 years ago

robinp commented 6 years ago

Just asking if you know about this, or have a quick idea on fixing. Can provide details/repro later if not.

I have in stack.yaml (with various resolvers, for example 11.7)

packages:
- .
- gloss-rendering-1.11.1.1
- gloss-1.11.1.1

where the gloss-* dirs were unpacked with stack unpack.

The project builds and runs fine. But when attempting stack repl, it seems to confuse the source-based one with the library:

    * Couldn't match type `gloss-rendering-1.11.1.1:Graphics.Gloss.Internals.Data.Picture.Picture'
                     with `Picture'
      NB: `Picture' is defined at
            ...path..to...............\gloss-rendering-1.11.1.1\Graphics\Gloss\Internals\Data\Picture.hs:(63,1)-(124,43)
          `gloss-rendering-1.11.1.1:Graphics.Gloss.Internals.Data.Picture.Picture'
            is defined in `Graphics.Gloss.Internals.Data.Picture'
                in package `gloss-rendering-1.11.1.1'
      Expected type: Maybe Picture
        Actual type: Maybe
                       gloss-rendering-1.11.1.1:Graphics.Gloss.Internals.Data.Picture.Picture

Not sure for the reason. Thank you.

robinp commented 6 years ago

I tried to put the unpacked dirs outside of the source tree, but doesn't make a difference. It sounds like the original cabal package gets into ghci's package db too.

robinp commented 6 years ago

Found the issue: I also depend on gloss-juicy, which in turn depends on gloss. So while the unpacked gloss got passed to GHCi by source path (using -i<the unpacked path>), gloss-juicy is passed by its package-id, and naturally it's pkgdb file references gloss by package-id as well. This led to gloss being pulled in twice.

Workaround: unpack all dependencies used as well (here gloss-juicy).

It would be nice if stack gave a warning about this situation at least.

robinp commented 6 years ago

Actually this behavior gets cumbersome as more unpacked package deps are added. It would be nice to be able to control which of those get expanded by source for GHCi, and which keep to get passed by package id.