sipeed/picoclaw · error
$EDITOR is not set
Error message
$EDITOR is not set
What it means
`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.
Source
Thrown at cmd/picoclaw/internal/mcp/edit.go:22
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"go.mau.fi/util/shlex"
"github.com/sipeed/picoclaw/cmd/picoclaw/internal"
)
func newEditCommand() *cobra.Command {
return &cobra.Command{
Use: "edit",
Short: "Open the PicoClaw config in $EDITOR",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
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")
}
View on GitHub (pinned to 49183d7e8d)
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
Example fix
# before picoclaw mcp edit # after EDITOR=nano picoclaw mcp edit
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "${EDITOR:-}" ] || [ -z "$(printf '%s' "$EDITOR" | tr -d '[:space:]')" ]; then
echo "EDITOR is not set; defaulting to vi" >&2
EDITOR=vi
fi
picoclaw mcp edit Prevention
- Export EDITOR in your shell rc file
- In scripts/CI, always invoke as EDITOR=<terminal-editor> picoclaw mcp edit
When it happens
Trigger: Fresh container/CI shell where EDITOR was never exported; running mcp edit from cron, a daemon, or another process with a scrubbed environment.
Common situations: Minimal Docker images and CI runners; root shells; users who normally use a GUI editor and never configured EDITOR.
Related errors
- failed to parse $EDITOR: %w
- failed to confirm overwrite: %w
- aborted: MCP server %q already exists
- missing value for %s
- usage: picoclaw mcp add [flags] <name> <command-or-url> [arg
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/bc7794bf39f1f4af.
Report an issue: GitHub.