{"record":{"id":"312f2bf5b01f36d9","repo":"lima-vm/lima","slug":"could-not-detect-a-text-editor-binary-try-setting","errorCode":null,"errorMessage":"could not detect a text editor binary, try setting $EDITOR","messagePattern":"could not detect a text editor binary, try setting \\$EDITOR","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/editutil/editutil.go","lineNumber":63,"sourceCode":"\tconfigDir, err := dirnames.LimaConfigDir()\n\tif err != nil {\n\t\ts += \"# WARNING: failed to load the config dir\\n\"\n\t\ts += \"\\n\"\n\t\treturn s\n\t}\n\n\ts += fileWarning(filepath.Join(configDir, filenames.Default))\n\ts += fileWarning(filepath.Join(configDir, filenames.Override))\n\treturn s\n}\n\n// OpenEditor opens an editor, and returns the content (not path) of the modified yaml.\n//\n// OpenEditor returns nil when the file was saved as an empty file, optionally with whitespaces.\nfunc OpenEditor(ctx context.Context, content []byte, hdr string) ([]byte, error) {\n\teditor := editorcmd.Detect()\n\tif editor == \"\" {\n\t\treturn nil, errors.New(\"could not detect a text editor binary, try setting $EDITOR\")\n\t}\n\ttmpYAMLFile, err := os.CreateTemp(\"\", \"lima-editor-\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttmpYAMLPath := tmpYAMLFile.Name()\n\tdefer os.RemoveAll(tmpYAMLPath)\n\tif _, err := tmpYAMLFile.Write(append([]byte(hdr), content...)); err != nil {\n\t\ttmpYAMLFile.Close()\n\t\treturn nil, err\n\t}\n\tif err := tmpYAMLFile.Close(); err != nil {\n\t\treturn nil, err\n\t}\n\n\teditorCmd := exec.CommandContext(ctx, editor, tmpYAMLPath)\n\teditorCmd.Env = os.Environ()\n\teditorCmd.Stdin = os.Stdin","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/editutil/editutil.go#L45-L81","documentation":"OpenEditor launches an interactive editor (via editorcmd.Detect()) to modify YAML content; it returns this error when no editor binary can be found in the environment. Detect() relies on $EDITOR/$VISUAL or well-known editors being installed.","triggerScenarios":"Calling OpenEditor (used by limactl edit and template creation flows via editAction / chooseNextCreatorState) in an environment where $EDITOR and $VISUAL are unset and no common editor binary (vi, nano, vim, etc.) is on PATH.","commonSituations":"Running lima inside minimal containers, CI jobs, or slimmed server images without any editor installed; non-interactive SSH shells where $EDITOR is not exported.","solutions":["Export EDITOR to an installed editor binary, e.g. `export EDITOR=vim` (or nano)","Install an editor (apt install vim / nano) if none exists","Set VISUAL if EDITOR is ignored in your shell environment","Pipe YAML via stdin/file instead of the interactive edit flow when no TTY/editor is available"],"exampleFix":"// before\nlimactl edit default  // fails: could not detect a text editor binary\n// after\nexport EDITOR=vim\nlimactl edit default","handlingStrategy":"validation","validationCode":"if os.Getenv(\"EDITOR\") == \"\" && os.Getenv(\"VISUAL\") == \"\" {\n    if _, err := exec.LookPath(\"vi\"); err != nil {\n        return errors.New(\"no editor: set $EDITOR or install one\")\n    }\n}","typeGuard":null,"tryCatchPattern":"content, err := editutil.OpenEditor(ctx, yaml, hdr)\nif err != nil {\n    if err.Error() == \"could not detect a text editor binary, try setting $EDITOR\" {\n        return fmt.Errorf(\"set $EDITOR and retry: %w\", err)\n    }\n    return err\n}","preventionTips":["Always export EDITOR in shell profiles used for lima management","Install a terminal editor in containers/CI images if editing flows are used","Prefer non-interactive workflows (stdin/file) when no TTY exists"],"tags":["editor","environment","interactive"],"backgroundTag":"missing-editor-env-var","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}