Skip to content
Latchkey

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-test

Common 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-test

Register the package in stack.yaml

  1. Add the package directory under packages:.
  2. Confirm the cabal file names the component you target.
  3. 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 targets to discover valid names.

Frequently asked questions

What causes ""Error parsing targets""?
The target name does not match a package in stack.yaml or a component in the cabal file (a typo or wrong suffix).
How do I fix "Error parsing targets"?
List what stack recognizes, then build that.

Related guides

References

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