sipeed/picoclaw · error
$EDITOR is empty
Error message
$EDITOR is empty
What it means
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.
Source
Thrown at cmd/picoclaw/internal/mcp/edit.go:38
editor := strings.TrimSpace(os.Getenv("EDITOR"))
if editor == "" {
return fmt.Errorf("$EDITOR is not set")
}
cfg, err := loadConfig()
if err != nil {
return err
}
if err = saveValidatedConfig(cfg); err != nil {
return err
}
editorArgs, err := shlex.Split(editor)
if err != nil {
return fmt.Errorf("failed to parse $EDITOR: %w", err)
}
if len(editorArgs) == 0 {
return fmt.Errorf("$EDITOR is empty")
}
editorArgs = append(editorArgs, internal.GetConfigPath())
process := editorCommand(editorArgs[0], editorArgs[1:]...)
process.Stdin = cmd.InOrStdin()
process.Stdout = cmd.OutOrStdout()
process.Stderr = cmd.ErrOrStderr()
if err := process.Run(); err != nil {
return fmt.Errorf("failed to start editor: %w", err)
}
return nil
},
}
}
View on GitHub (pinned to 49183d7e8d)
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
Example fix
# before export EDITOR='#vi' # after export EDITOR=vi
Defensive patterns
Strategy: validation
Validate before calling
import "github.com/google/shlex"
words, err := shlex.Split(editor)
if err != nil || len(words) == 0 {
return fmt.Errorf("EDITOR %q does not name an editor command", editor)
} Prevention
- Set EDITOR to a bare command name (vim, nano)
- Avoid leading # or comment-like content in EDITOR
When it happens
Trigger: EDITOR='#vi' where the leading # comments out the whole word; a value consisting only of characters the lexer discards.
Common situations: A copy-pasted config line that kept a leading comment marker; accidental garbage in the environment variable.
Related errors
- failed to parse $EDITOR: %w
- $EDITOR is not set
- failed to start editor: %w
- failed to load config: %w
- reset failed: %w
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/cca355ab584a6cfd.
Report an issue: GitHub.