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

  1. Run `terraform init` to download the locked provider versions into the cache.
  2. If TF_PLUGIN_CACHE_DIR is set, ensure that directory is populated or let init populate it.
  3. Verify TF_DATA_DIR points to the same cache used during init.
  4. 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

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


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/976146fec085f412. Report an issue: GitHub.