stack "Error parsing targets" in CI
stack could not interpret a target you asked it to build or test. The package, component, or path on the command line does not match anything in the project.
What this error means
stack build/test exits with Error parsing targets: followed by the unrecognized target. It is deterministic and tied to your command and stack.yaml.
stack
Error parsing targets: Unknown local package: myapp-tests
The valid targets are:
myapp
myapp:test:myapp-testCommon causes
Wrong package or component name
The target name does not match a package in stack.yaml or a component in the cabal file (a typo or wrong suffix).
Package not in stack.yaml packages
A package directory is not listed under packages:, so stack does not know about it.
How to fix it
Use a valid target name
List what stack recognizes, then build that.
CI step
stack ide targets
stack test myapp:test:myapp-testRegister the package in stack.yaml
- Add the package directory under
packages:. - Confirm the cabal file names the component you target.
- Re-run after editing stack.yaml.
How to prevent it
- Reference exact component names in CI.
- Keep stack.yaml packages list complete.
- Use
stack ide targetsto discover valid names.
Related guides
cabal "encountered missing dependencies" in CIFix cabal "encountered missing or private dependencies" in CI - the solver cannot satisfy version bounds for…
GHC "Could not find module" in CIFix Haskell GHC "Could not find module" in stack/cabal CI - a module is not in the package, not a dependency,…
GHC out of memory / killed in CIFix Haskell GHC "out of memory" or OOM-killed compilation in CI - large modules and heavy optimization exhaus…