dgraph-io/dgraph · error
error while creating temporary directory: %s
Error message
error while creating temporary directory: %s
What it means
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.
Source
Thrown at dgraph/cmd/debuginfo/run.go:99
flags.StringVarP(&debugInfoCmd.alphaAddr, "alpha", "a", "localhost:8080",
"Address of running dgraph alpha.")
flags.StringVarP(&debugInfoCmd.zeroAddr, "zero", "z", "", "Address of running dgraph zero.")
flags.StringVarP(&debugInfoCmd.directory, "directory", "d", "",
"Directory to write the debug info into.")
flags.BoolVarP(&debugInfoCmd.archive, "archive", "x", true,
"Whether to archive the generated report")
flags.Uint32VarP(&debugInfoCmd.seconds, "seconds", "s", 30,
"Duration for time-based metric collection.")
flags.StringSliceVarP(&debugInfoCmd.metricTypes, "metrics", "m", metricList,
"List of metrics & profile to dump in the report.")
}
func collectDebugInfo() (err error) {
if debugInfoCmd.directory == "" {
debugInfoCmd.directory, err = os.MkdirTemp("/tmp", "dgraph-debuginfo")
if err != nil {
return fmt.Errorf("error while creating temporary directory: %s", err)
}
} else {
err = os.MkdirAll(debugInfoCmd.directory, 0644)
if err != nil {
return err
}
}
glog.Infof("using directory %s for debug info dump.", debugInfoCmd.directory)
collectDebug()
if debugInfoCmd.archive {
return archiveDebugInfo()
}
return nil
}
func collectDebug() {View on GitHub (pinned to 759e242be6)
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.
Example fix
// before dgraph debuginfo # fails on read-only /tmp // after dgraph debuginfo --directory /var/tmp/dgraph-debuginfo
Defensive patterns
Strategy: validation
Validate before calling
info, err := os.Stat("/tmp")
if err != nil || !info.IsDir() {
return fmt.Errorf("/tmp unavailable: %v", err)
}
if err := unix.Access("/tmp", unix.W_OK); err != nil {
return fmt.Errorf("/tmp not writable: %v", err)
} Try / catch
if err := collectDebugInfo(); err != nil {
if strings.Contains(err.Error(), "temporary directory") {
// fallback to an explicit directory
cmd.Flags().Set("directory", "/var/tmp/dgraph-debug")
}
return err
} Prevention
- 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.
When it happens
Trigger: Running `dgraph debuginfo` without --directory when /tmp is not writable, full, or mounted noexec/no-write (e.g. hardened containers, read-only rootfs).
Common situations: Containers running as non-root with restricted /tmp, disk-full nodes during incident debugging, security profiles (PSP/SELinux) blocking /tmp writes.
Related errors
- error while creating debug file: %s
- server response: %s - %s
- server response: %s
- error while archiving debuginfo directory: %s
- p directory does not exist for group [%d]: [%s]
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/3d6fc787e2f0f0de.
Report an issue: GitHub.