Skip to content

Local package dependency ghc-pkg: cannot find package #5147

@lehins

Description

@lehins

General summary/comments (optional)

When one package bar has another local package foo as a dependency (either in packages or extrs-deps), rebuilding separately package foo will cause package bar erroring during build with:

ghc-pkg: cannot find package foo

Steps to reproduce

Here are two sample projects that replicate the problem: https://github.com/lehins/bugs/tree/master/haskell/stack-ghc-pkg-cannot-find-package

$ git clone https://github.com/lehins/bugs
$ cd bugs/haskell/stack-ghc-pkg-cannot-find-package
$ cd bar
$ stack build
$ cd ../foo
$ stack build
$ cd ../bar
$ stack build --force-dirty
...
Standard error:

ghc-pkg: cannot find package foo

Not 100% sure, but I think it is important that foo and bar are both on a different snapshots, but with the same ghc, eg. one is lts-14.4 another lts-14.20.

Expected

Regardless of the order packages build successfully.

Actual

Here is also a sample log with --verbose: https://github.com/lehins/bugs/blob/master/haskell/stack-ghc-pkg-cannot-find-package/output.log

Stack version

Stack version used was the latest, but I've been observing this issue since 2.0, but was unable to reproduce it reliably on small set of packages

$ stack --version
Version 2.2.0, Git revision c3c33b61a4d5c286a6718550d285305270ba4bf0 PRE-RELEASE x86_64 hpack-0.31.2

Method of installation

  • stack upgrade --git

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions