Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
pradyunsg opened this issue Jan 21, 2022 · 4 comments · Fixed by #10819
Closed
1 task done
Labels
C: error messages Improving error messages good first issue A good item for first time contributors to work on type: enhancement Improvements to functionality

Comments

@pradyunsg
Copy link
Member

pradyunsg commented Jan 21, 2022

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

@pradyunsg pradyunsg added type: enhancement Improvements to functionality good first issue A good item for first time contributors to work on C: error messages Improving error messages labels Jan 21, 2022
@pradyunsg pradyunsg changed the title Improve error when pip config edit is provided an editor that doesn't exist Improve error message when pip config edit is provided an editor that doesn't exist Jan 21, 2022
@dhrubo28
Copy link

Hi, I would like to work on this issue if no one else is.

@pradyunsg
Copy link
Member Author

Please feel free to pick this up @dhrubo28! :)

@dhrubo28
Copy link

I tried running pip config edit --editor code in the directory I don't have VScode and another directory where I have VScode and in both places, I get the traceback error.

@dhrubo28
Copy link

Has this issue been fixed? If not, I would like guidance as I am a beginner. So, through my research particularly through https://pip.pypa.io/en/stable/cli/pip_config/ and https://pip.pypa.io/en/latest/development/architecture/anatomy/ I understand I will have to work with the configuration.py file.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: error messages Improving error messages good first issue A good item for first time contributors to work on type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants