-
Notifications
You must be signed in to change notification settings - Fork 3k
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
pip config and $EDITOR containing arguments #7392
Comments
There is some discussion on the associated PR #7391. |
I remember researching this. There wasn't any reference material for $editor that involved arguments. That said, if git and svn (both) support this form of invocation, that's a strong argument in support of allowing this. If either doesn't, I don't know how we should go about this. Regardless, we should definitely print a nicer error message here IMO. |
A quick test shows git supports it too:
yields
I would be in favor of this depending on the approach. We can discuss that on #7391. |
For anyone that wants to implement this, please see #7391 which shows where the change needs to happen and #7391 (comment) which has advice to improve that approach. We would be happy to review a PR that implements this taking those into account. |
I would like to resolve this issue. |
Hi @gutsytechster! My previous comment still stands. The first place I would start is figuring out a way to get |
An alternative to
A quick search over the web leaded to me this implementation. Reference:- https://stackoverflow.com/questions/9877462/is-there-a-python-equivalent-to-the-which-command. What do you think about this @chrahunt? |
On Windows it would also need to check |
I see. Thanks, I'll then put up a PR to implement this on Python3. |
@chrahunt, In the suggested implementation here, #7391 (review), what would be the case when the code under I mean, if the path would exist, then the first condition would already return |
Also currently, the way that code executes is like this.
Since the behaviour is not changed for Python 2, the output is similar to what is being provided to it as an editor. However for Python 3, if a single argument ie the application is provided, then it returns an absolute path to the executable but when an application is provided with arguments, the arguments are separated by space. Should it behave like that? This is w.r.t #8612 |
I've been reading the discussion over GH-7391 and I also favor passing the raw
|
I believe How do other tools (e.g. SVN, Git) handle this environment variable? |
You're right, I've just checked this again.
git seems to handle it out-of-box, e.g. with #!/bin/sh
cd $(mktemp -d)
mkdir example\ path
cp ~/.vim/vimrc example\ path
git init
git add .
EDITOR="vim -S 'example path/vimrc'" git commit I don't understand why we need |
I should be clearer. I was wondering how other tools implement this feature, e.g. do they use something analogous to |
I've just taken a peak at git's source and it uses shell too. |
So, how do we want to proceed with it? This question #7392 (comment) still stands. |
ping^^ |
I feel we should yield and just use |
I'll just add a popular use case to the discussion - using vscode as a git editor. |
@gutsytechster - About #7392 (comment), what if we change the logic to: ...
result = shutil.which(editor)
if result or os.path.exists(editor):
return [editor]
return shlex.split(editor) So if the users command works - we just use that without changing it. This removes the odd behavior of changing to absolute path, but keeps everything else working. |
Just tripped across this issue. I have |
Yep, just hit this one too. Is there any workaround?
|
As a workaround, you can have a small script that invokes your editor with your preferred arguments, and put that script's name into your There's no real documentation on |
@pfmoore good idea about the script, I'll try that. I still use edit: found another one: crontab -e
crontab: /usr/local/bin/subl -w: No such file or directory |
@pfmoore Thanks again for the idea of wedging a small script in between I came up with this (bonus: falls back to vim when I'm in an SSH session) In .bash_profile: export EDITOR=editor_shim /usr/local/bin/editor_shim: #!/bin/bash
if [ -z "$SSH_TTY" ]; then
/usr/local/bin/subl -w "$@"
else
vim "$@"
fi |
Environment
Description
pip config edit
is supposed to open the program specified by environment variable Editor if it's set. Actually if the env is a program with its options, pip will treat the whole thing as the program name and throws a FileNotFoundError.Expected behavior
pip config edit open the editor with options set.
How to Reproduce
export EDITOR="nvim --noplugin"; pip config edit
Output
My Fix #7391
The text was updated successfully, but these errors were encountered: