{"record":{"id":"bb2c04028c3331ca","repo":"sipeed/picoclaw","slug":"failed-to-start-editor-w","errorCode":null,"errorMessage":"failed to start editor: %w","messagePattern":"failed to start editor: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/mcp/edit.go","lineNumber":48,"sourceCode":"\t\t\t\treturn err\n\t\t\t}\n\n\t\t\teditorArgs, err := shlex.Split(editor)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse $EDITOR: %w\", err)\n\t\t\t}\n\t\t\tif len(editorArgs) == 0 {\n\t\t\t\treturn fmt.Errorf(\"$EDITOR is empty\")\n\t\t\t}\n\n\t\t\teditorArgs = append(editorArgs, internal.GetConfigPath())\n\t\t\tprocess := editorCommand(editorArgs[0], editorArgs[1:]...)\n\t\t\tprocess.Stdin = cmd.InOrStdin()\n\t\t\tprocess.Stdout = cmd.OutOrStdout()\n\t\t\tprocess.Stderr = cmd.ErrOrStderr()\n\n\t\t\tif err := process.Run(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to start editor: %w\", err)\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t}\n}\n","sourceCodeStart":30,"sourceCodeEnd":55,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/mcp/edit.go#L30-L55","documentation":"edit.go:48-50 wraps process.Run() of the spawned editor. Despite the 'failed to start' wording it covers both spawn failures (binary not found in PATH) and non-zero editor exits, since Run covers both; the underlying exec error is preserved via %w. Stdin/stdout/stderr are wired to the terminal, so interactive editors work normally.","triggerScenarios":"EDITOR points to a binary not installed or not on PATH in this shell; the editor exits non-zero (vim :cq, crashed plugin); $TERM unset in a headless session makes the editor bail immediately.","commonSituations":"EDITOR=code over SSH without the VS Code CLI on PATH; tmux/screen without TERM; broken editor config causing instant exit; EDITOR left over from another machine.","solutions":["Confirm the first word of EDITOR resolves: command -v ${EDITOR%% *}","Run the editor directly on the config path (\"$EDITOR\" ~/.config/picoclaw/config.json) to see its own error output","For headless/SSH contexts, switch to a terminal editor (vim/nano) for this invocation: EDITOR=vim picoclaw mcp edit"],"exampleFix":"# before\nexport EDITOR=code   # code not on PATH over ssh\npicoclaw mcp edit\n# after\ncommand -v code || export EDITOR=vim\npicoclaw mcp edit","handlingStrategy":"try-catch","validationCode":"editorBin=$(printf '%s' \"$EDITOR\" | cut -d' ' -f1)\ncommand -v \"$editorBin\" >/dev/null 2>&1 || { echo \"editor $editorBin not found in PATH\" >&2; exit 127; }\npicoclaw mcp edit","typeGuard":null,"tryCatchPattern":"if err := editCmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to start editor\") {\n\t\t// underlying *exec.Error or *exec.ExitError is wrapped via %w:\n\t\t// inspect with errors.As to distinguish not-found vs non-zero exit\n\t\tvar execErr *exec.ExitError\n\t\tif errors.As(err, &execErr) {\n\t\t\tfmt.Fprintf(os.Stderr, \"editor exited %s\\n\", execErr.ExitCode())\n\t\t}\n\t}\n}","preventionTips":["Verify the editor binary is on PATH in the exact shell you launch from (SSH, tmux)","Set TERM when running in headless contexts","Prefer terminal editors for CLI edit flows"],"tags":["cli","editor","process","exec"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}