{"record":{"id":"c501f00f025d424b","repo":"hashicorp/terraform","slug":"failed-to-read-module-manifest-s","errorCode":null,"errorMessage":"failed to read module manifest: %s","messagePattern":"failed to read module manifest: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/configload/loader.go","lineNumber":92,"sourceCode":"\n\tparser := configs.NewParser(fs)\n\treg := registry.NewClient(config.Services, nil)\n\n\tret := &Loader{\n\t\tparser: parser,\n\t\tmodules: moduleMgr{\n\t\t\tFS:         afero.Afero{Fs: fs},\n\t\t\tCanInstall: true,\n\t\t\tDir:        config.ModulesDir,\n\t\t\tServices:   config.Services,\n\t\t\tRegistry:   reg,\n\t\t},\n\t\tparserOpts: make([]configs.Option, 0),\n\t}\n\n\terr := ret.modules.readModuleManifestSnapshot()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read module manifest: %s\", err)\n\t}\n\n\tif config.IncludeQueryFiles {\n\t\tret.parserOpts = append(ret.parserOpts, configs.MatchQueryFiles())\n\t}\n\n\tif config.IncludeStateMigrateFiles {\n\t\tret.parserOpts = append(ret.parserOpts, configs.MatchStateMigrateFiles())\n\t}\n\n\treturn ret, nil\n}\n\n// ModulesDir returns the path to the directory where the loader will look for\n// the local cache of remote module packages.\nfunc (l *Loader) ModulesDir() string {\n\treturn l.modules.Dir\n}","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/configload/loader.go#L74-L110","documentation":"Raised by NewLoader when modules.readModuleManifestSnapshot() fails to read or parse the module manifest (.terraform/modules/modules.json). The manifest records which modules are installed and where; if it is missing, unreadable, or contains invalid JSON, the loader cannot build the module install graph. Hit at the very start of any command that needs a Loader (line 90-92).","triggerScenarios":"A corrupted or half-written modules.json (interrupted `terraform get`/`init`), a manually edited manifest with invalid JSON, permission errors reading .terraform/modules/, or an empty/garbage file from a failed download.","commonSituations":"Interrupted init, disk-full during module download, syncing .terraform across machines/OSes, git operations that touched .terraform/modules, stale manifest after switching branches.","solutions":["Wipe the local module cache and reinit: `rm -rf .terraform && terraform init`.","If only the manifest is bad, delete `.terraform/modules/modules.json` and run `terraform get -update` then `terraform init`.","Check filesystem permissions on the .terraform directory."],"exampleFix":"// before: NewLoader returns \"failed to read module manifest: ...\"\n\n$ rm -rf .terraform && terraform init","handlingStrategy":"validation","validationCode":"// Treat .terraform/ as disposable. In CI, never cache .terraform/modules across\n// jobs; run `terraform init` from a clean checkout to guarantee a valid manifest.\n// If you must cache, verify modules.json parses as JSON before reuse.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't commit or sync .terraform/ across machines.","Treat .terraform/ as always-reproducible via terraform init.","Interrupt init cleanly and re-run if it dies mid-download."],"tags":["config","modules","loader","init"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}