{"record":{"id":"ec99aae741ee6566","repo":"pypa/pip","slug":"could-not-determine-editor-to-use","errorCode":null,"errorMessage":"Could not determine editor to use.","messagePattern":"Could not determine editor to use\\.","errorType":"exception","errorClass":"PipError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/commands/configuration.py","lineNumber":289,"sourceCode":"        # We successfully ran a modifying command. Need to save the\n        # configuration.\n        try:\n            self.configuration.save()\n        except Exception:\n            logger.exception(\n                \"Unable to save configuration. Please report this as a bug.\"\n            )\n            raise PipError(\"Internal Error.\")\n\n    def _determine_editor(self, options: Values) -> str:\n        if options.editor is not None:\n            return options.editor\n        elif \"VISUAL\" in os.environ:\n            return os.environ[\"VISUAL\"]\n        elif \"EDITOR\" in os.environ:\n            return os.environ[\"EDITOR\"]\n        else:\n            raise PipError(\"Could not determine editor to use.\")\n","sourceCodeStart":271,"sourceCodeEnd":290,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/commands/configuration.py#L271-L290","documentation":"Raised by `pip config edit` when no editor can be determined. _determine_editor at configuration.py:281 checks --editor, then $VISUAL, then $EDITOR; if all three are absent/None it raises this PipError. pip has no built-in default editor.","triggerScenarios":"Running `pip config edit` without --editor and with neither VISUAL nor EDITOR exported in the environment.","commonSituations":"Minimal containers, CI shells, fresh user accounts, or non-interactive shells where no editor env var is set.","solutions":["Pass the editor explicitly: `pip config edit --editor nano`.","Set EDITOR (or VISUAL) in your shell: `export EDITOR=nano` (add to ~/.bashrc/~/.zshrc).","Edit the file manually — run `pip config debug` to find its path, then open it in any editor."],"exampleFix":"// before\npip config edit\n// after\nexport EDITOR=nano\npip config edit","handlingStrategy":"validation","validationCode":"# Ensure an editor is resolvable before pip config edit\nimport os, shutil\n\ndef resolve_editor(explicit=None):\n    ed = explicit or os.environ.get(\"VISUAL\") or os.environ.get(\"EDITOR\")\n    if not ed or not shutil.which(ed.split()[0]):\n        raise EnvironmentError(\"No editor: set EDITOR or pass --editor\")\n    return ed\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always export EDITOR in your shell rc file.","Pass `--editor <path>` explicitly in scripts/containers.","Fall back to editing the file directly via `pip config debug` for the path."],"tags":["cli","pip-config","configuration","environment","editor"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}