ipfs/kubo · error
cannot parse $EDITOR value: %s
Error message
cannot parse $EDITOR value: %s
What it means
`editConfig` parses $EDITOR with shlex (shell-style word splitting) so values like 'code -w' become command + args. This error wraps a shlex failure — raised when the EDITOR value contains unbalanced quotes or other characters that cannot be tokenized. The wrapped shlex error is included via %s.
Source
Thrown at core/commands/config.go:614
return nil, fmt.Errorf("failed to set config value: %s (maybe use --json?)", err)
}
return getConfig(r, key)
}
// parseEditorCommand parses the EDITOR environment variable into command and arguments
func parseEditorCommand(editor string) ([]string, error) {
return shlex.Split(editor, true)
}
func editConfig(filename string) error {
editor := os.Getenv("EDITOR")
if editor == "" {
return errors.New("ENV variable $EDITOR not set")
}
editorAndArgs, err := parseEditorCommand(editor)
if err != nil {
return fmt.Errorf("cannot parse $EDITOR value: %s", err)
}
editor = editorAndArgs[0]
args := append(editorAndArgs[1:], filename)
cmd := exec.Command(editor, args...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
return cmd.Run()
}
// nodePeerID derives the PeerID implied by the private key stored in the repo
// config. Identity.PeerID must equal this value; the node refuses to start
// when the two disagree.
func nodePeerID(r repo.Repo) (peer.ID, error) {
keyF, err := getConfig(r, config.PrivKeySelector)
if err != nil {
return "", errors.New("failed to get PrivKey")
}
pkstr, ok := keyF.Value.(string)View on GitHub (pinned to 329838acdf)
Solutions
- Fix the EDITOR value to be simple or correctly quoted: `EDITOR='code -w'` (balanced quotes)
- Test the split first: `echo $EDITOR` and verify it's a clean command plus optional flags
- Simplify to a bare binary name if possible: `EDITOR=vim`
- If the editor path has spaces, create a symlink without spaces or use a wrapper script
Example fix
// before export EDITOR='my editor -w "' // after export EDITOR='code -w'
Defensive patterns
Strategy: validation
Validate before calling
EDITOR='code -w'; python3 -c "import shlex,sys; shlex.split(sys.argv[1])" "$EDITOR" && echo "EDITOR parses OK"
Try / catch
if err := editConfig(f); err != nil {
if strings.HasPrefix(err.Error(), "cannot parse $EDITOR") {
fmt.Fprintf(os.Stderr, "fix EDITOR quoting; got: %q\n", os.Getenv("EDITOR"))
}
return err
} Prevention
- Keep EDITOR as a simple command name plus flags, e.g. EDITOR='code -w'
- Quote paths with spaces using balanced single quotes in your rc file
- Avoid copy-pasting EDITOR values with curly/smart quotes
- Test with shlex or `echo` before relying on it in scripts
When it happens
Trigger: EDITOR set to a value with unbalanced quotes, e.g. `EDITOR='vim "'` or other malformed shell-like strings that shlex.Split cannot parse into tokens.
Common situations: Users quoting paths with mismatched quotes (EDITOR="'/usr/local/bin/my editor"), or copy-pasting an EDITOR value with stray quote characters into their shell rc file.
Related errors
- invalid provide strategy: empty token in %q
- unknown provide strategy token: %q in %q
- failed to unmarshal json. %s
- ENV variable $EDITOR not set
- cannot parse mode %s: %s
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/15642f85e8ad74cf.
Report an issue: GitHub.