{"record":{"id":"3d6fc787e2f0f0de","repo":"dgraph-io/dgraph","slug":"error-while-creating-temporary-directory-s","errorCode":null,"errorMessage":"error while creating temporary directory: %s","messagePattern":"error while creating temporary directory: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/debuginfo/run.go","lineNumber":99,"sourceCode":"\tflags.StringVarP(&debugInfoCmd.alphaAddr, \"alpha\", \"a\", \"localhost:8080\",\n\t\t\"Address of running dgraph alpha.\")\n\tflags.StringVarP(&debugInfoCmd.zeroAddr, \"zero\", \"z\", \"\", \"Address of running dgraph zero.\")\n\tflags.StringVarP(&debugInfoCmd.directory, \"directory\", \"d\", \"\",\n\t\t\"Directory to write the debug info into.\")\n\tflags.BoolVarP(&debugInfoCmd.archive, \"archive\", \"x\", true,\n\t\t\"Whether to archive the generated report\")\n\tflags.Uint32VarP(&debugInfoCmd.seconds, \"seconds\", \"s\", 30,\n\t\t\"Duration for time-based metric collection.\")\n\tflags.StringSliceVarP(&debugInfoCmd.metricTypes, \"metrics\", \"m\", metricList,\n\t\t\"List of metrics & profile to dump in the report.\")\n\n}\n\nfunc collectDebugInfo() (err error) {\n\tif debugInfoCmd.directory == \"\" {\n\t\tdebugInfoCmd.directory, err = os.MkdirTemp(\"/tmp\", \"dgraph-debuginfo\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error while creating temporary directory: %s\", err)\n\t\t}\n\t} else {\n\t\terr = os.MkdirAll(debugInfoCmd.directory, 0644)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tglog.Infof(\"using directory %s for debug info dump.\", debugInfoCmd.directory)\n\n\tcollectDebug()\n\n\tif debugInfoCmd.archive {\n\t\treturn archiveDebugInfo()\n\t}\n\treturn nil\n}\n\nfunc collectDebug() {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/debuginfo/run.go#L81-L117","documentation":"collectDebugInfo fails to create the temporary directory under /tmp via os.MkdirTemp. This is the OS rejecting the temp-dir creation (permissions, disk space, missing /tmp), surfaced with the underlying error text.","triggerScenarios":"Running `dgraph debuginfo` without --directory when /tmp is not writable, full, or mounted noexec/no-write (e.g. hardened containers, read-only rootfs).","commonSituations":"Containers running as non-root with restricted /tmp, disk-full nodes during incident debugging, security profiles (PSP/SELinux) blocking /tmp writes.","solutions":["Read the wrapped OS error for the exact cause (permission denied / no space left / read-only).","Pass an explicit writable directory: dgraph debuginfo --directory /var/tmp/dgraph-debug.","Free disk space or fix /tmp permissions (chmod 1777 /tmp) if that is the cause.","Run the command as a user with write access to the chosen directory."],"exampleFix":"// before\ndgraph debuginfo                      # fails on read-only /tmp\n// after\ndgraph debuginfo --directory /var/tmp/dgraph-debuginfo","handlingStrategy":"validation","validationCode":"info, err := os.Stat(\"/tmp\")\nif err != nil || !info.IsDir() {\n    return fmt.Errorf(\"/tmp unavailable: %v\", err)\n}\nif err := unix.Access(\"/tmp\", unix.W_OK); err != nil {\n    return fmt.Errorf(\"/tmp not writable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := collectDebugInfo(); err != nil {\n    if strings.Contains(err.Error(), \"temporary directory\") {\n        // fallback to an explicit directory\n        cmd.Flags().Set(\"directory\", \"/var/tmp/dgraph-debug\")\n    }\n    return err\n}","preventionTips":["Always pass --directory on hosts with restricted or full /tmp.","Monitor disk usage on debug-collection targets.","Run the tool as a user with write access to the temp location.","In containers, mount a writable scratch volume for diagnostics."],"tags":["filesystem","disk","tmpdir","debuginfo"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}