{"record":{"id":"f575a9212ca50aa1","repo":"hashicorp/terraform","slug":"error-validating-destination-directory-s","errorCode":null,"errorMessage":"Error validating destination directory: %s","messagePattern":"Error validating destination directory: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/init_run.go","lineNumber":69,"sourceCode":"\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 {\n\t\t\tdiags = diags.Append(errors.New(strings.TrimSpace(errInitCopyNotEmpty)))\n\t\t\tview.Diagnostics(diags)\n\t\t\treturn 1\n\t\t}\n\n\t\tview.LogConfigurationCopyingStart(src)\n\n\t\thooks := uiModuleInstallHooks{\n\t\t\tUi:             c.Ui,\n\t\t\tShowLocalPaths: false, // since they are in a weird location for init\n\t\t\tView:           view,\n\t\t}\n\n\t\tctx, span := tracer.Start(ctx, \"-from-module=...\", trace.WithAttributes(","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/init_run.go#L51-L87","documentation":"Thrown when -from-module is set and configs.IsEmptyDir(path, TestsDirectory) returns an error while validating the destination directory before copying the source module. The %s is the underlying error from IsEmptyDir.","triggerScenarios":"Running `terraform init -from-module=...` when the destination directory cannot be inspected (permission denied, I/O error, broken symlink) or when IsEmptyDir encounters a read failure on a subdir.","commonSituations":"Destination directory not readable; path collision; running from a directory with permission issues; filesystem errors during traversal.","solutions":["Check read permissions on the destination directory: `ls -la <path>`.","Ensure the destination exists and is a valid, traversable directory.","Retry from a clean, writable empty directory."],"exampleFix":"$ mkdir -p ./mod && chmod u+rx ./mod && terraform init -from-module=github.com/x/y ./mod","handlingStrategy":"validation","validationCode":"// Verify destination dir is readable and empty before -from-module.\nfunc readableAndEmpty(p string) error {\n    e, err := configs.IsEmptyDir(p, \"\")\n    if err != nil { return err }\n    if !e { return errors.New(\"not empty\") }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Init -from-module into a fresh, empty, writable directory.","Confirm read permissions on the destination before running.","Avoid nested broken symlinks in the destination tree."],"tags":["terraform-init","from-module","filesystem","validation"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}