hashicorp/terraform · error
there is no package for %s %s cached in %s
Error message
there is no package for %s %s cached in %s
What it means
Raised when a provider version recorded in the lock file is not present in the local plugin cache directory (.terraform/providers). cacheDir.ProviderVersion(provider, version) returned nil, meaning the expected package is missing — typically because init was not run, was interrupted, the cache was cleared, or TF_PLUGIN_CACHE_DIR changed.
Source
Thrown at internal/command/meta_providers.go:402
reportError := func(thisErr error) {
errs[provider] = thisErr
// We'll populate a provider factory that just echoes our error
// again if called, which allows us to still report a helpful
// error even if it gets detected downstream somewhere from the
// caller using our partial result.
factories[provider] = providerFactoryError(thisErr)
}
if locks.ProviderIsOverridden(provider) {
// Overridden providers we'll handle with the other separate
// loops below, for dev overrides etc.
continue
}
version := lock.Version()
cached := cacheDir.ProviderVersion(provider, version)
if cached == nil {
reportError(fmt.Errorf(
"there is no package for %s %s cached in %s",
provider, version, cacheDir.BasePath(),
))
continue
}
// The cached package must match one of the checksums recorded in
// the lock file, if any.
if allowedHashes := lock.PreferredHashes(); len(allowedHashes) != 0 {
matched, err := cached.MatchesAnyHash(allowedHashes)
if err != nil {
reportError(fmt.Errorf(
"failed to verify checksum of %s %s package cached in in %s: %s",
provider, version, cacheDir.BasePath(), err,
))
continue
}
if !matched {
reportError(fmt.Errorf(View on GitHub (pinned to c9def3e214)
Solutions
- Run `terraform init` to download the locked provider versions into the cache.
- If TF_PLUGIN_CACHE_DIR is set, ensure that directory is populated or let init populate it.
- Verify TF_DATA_DIR points to the same cache used during init.
- Do not manually delete .terraform/providers; re-run init if you must.
Example fix
// before // terraform plan -> there is no package for registry.terraform.io/hashicorp/aws 4.0 cached in .terraform/providers // after terraform init # populates .terraform/providers from the lock file
Defensive patterns
Strategy: validation
Validate before calling
// Ensure providers are cached before plan/apply
func providersCached(lockPath, cacheDir string) (bool, error) {
locks, err := depsfile.LoadLocksFromFile(lockPath)
if err != nil { return false, err }
for p, l := range locks.AllProviders() {
if _, err := os.Stat(filepath.Join(cacheDir, p.String(), l.Version().String())); err != nil {
return false, nil
}
}
return true, nil
} Prevention
- Always run `terraform init` before plan/apply to populate the cache.
- Do not delete .terraform/providers manually; re-run init instead.
- Keep TF_DATA_DIR and TF_PLUGIN_CACHE_DIR consistent across runs.
- After cloning a repo, run init before any other terraform command.
When it happens
Trigger: providerFactoriesFromLocks: for a locked provider, cacheDir.ProviderVersion(provider, version)==nil. Triggered after deleting .terraform/providers, switching TF_PLUGIN_CACHE_DIR, copying a config without its .terraform cache, or a partial/failed init.
Common situations: Cloning a repo without running init; manually rm -rf .terraform; CI cache miss; switching the data dir (TF_DATA_DIR); a previous init was interrupted before all providers downloaded.
Related errors
- failed to read dependency lock file: %s
- failed to verify checksum of %s %s package cached in in %s:
- The -upgrade flag conflicts with -lockfile=readonly.
- Failed obtain the in-use version of provider %s (%q) used wi
- failed to create local modules directory: %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/976146fec085f412.
Report an issue: GitHub.