{"record":{"id":"2563b6eed6203344","repo":"go-delve/delve","slug":"could-not-open-stdin-file-v","errorCode":null,"errorMessage":"could not open stdin file: %v","messagePattern":"could not open stdin file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/dap/server.go","lineNumber":1420,"sourceCode":"\t\treturn \".\"\n\t}\n\treturn string(bytes.TrimSpace(out))\n}\n\n// newNoDebugProcess is called from onLaunchRequest (run goroutine) and\n// requires holding mu lock. It prepares process exec.Cmd to be started.\nfunc (s *Session) newNoDebugProcess(program string, targetArgs []string, wd string, remoteOut bool, stdinFrom, stdoutTo, stderrTo string) (cmd *exec.Cmd, stdoutReader, stderrReader io.ReadCloser, err error) {\n\tif s.noDebugProcess != nil {\n\t\treturn nil, nil, nil, errors.New(\"another launch request is in progress\")\n\t}\n\n\tcmd = exec.Command(program, targetArgs...)\n\tcmd.Stdin, cmd.Dir = os.Stdin, wd\n\n\tif stdinFrom != \"\" {\n\t\tfh, err := os.Open(stdinFrom)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"could not open stdin file: %v\", err)\n\t\t}\n\t\tcmd.Stdin = fh\n\t}\n\n\tif remoteOut {\n\t\tif stderrReader, err = cmd.StderrPipe(); err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\n\t\tif stdoutReader, err = cmd.StdoutPipe(); err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t} else {\n\t\tvar err error\n\t\ttoclose := []*os.File{}\n\t\tcreate := func(redirect string, dflt *os.File) (f *os.File) {\n\t\t\tif redirect != \"\" {\n\t\t\t\tf, err = os.Create(redirect)","sourceCodeStart":1402,"sourceCodeEnd":1438,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/dap/server.go#L1402-L1438","documentation":"The DAP launch request supports 'stdinFrom' to redirect the debuggee's stdin from a file. Delve opens that file with os.Open before starting the process; if the open fails (missing file, permission denied, is-a-directory), this error is returned and the debug session fails to launch. Note cmd.Stdin defaults to os.Stdin when stdinFrom is empty.","triggerScenarios":"A DAP launch/attach request with attribute stdinFrom pointing to a nonexistent path, a path without read permission, a directory, or a path relative to a different working directory than the client's.","commonSituations":" Typos in the launch.json 'stdinFrom' value; file deleted between launches; using a client-side relative path that doesn't resolve where dlv runs; trying to feed a directory or unreadable device node; container/remote debugging where the path exists on the client but not the host running dlv.","solutions":["Verify the stdinFrom path exists and is readable by the user running delve (ls -l / test -r).","Use an absolute path, or a path correct relative to the DAP server's working directory.","Ensure it is a regular file, not a directory.","In remote/container setups, make sure the file exists on the machine where dlv runs, not just the client."],"exampleFix":"// before (launch.json)\n\"stdinFrom\": \"./input.txt\"\n// after\n\"stdinFrom\": \"/absolute/path/to/input.txt\"","handlingStrategy":"validation","validationCode":"info, err := os.Stat(cfg.StdinFrom)\nif err != nil {\n    return fmt.Errorf(\"stdinFrom unreachable: %w\", err)\n}\nif info.IsDir() {\n    return errors.New(\"stdinFrom must be a regular file\")\n}\nf, err := os.Open(cfg.StdinFrom)\nif err != nil {\n    return fmt.Errorf(\"stdinFrom not readable: %w\", err)\n}\nf.Close()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for stdinFrom","Pre-flight check file existence and readability before launching","In remote debugging, ensure the file exists on the dlv host"],"tags":["dap","launch","file-io"],"backgroundTag":"file-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}