{"record":{"id":"976146fec085f412","repo":"hashicorp/terraform","slug":"there-is-no-package-for-s-s-cached-in-s","errorCode":null,"errorMessage":"there is no package for %s %s cached in %s","messagePattern":"there is no package for (.+?) (.+?) cached in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_providers.go","lineNumber":402,"sourceCode":"\t\treportError := func(thisErr error) {\n\t\t\terrs[provider] = thisErr\n\t\t\t// We'll populate a provider factory that just echoes our error\n\t\t\t// again if called, which allows us to still report a helpful\n\t\t\t// error even if it gets detected downstream somewhere from the\n\t\t\t// caller using our partial result.\n\t\t\tfactories[provider] = providerFactoryError(thisErr)\n\t\t}\n\n\t\tif locks.ProviderIsOverridden(provider) {\n\t\t\t// Overridden providers we'll handle with the other separate\n\t\t\t// loops below, for dev overrides etc.\n\t\t\tcontinue\n\t\t}\n\n\t\tversion := lock.Version()\n\t\tcached := cacheDir.ProviderVersion(provider, version)\n\t\tif cached == nil {\n\t\t\treportError(fmt.Errorf(\n\t\t\t\t\"there is no package for %s %s cached in %s\",\n\t\t\t\tprovider, version, cacheDir.BasePath(),\n\t\t\t))\n\t\t\tcontinue\n\t\t}\n\t\t// The cached package must match one of the checksums recorded in\n\t\t// the lock file, if any.\n\t\tif allowedHashes := lock.PreferredHashes(); len(allowedHashes) != 0 {\n\t\t\tmatched, err := cached.MatchesAnyHash(allowedHashes)\n\t\t\tif err != nil {\n\t\t\t\treportError(fmt.Errorf(\n\t\t\t\t\t\"failed to verify checksum of %s %s package cached in in %s: %s\",\n\t\t\t\t\tprovider, version, cacheDir.BasePath(), err,\n\t\t\t\t))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !matched {\n\t\t\t\treportError(fmt.Errorf(","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_providers.go#L384-L420","documentation":"In Meta.providerFactoriesFromLocks, for each provider recorded in the lock file the installer looks up cacheDir.ProviderVersion(provider, version). If that returns nil (no matching package directory in the local plugin cache), reportError records this message and installs a stub factory that will re-emit the error if invoked. The lock file promises a version that is not present on disk.","triggerScenarios":"providerFactoriesFromLocks iterates providerLocks; for a provider not overridden and not dev-overridden, cacheDir.ProviderVersion(provider, lock.Version()) returns nil. This happens when the lock file lists a version but the .terraform/providers cache lacks the unpacked package.","commonSituations":"Fresh clone without terraform init; CI runner with a cold or cleared plugin cache; cache directory moved or on a different TF_PLUGIN_CACHE_DIR; package deleted manually or by a cleanup job; switching machines after committing .terraform.lock.hcl but not the cache.","solutions":["Run terraform init to download and unpack the locked provider versions into the cache.","Verify TF_PLUGIN_CACHE_DIR points at the directory that actually holds the packages, or unset it to use the default .terraform/providers.","Check that the cache directory is writable and not on a read-only or ephemeral mount.","Confirm the lock file version still exists upstream if init still fails, then terraform init -upgrade if the version was withdrawn."],"exampleFix":"# before: cache missing for locked version\n# after\nterraform init","handlingStrategy":"fallback","validationCode":"// Check the cache before invoking commands that need providers.\nfor p, v := range lockedVersions {\n    if cacheDir.ProviderVersion(p, v) == nil {\n        return fmt.Errorf(\"run 'terraform init' to cache %s %s\", p, v)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run terraform init after cloning or clearing .terraform.","Pin TF_PLUGIN_CACHE_DIR to a stable, writable, local directory.","In CI, cache the .terraform/providers directory between runs."],"tags":["terraform","provider","cache","init","lock-file"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}