{"record":{"id":"8587b5693f174563","repo":"hashicorp/terraform","slug":"failed-to-refresh-module-manifest-w","errorCode":null,"errorMessage":"Failed to refresh module manifest: %w","messagePattern":"Failed to refresh module manifest: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/modules.go","lineNumber":138,"sourceCode":"\tmanifestWithRef := resolver.Resolve(config)\n\n\t// Render the new manifest with references\n\treturn view.Display(*manifestWithRef)\n}\n\n// internalManifest will use the configuration loader to refresh and load the\n// internal manifest.\nfunc (c *ModulesCommand) internalManifest() (modsdir.Manifest, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\n\tloader, err := c.initConfigLoader()\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to initialize config loader: %w\", err))\n\t\treturn nil, diags\n\t}\n\n\tif err = loader.RefreshModules(); err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to refresh module manifest: %w\", err))\n\t\treturn nil, diags\n\t}\n\n\treturn loader.ModuleManifest(), diags\n}\n\nconst modulesCommandHelp = `\nUsage: terraform [global options] modules [options]\n\n  Prints out a list of all declared Terraform modules and their resolved versions\n  in a Terraform working directory.\n\nOptions:\n\n  -json               If specified, output declared Terraform modules and\n                      their resolved versions in a machine-readable format.\n\n  -var 'foo=bar'      Set a value for one of the input variables in the root","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/modules.go#L120-L156","documentation":"Wrapped error from ModulesCommand.internalManifest when loader.RefreshModules() fails. RefreshModules downloads/updates the module manifest entries (the records describing locally-installed child modules). Failure means Terraform could not reconcile the manifest on disk with the registry, preventing the modules command from listing resolved versions.","triggerScenarios":"Running 'terraform modules' when RefreshModules errors — typically a registry/network failure fetching module metadata, a corrupt modules manifest file (.terraform/modules/modules.json), or a filesystem write error updating the manifest.","commonSituations":"Air-gapped environment without registry access; a private module registry token expired or is misconfigured; the .terraform/modules directory was partially deleted; disk full preventing manifest write.","solutions":["Check network connectivity and registry/TF_TOKEN_* credentials for the module source hostname.","Delete .terraform/modules and re-run 'terraform get' / 'terraform init' to rebuild the manifest.","Ensure the working directory and TF_DATA_DIR are writable with adequate free disk space.","Use -plugin-dir or vendored module paths to avoid registry access in air-gapped setups."],"exampleFix":"// before: corrupt/partial module manifest\n// after: rebuild module install\n$ rm -rf .terraform/modules\n$ terraform init\n$ terraform modules","handlingStrategy":"validation","validationCode":"// Pre-flight: verify registry reachability and module manifest integrity\npackage main\n\nfunc preflightModules(dataDir string) error {\n\tmanifest := filepath.Join(dataDir, \"modules\", \"modules.json\")\n\tif info, err := os.Stat(manifest); err == nil && info.Size() == 0 {\n\t\treturn fmt.Errorf(\"module manifest %s is empty; run 'terraform init'\", manifest)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run 'terraform init' (which calls RefreshModules) before 'terraform modules'.","Provide registry credentials via TF_TOKEN_* for private registries.","Vendor modules locally (-plugin-dir) in air-gapped environments."],"tags":["modules","registry","manifest","network","initialization"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}