go-delve/delve · error
could not create stderr file: %v
Error message
could not create stderr file: %v
What it means
Delve's DAP server failed to create a temporary file to which the debuggee's stderr (or stdout) would be redirected when launching the process. This is a local filesystem error wrapped with context; the underlying OS error (permissions, missing directory, too many open files) is embedded in the message.
Source
Thrown at service/dap/server.go:1459
return f
}
return dflt
}
defer func() {
for _, f := range toclose {
f.Close()
}
}()
cmd.Stdout = create(stdoutTo, os.Stdout)
if err != nil {
return nil, nil, nil, fmt.Errorf("could not create stdout file: %v", err)
}
cmd.Stderr = create(stderrTo, os.Stderr)
if err != nil {
return nil, nil, nil, fmt.Errorf("could not create stderr file: %v", err)
}
}
if err = cmd.Start(); err != nil {
return nil, nil, nil, err
}
s.noDebugProcess = &process{Cmd: cmd, exited: make(chan struct{})}
return cmd, stdoutReader, stderrReader, nil
}
// stopNoDebugProcess is called from Stop (main goroutine) and
// onDisconnectRequest (run goroutine) and requires holding mu lock.
func (s *Session) stopNoDebugProcess() {
if s.noDebugProcess == nil {
s.disconnected = true
// We already handled termination or there was never a process
returnView on GitHub (pinned to a23773e6c3)
Solutions
- Check the directory used for the redirect/temp file exists and is writable by the user running DAP
- Free disk space or raise ulimit -n if 'too many open files' is reported
- Run the editor/DAP client in an environment with a writable TMPDIR
- Read the wrapped OS error in the message to identify the exact filesystem cause
Example fix
// before: launching with stderr redirected to a non-writable path
{"request":"launch","console":"integratedTerminal","outputPath":"/proc/mydir/log"}
// after: use a writable location
{"request":"launch","console":"integratedTerminal","outputPath":"/tmp/dlv-log"} Defensive patterns
Strategy: validation
Validate before calling
if st, err := os.Stat(outputDir); err != nil || !st.IsDir() { return fmt.Errorf("output dir not writable: %v", outputDir) }
if f, err := os.CreateTemp(outputDir, "dlv-stderr-*"); err != nil { return err } else { f.Close() } Try / catch
if err := startDAPLaunch(cfg); err != nil { if strings.Contains(err.Error(), "could not create stderr file") { /* fix outputPath/TMPDIR */ } return err } Prevention
- Ensure the outputPath/TMPDIR directory exists and is writable
- Check ulimit -n in long-lived sessions
- Test launch configs in a clean environment before CI
When it happens
Trigger: An onLaunchRequest (or onAttachRequest with launch semantics) where the launch configuration requests output redirection (e.g. console internals / outputPath handling) and os.CreateFile-style creation of the stderr target file fails with an OS error.
Common situations: Read-only or non-existent output directory, disk full, restrictive file permissions/umask, or hitting the open-file limit when many sessions create temp files.
Related errors
- not an executable file
- another launch request is in progress
- could not open stdin file: %v
- could not create stdout file: %v
- could not launch process: %s
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/6a9768503f93aacf.
Report an issue: GitHub.