{"record":{"id":"21db05142cc58f5a","repo":"github/copilot-sdk","slug":"failed-to-create-temp-dir-w","errorCode":null,"errorMessage":"failed to create temp dir: %w","messagePattern":"failed to create temp dir: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":436,"sourceCode":"\t\truntimeHash, err := sha256FileFromCompressed(runtimeArtifactPath)\n\t\tif err != nil {\n\t\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to hash existing runtime.node: %w\", err)\n\t\t}\n\t\twrapperHash, err := sha256FileFromCompressed(wrapperArtifactPath)\n\t\tif err != nil {\n\t\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to hash existing runtime wrapper: %w\", err)\n\t\t}\n\t\tassetsHash, err := sha256File(assetsArtifactPath)\n\t\tif err != nil {\n\t\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to hash existing runtime assets: %w\", err)\n\t\t}\n\t\treturn bundleArtifacts{outputPath, binaryHash, runtimeArtifactPath, runtimeHash, wrapperArtifactPath, wrapperHash, assetsArtifactPath, assetsHash}, nil\n\t}\n\n\t// Create temp directory for download\n\ttempDir, err := os.MkdirTemp(\"\", \"copilot-bundler-*\")\n\tif err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to create temp dir: %w\", err)\n\t}\n\tdefer os.RemoveAll(tempDir)\n\n\tbinaryPath, tarballPath, err := downloadCLIBinary(info.runtimePlatform, info.binaryName, cliVersion, tempDir)\n\tif err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to download CLI binary: %w\", err)\n\t}\n\n\tif outputDir != \".\" {\n\t\tif err := os.MkdirAll(outputDir, 0755); err != nil {\n\t\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to create output directory: %w\", err)\n\t\t}\n\t}\n\tif includeLicense {\n\t\tif err := extractCLILicense(tarballPath, outputPath); err != nil {\n\t\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to extract CLI license: %w\", err)\n\t\t}\n\t}","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L418-L454","documentation":"buildBundle could not create the temporary working directory via os.MkdirTemp(\"\", \"copilot-bundler-*\") before downloading artifacts. This is an environment-level failure: os.MkdirTemp fails only when the system temp location is unusable, so this almost always indicates a machine/container problem rather than a code bug.","triggerScenarios":"os.MkdirTemp fails — TMPDIR points to a nonexistent or read-only directory, the temp filesystem is full, or permissions/SELinux block directory creation in the temp location.","commonSituations":"Containers with read-only /tmp; TMPDIR set to a path that doesn't exist; disk-full on the temp volume; restrictive security policies (SELinux/AppArmor) blocking temp dir creation in CI.","solutions":["Check TMPDIR points to an existing writable directory, or unset it to use the default.","Free disk space on the temp filesystem.","Ensure /tmp (or $TMPDIR) is writable by the running user.","Check SELinux/AppArmor denials if on a locked-down host.","Mount a writable tmpfs in containerized CI if /tmp is read-only."],"exampleFix":"// before\ntempDir, err := os.MkdirTemp(\"\", \"copilot-bundler-*\")\nif err != nil {\n\treturn bundleArtifacts{}, fmt.Errorf(\"failed to create temp dir: %w\", err)\n}\n// after\nbase := os.TempDir()\nif st, err := os.Stat(base); err != nil || !st.IsDir() {\n\treturn bundleArtifacts{}, fmt.Errorf(\"temp dir %s unusable (set TMPDIR to a writable dir): %w\", base, err)\n}\ntempDir, err := os.MkdirTemp(\"\", \"copilot-bundler-*\")\nif err != nil {\n\treturn bundleArtifacts{}, fmt.Errorf(\"failed to create temp dir: %w\", err)\n}","handlingStrategy":"validation","validationCode":"base := os.TempDir()\nif st, err := os.Stat(base); err != nil || !st.IsDir() {\n\treturn fmt.Errorf(\"TMPDIR %s is not a usable directory\", base)\n}\nif err := unix.Access(base, unix.W_OK); err != nil {\n\treturn fmt.Errorf(\"TMPDIR %s is not writable\", base)\n}","typeGuard":null,"tryCatchPattern":"artifacts, err := buildBundle(...)\nif err != nil && strings.Contains(err.Error(), \"failed to create temp dir\") {\n\t// fix TMPDIR / disk space in the environment, then rerun\n\tos.Setenv(\"TMPDIR\", \"/var/tmp\")\n}","preventionTips":["Verify TMPDIR points to an existing writable directory in CI containers.","Monitor free space on the temp filesystem.","Mount writable tmpfs when /tmp is read-only.","Check SELinux/AppArmor policies on locked-down hosts."],"tags":["filesystem","temp-dir","environment"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}