Skip to content

Improve error message when pip config edit is provided an editor that doesn't exist #10812

Closed
@pradyunsg

Description

@pradyunsg

Description

If you run pip config --edit with an editor that doesn't exist, pip presents a traceback.

Expected behavior

pip would present a clear error message, about which file could not be found.

pip version

21.3.1

Python version

N/A

OS

Windows

How to Reproduce

Run pip config edit --editor code on a Windows machine without VSCode installed.

Output

C:\Users\traveler\Desktop\pip>py -m pip config edit --editor code
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\traveler\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
    status = self.run(options, args)
  File "C:\Users\traveler\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\configuration.py", line 128, in run
    handlers[action](options, args[1:])
  File "C:\Users\traveler\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\configuration.py", line 225, in open_in_editor
    subprocess.check_call([editor, fname])
  File "C:\Users\traveler\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 364, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Users\traveler\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 345, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\traveler\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\traveler\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: error messagesImproving error messagesgood first issueA good item for first time contributors to work ontype: enhancementImprovements to functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions