{"record":{"id":"84fb93139a1637d1","repo":"hashicorp/terraform","slug":"error-saving-plugin-dir-to-workspace-directory","errorCode":null,"errorMessage":"Error saving -plugin-dir to workspace directory: %s","messagePattern":"Error saving -plugin-dir to workspace directory: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/init_run.go","lineNumber":55,"sourceCode":"\tc.Meta.input = initArgs.InputEnabled\n\tc.Meta.targetFlags = initArgs.TargetFlags\n\tc.Meta.compactWarnings = initArgs.CompactWarnings\n\n\t// Copying the state only happens during backend migration, so setting\n\t// -force-copy implies -migrate-state\n\tif c.forceInitCopy {\n\t\tc.migrateState = true\n\t}\n\n\tif len(initArgs.PluginPath) > 0 {\n\t\tc.pluginPath = initArgs.PluginPath\n\t}\n\n\t// Get the working directory\n\tpath := c.Meta.WorkingDir.RootModuleDir()\n\n\tif err := c.storePluginPath(c.pluginPath); err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error saving -plugin-dir to workspace directory: %s\", err))\n\t\tview.Diagnostics(diags)\n\t\treturn 1\n\t}\n\n\t// Initialization can be aborted by interruption signals\n\tctx, done := c.InterruptibleContext(c.CommandContext())\n\tdefer done()\n\n\tif initArgs.FromModule != \"\" {\n\t\tsrc := initArgs.FromModule\n\n\t\tempty, err := configs.IsEmptyDir(path, initArgs.TestsDirectory)\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Error validating destination directory: %s\", err))\n\t\t\tview.Diagnostics(diags)\n\t\t\treturn 1\n\t\t}\n\t\tif !empty {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/init_run.go#L37-L73","documentation":"Thrown by init_run.go when c.storePluginPath(c.pluginPath) fails while persisting the -plugin-dir flags to the workspace's .terraformrc/plugin-paths file. The %s is the underlying error.","triggerScenarios":"Running `terraform init -plugin-dir=...` (or with TF_PLUGIN_PATHS) when the workspace directory is read-only, full, or the plugin-paths metadata file cannot be written.","commonSituations":"Read-only checkout in CI; full disk; permissions on the .terraform directory; running init against a module path the user cannot write to.","solutions":["Verify write permissions on the working directory and .terraform/: `ls -ld . .terraform`.","Free disk space if the volume is full.","Ensure the working directory is writable; avoid running init inside a read-only mount."],"exampleFix":"$ chmod u+w . && terraform init -plugin-dir=/opt/plugins","handlingStrategy":"validation","validationCode":"// Verify the workspace dir is writable before init with -plugin-dir.\nfunc writableDir(p string) bool {\n    return os.WriteFile(filepath.Join(p, \".w\"), []byte(\"x\"), 0644) == nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run init in a writable working directory.","Check disk space before init.","Avoid read-only checkouts in CI for the init step."],"tags":["terraform-init","plugin-dir","filesystem","permissions","write"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}