{"record":{"id":"98d8924ac5423b95","repo":"lima-vm/lima","slug":"could-not-execute-editor-q-for-a-file-q-w","errorCode":null,"errorMessage":"could not execute editor %#q for a file %#q: %w","messagePattern":"could not execute editor %#q for a file %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/editutil/editutil.go","lineNumber":86,"sourceCode":"\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\n\teditorCmd.Stdout = os.Stdout\n\teditorCmd.Stderr = os.Stderr\n\tlogrus.Debugf(\"opening editor %#q for a file %#q\", editor, tmpYAMLPath)\n\tif err := editorCmd.Run(); err != nil {\n\t\treturn nil, fmt.Errorf(\"could not execute editor %#q for a file %#q: %w\", editor, tmpYAMLPath, err)\n\t}\n\tb, err := os.ReadFile(tmpYAMLPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmodifiedInclHdr := string(b)\n\tmodifiedExclHdr := strings.TrimPrefix(modifiedInclHdr, hdr)\n\tif strings.TrimSpace(modifiedExclHdr) == \"\" {\n\t\treturn nil, nil\n\t}\n\treturn []byte(modifiedExclHdr), nil\n}\n","sourceCodeStart":68,"sourceCodeEnd":99,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/editutil/editutil.go#L68-L99","documentation":"OpenEditor successfully located and launched the editor, but the editor process exited with a non-zero status. The error wraps the editor command, the temp YAML path, and the underlying exit error so the user can see which editor failed on which file.","triggerScenarios":"The editor binary launched by OpenEditor (editAction / chooseNextCreatorState flows) exits non-zero — e.g. bad $EDITOR value (a flag-taking command like `code -w` misconfigured), editor crashing, or user quitting the editor with an error exit code.","commonSituations":"Setting EDITOR to a GUI editor that doesn't block/wait for the terminal; EDITOR containing shell syntax (pipes, args) that exec can't run directly; editor failing on the temp file's permissions or disk-full conditions.","solutions":["Check the wrapped exit error to see how the editor failed","Set EDITOR to a terminal editor executable path without shell syntax, e.g. `export EDITOR=/usr/bin/vim`","For GUI editors use a wait-wrapping wrapper (e.g. a script calling `code --wait`)","Retry the edit command after fixing the EDITOR setting"],"exampleFix":"// before\nexport EDITOR=\"code\"        // exits immediately, no wait\n// after\nexport EDITOR=\"code --wait\"  // via wrapper script if -- args unsupported","handlingStrategy":"try-catch","validationCode":"editor := os.Getenv(\"EDITOR\")\nif editor != \"\" {\n    if _, err := exec.LookPath(strings.Fields(editor)[0]); err != nil {\n        return fmt.Errorf(\"EDITOR %q is not an executable\", editor)\n    }\n}","typeGuard":null,"tryCatchPattern":"content, err := editutil.OpenEditor(ctx, yaml, hdr)\nif err != nil {\n    var ee *exec.ExitError\n    if errors.As(err, &ee) {\n        return fmt.Errorf(\"editor exited non-zero (did it crash or not wait?): %w\", err)\n    }\n    return err\n}","preventionTips":["Set EDITOR to a plain executable path without shell syntax","Use a wait wrapper for GUI editors (code --wait)","Avoid editors that exit immediately without waiting","Check disk space/permissions if editors fail on temp files"],"tags":["editor","subprocess","environment"],"backgroundTag":"editor-command-exit-error","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}