{"record":{"id":"cca355ab584a6cfd","repo":"sipeed/picoclaw","slug":"editor-is-empty","errorCode":null,"errorMessage":"$EDITOR is empty","messagePattern":"\\$EDITOR is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/mcp/edit.go","lineNumber":38,"sourceCode":"\t\t\teditor := strings.TrimSpace(os.Getenv(\"EDITOR\"))\n\t\t\tif editor == \"\" {\n\t\t\t\treturn fmt.Errorf(\"$EDITOR is not set\")\n\t\t\t}\n\n\t\t\tcfg, err := loadConfig()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err = saveValidatedConfig(cfg); err != nil {\n\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":20,"sourceCodeEnd":55,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/mcp/edit.go#L20-L55","documentation":"After a successful shlex split, edit.go:37-39 requires at least one token. A non-empty EDITOR can still lex to zero words with google/shlex — most realistically when the value begins with # (a comment) or reduces to nothing after lexing. This is a narrower sibling of the '$EDITOR is not set' check.","triggerScenarios":"EDITOR='#vi' where the leading # comments out the whole word; a value consisting only of characters the lexer discards.","commonSituations":"A copy-pasted config line that kept a leading comment marker; accidental garbage in the environment variable.","solutions":["Set EDITOR to a bare command name (vim, nano, code)","Print and inspect the raw value: printf '%s\\n' \"$EDITOR\" | cat -A, then remove stray characters"],"exampleFix":"# before\nexport EDITOR='#vi'\n# after\nexport EDITOR=vi","handlingStrategy":"validation","validationCode":"import \"github.com/google/shlex\"\n\nwords, err := shlex.Split(editor)\nif err != nil || len(words) == 0 {\n\treturn fmt.Errorf(\"EDITOR %q does not name an editor command\", editor)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set EDITOR to a bare command name (vim, nano)","Avoid leading # or comment-like content in EDITOR"],"tags":["cli","editor","shell-parsing"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}