{"record":{"id":"c77e9e31837726a0","repo":"opentofu/opentofu","slug":"failed-to-create-directory-s-w","errorCode":null,"errorMessage":"failed to create directory %s: %w","messagePattern":"failed to create directory (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getmodules/getter.go","lineNumber":185,"sourceCode":"\t// that need before we introduce that complexity.\n\t//\n\t// NOTE WELL: [getter.Client.Get] modifies internal state inside each of the\n\t// getters passed in [getter.Client.Getters] before calling into them, so\n\t// it is _not_ safe to reuse the same getter instances across multiple\n\t// concurrent calls. If we want to make this work concurrently in future\n\t// then we'll need to instead instantiate the getters on demand for each\n\t// request.\n\tg.previousInstallsMu.Lock()\n\tdefer g.previousInstallsMu.Unlock()\n\tif g.previousInstalls == nil {\n\t\tg.previousInstalls = make(map[string]string)\n\t}\n\n\tif prevDir, exists := g.previousInstalls[packageAddr]; exists {\n\t\tlog.Printf(\"[TRACE] getmodules: copying previous install of %q from %s to %s\", packageAddr, prevDir, instPath)\n\t\terr := os.Mkdir(instPath, os.ModePerm)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create directory %s: %w\", instPath, err)\n\t\t}\n\t\terr = copy.CopyDir(instPath, prevDir)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy from %s to %s: %w\", prevDir, instPath, err)\n\t\t}\n\t} else {\n\t\tlog.Printf(\"[TRACE] getmodules: fetching %q to %q\", packageAddr, instPath)\n\t\tclient := getter.Client{\n\t\t\tSrc: packageAddr,\n\t\t\tDst: instPath,\n\t\t\tPwd: instPath,\n\n\t\t\tMode: getter.ClientModeDir,\n\n\t\t\tDetectors:     goGetterNoDetectors, // our caller should've already done detection\n\t\t\tDecompressors: goGetterDecompressors,\n\t\t\tGetters:       g.getters,\n\t\t\tCtx:           ctx,","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/getmodules/getter.go#L167-L203","documentation":"Error \"failed to create directory %s: %w\" thrown in opentofu/opentofu.","triggerScenarios":"Thrown at internal/getmodules/getter.go:185 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}