Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/10812.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improve error message when ``pip config edit`` is provided an editor that
doesn't exist.
4 changes: 4 additions & 0 deletions src/pip/_internal/commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def open_in_editor(self, options: Values, args: List[str]) -> None:

try:
subprocess.check_call([editor, fname])
except FileNotFoundError as e:
if not e.filename:
e.filename = editor
raise
except subprocess.CalledProcessError as e:
raise PipError(
"Editor Subprocess exited with exit code {}".format(e.returncode)
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,10 @@ def test_global_config_file(self, script: PipTestEnvironment) -> None:
global_config_file = get_configuration_files()[kinds.GLOBAL][0]
result = script.pip("config", "debug")
assert f"{global_config_file}, exists:" in result.stdout

def test_editor_does_not_exist(self, script: PipTestEnvironment) -> None:
"""Ensure that FileNotFoundError sets filename correctly"""
result = script.pip(
"config", "edit", "--editor", "notrealeditor", expect_error=True
)
assert "notrealeditor" in result.stderr