Skip to content
Latchkey

Haskell cabal "is a member of the hidden package" / build-depends in CI

GHC found the module you imported but its package is hidden because it is not declared in build-depends. The package is available, but cabal only exposes packages you list, so the import is rejected.

What this error means

A build fails with "Could not load module 'X' ... It is a member of the hidden package 'pkg-1.2'. Perhaps you need to add 'pkg' to the build-depends in your .cabal file."

Haskell
src/Lib.hs:4:1: error:
    Could not load module 'Data.Map'
    It is a member of the hidden package 'containers-0.6.7'.
    Perhaps you need to add 'containers' to the build-depends in your .cabal file.

Common causes

The package is installed but not in build-depends

cabal hides every package you do not declare; importing from one not listed in build-depends fails even though it is present.

A transitive package used directly

Code imports a module from a package that is only a transitive dependency, not a direct one in build-depends.

How to fix it

Add the package to build-depends

  1. Read which hidden package GHC names.
  2. Add it to build-depends for the affected component.
  3. Rebuild so the package is exposed.
app.cabal
library
  build-depends: base, containers
  exposed-modules: Lib

Constrain the version if needed

If multiple versions exist, add a bound so the build picks the intended one.

app.cabal
build-depends: containers >=0.6 && <0.7

How to prevent it

  • Declare every package you import directly in build-depends.
  • Do not rely on transitive packages being exposed.
  • Build from a clean checkout so hidden-package errors surface.

Frequently asked questions

What causes ""is a member of the hidden package""?
cabal hides every package you do not declare; importing from one not listed in build-depends fails even though it is present.
How do I fix "is a member of the hidden package"?
Add the package to build-depends

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card