ipfs/kubo · error
ENV variable $EDITOR not set
Error message
ENV variable $EDITOR not set
What it means
`ipfs config edit` opens the config file in the editor named by $EDITOR. Kubo throws this when the EDITOR environment variable is empty or unset, because it refuses to guess which editor to launch. The command exits without modifying the config.
Source
Thrown at core/commands/config.go:609
}
func setConfig(r repo.Repo, key string, value any) (*ConfigField, error) {
err := r.SetConfigKey(key, value)
if err != nil {
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) {View on GitHub (pinned to 329838acdf)
Solutions
- Set EDITOR before running: `EDITOR=vim ipfs config edit` (or nano/emacs/vi)
- Export it persistently: `echo 'export EDITOR=vim' >> ~/.bashrc && source ~/.bashrc`
- Skip the editor entirely: use `ipfs config <key> <value>` or `ipfs config replace <file>` instead
- Also consider VISUAL: some setups read VISUAL first; export both to be safe
Example fix
// before ipfs config edit // after EDITOR=nano ipfs config edit
Defensive patterns
Strategy: fallback
Validate before calling
[ -n "$EDITOR" ] || [ -n "$VISUAL" ] && echo "editor set" || echo "EDITOR not set: run e.g. EDITOR=vim ipfs config edit"
Try / catch
if err := editConfig(tmpfile); err != nil {
if strings.Contains(err.Error(), "$EDITOR not set") {
// fall back to printing the path for manual editing
fmt.Println("edit manually:", tmpfile)
return nil
}
return err
} Prevention
- Export EDITOR (and VISUAL) in shell rc files so it survives SSH and scripts
- In Docker/CI, pass -e EDITOR=vim to the container or avoid `config edit` entirely
- Prefer `ipfs config <key> <value>` / `config replace` in non-interactive contexts
- Test `echo $EDITOR` if `ipfs config edit` fails in a new shell
When it happens
Trigger: Running `ipfs config edit` in an environment where EDITOR is not exported: bare docker containers, CI jobs, cron/systemd services, fresh shells, or SSH sessions without a login rc file.
Common situations: Using ipfs inside a minimal Docker image or container where no editor env var is set; running the command from a daemonized/scripted context that has no interactive environment.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- cannot parse $EDITOR value: %s
- private networking (swarm.key / LIBP2P_FORCE_PNET) does not
- Routing.AcceleratedDHTClient option is set even tho Routing.
- serveHTTPApi: GetConfig() failed: %s
- serveHTTPApi: invalid API address: %q (err: %s)
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/963ee2896268969c.
Report an issue: GitHub.