{"record":{"id":"6a9768503f93aacf","repo":"go-delve/delve","slug":"could-not-create-stderr-file-v","errorCode":null,"errorMessage":"could not create stderr file: %v","messagePattern":"could not create stderr file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/dap/server.go","lineNumber":1459,"sourceCode":"\t\t\t\treturn f\n\t\t\t}\n\n\t\t\treturn dflt\n\t\t}\n\t\tdefer func() {\n\t\t\tfor _, f := range toclose {\n\t\t\t\tf.Close()\n\t\t\t}\n\t\t}()\n\n\t\tcmd.Stdout = create(stdoutTo, os.Stdout)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"could not create stdout file: %v\", err)\n\t\t}\n\n\t\tcmd.Stderr = create(stderrTo, os.Stderr)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"could not create stderr file: %v\", err)\n\t\t}\n\t}\n\n\tif err = cmd.Start(); err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\ts.noDebugProcess = &process{Cmd: cmd, exited: make(chan struct{})}\n\treturn cmd, stdoutReader, stderrReader, nil\n}\n\n// stopNoDebugProcess is called from Stop (main goroutine) and\n// onDisconnectRequest (run goroutine) and requires holding mu lock.\nfunc (s *Session) stopNoDebugProcess() {\n\tif s.noDebugProcess == nil {\n\t\ts.disconnected = true\n\t\t// We already handled termination or there was never a process\n\t\treturn","sourceCodeStart":1441,"sourceCodeEnd":1477,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/dap/server.go#L1441-L1477","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: launching with stderr redirected to a non-writable path\n{\"request\":\"launch\",\"console\":\"integratedTerminal\",\"outputPath\":\"/proc/mydir/log\"}\n// after: use a writable location\n{\"request\":\"launch\",\"console\":\"integratedTerminal\",\"outputPath\":\"/tmp/dlv-log\"}","handlingStrategy":"validation","validationCode":"if st, err := os.Stat(outputDir); err != nil || !st.IsDir() { return fmt.Errorf(\"output dir not writable: %v\", outputDir) }\nif f, err := os.CreateTemp(outputDir, \"dlv-stderr-*\"); err != nil { return err } else { f.Close() }","typeGuard":null,"tryCatchPattern":"if err := startDAPLaunch(cfg); err != nil { if strings.Contains(err.Error(), \"could not create stderr file\") { /* fix outputPath/TMPDIR */ } return err }","preventionTips":["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"],"tags":["dap","filesystem","launch"],"backgroundTag":"file-create-permission-denied","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}