Skip to content
Latchkey

Packer "references unknown source" in a build block in CI

A build block links to sources by name. If the sources = [...] list names a source that no source block defines, Packer cannot wire the build and fails at load.

What this error means

packer validate or build fails with "build references unknown source X" because the name in the build block does not match a declared source.

packer
Error: Unknown source amazon-ebs.ubunto

  on build.pkr.hcl line 20, in build:
  20:   sources = ["source.amazon-ebs.ubunto"]

Known: [source.amazon-ebs.ubuntu]

Common causes

A typo in the source reference

The sources list names amazon-ebs.ubunto while the source block is amazon-ebs.ubuntu, so no match is found.

The source block is in a file not loaded

The source is defined in a file outside the directory Packer builds, so it is not part of the loaded config.

How to fix it

Match the source name exactly

  1. Read the "Known:" list Packer prints.
  2. Correct the sources entry to match the declared source.
  3. Run packer validate to confirm the build links.
build.pkr.hcl
build {
  sources = ["source.amazon-ebs.ubuntu"]
}

Build the directory that holds all files

Point Packer at the directory containing every source and build file so all blocks load together.

Terminal
packer build .

How to prevent it

  • Keep source and build blocks in the same loaded directory.
  • Copy source names to avoid typos in the build block.
  • Run packer validate before build to catch broken links.

Frequently asked questions

What causes ""references unknown source""?
The sources list names amazon-ebs.ubunto while the source block is amazon-ebs.ubuntu, so no match is found.
How do I fix "references unknown source"?
Match the source name exactly

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card