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."
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
- Read which hidden package GHC names.
- Add it to
build-dependsfor the affected component. - Rebuild so the package is exposed.
library
build-depends: base, containers
exposed-modules: LibConstrain the version if needed
If multiple versions exist, add a bound so the build picks the intended one.
build-depends: containers >=0.6 && <0.7How 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.