{"record":{"id":"bc7794bf39f1f4af","repo":"sipeed/picoclaw","slug":"editor-is-not-set","errorCode":null,"errorMessage":"$EDITOR is not set","messagePattern":"\\$EDITOR is not set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/mcp/edit.go","lineNumber":22,"sourceCode":"\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/spf13/cobra\"\n\t\"go.mau.fi/util/shlex\"\n\n\t\"github.com/sipeed/picoclaw/cmd/picoclaw/internal\"\n)\n\nfunc newEditCommand() *cobra.Command {\n\treturn &cobra.Command{\n\t\tUse:   \"edit\",\n\t\tShort: \"Open the PicoClaw config in $EDITOR\",\n\t\tArgs:  cobra.NoArgs,\n\t\tRunE: func(cmd *cobra.Command, _ []string) error {\n\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","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/mcp/edit.go#L4-L40","documentation":"`picoclaw mcp edit` shells out to the program named by $EDITOR (edit.go:22-24); if EDITOR is unset or whitespace-only the command aborts before the config is even loaded. The check is strings.TrimSpace(os.Getenv(\"EDITOR\")) == \"\", so an empty or blank value is fatal.","triggerScenarios":"Fresh container/CI shell where EDITOR was never exported; running mcp edit from cron, a daemon, or another process with a scrubbed environment.","commonSituations":"Minimal Docker images and CI runners; root shells; users who normally use a GUI editor and never configured EDITOR.","solutions":["One-off: prefix the command, e.g. EDITOR=nano picoclaw mcp edit","Permanent: add export EDITOR=vim (or nano/code) to ~/.bashrc or ~/.zshrc and restart the shell","On Debian/Ubuntu, select a default via update-alternatives --config editor after installing an editor package"],"exampleFix":"# before\npicoclaw mcp edit\n# after\nEDITOR=nano picoclaw mcp edit","handlingStrategy":"validation","validationCode":"if [ -z \"${EDITOR:-}\" ] || [ -z \"$(printf '%s' \"$EDITOR\" | tr -d '[:space:]')\" ]; then\n  echo \"EDITOR is not set; defaulting to vi\" >&2\n  EDITOR=vi\nfi\npicoclaw mcp edit","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export EDITOR in your shell rc file","In scripts/CI, always invoke as EDITOR=<terminal-editor> picoclaw mcp edit"],"tags":["cli","environment","editor","mcp"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}