-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Pipenv provides incorrect completion if current shell does not match login shell #1762
Comments
@QasimK what version of fish are you running? |
@QasimK you aren't running fish...
And your
To use completion with bash, use: Closing for now since this seems to be an issue with which shell is running |
@techalchemy Thank you for looking into this. I would like to assure you that I am running fish and I hope the following screenshot is sufficient evidence. According to this and this, Thanks for pointing out |
Pipenv uses @kennethreitz Are you open to modify the option to take an explicit argument (e.g. |
An explicit argument would probably be simpler, and I believe that's how pip does it. I'd be happy to create a PR for that |
@uranusjr Would you mind re-opening this issue given that it is an issue with Pipenv and not the environment, and given that there is also a potential solution on the table |
Pipenv uses click-completion, so you can use this instead: eval (env _PIPENV_COMPLETE=source-fish pipenv) however, it does seem like this is a Pipenv bug, if |
@anowlcalledjosh that’s exactly what pipenv expects |
Overall I would say +1 for the solution proposed by @anowlcalledjosh - closing this because pipenv really expects you to run properly configured login shells when you use it and the documentation does specifically say to specify |
@techalchemy Not sure if I can be any less blunt, but it seems like Pipenv is using Also, I'm not sure if there is any other way to run a "properly configured" fish without changing your default shell (which is not recommended because of the problems that causes): The workaround that @anowlcalledjosh provided works great. I feel that should at least be documented if Pipenv isn't willing to make other changes. |
Hm arguably yes we are misusing the shell variable, how else would you suggest we get the users shell on Linux? People typically add completion in their login scripts so we haven’t encountered this. Also completion has been historically slow so I feel most people have just avoided it. As for documentation, we need plenty of help there so PRs welcome :) |
Well there are a few workarounds available without complicating the most common workflow. Allowing source $(SHELL=$(which fish) pipenv --completion) I don’t know how to write fish scripts so this is bash, but you get the idea. |
I hacked around this by adding |
@veggiedefender not only does it not break other stuff but it is recommended and is what you are supposed to have in your |
@techalchemy Earlier, I provided evidence that that is not what you're supposed to have in your |
Per POSIX,
That's all it says (plus a note about behaviour of "utilities" being undefined when |
Proof of concept:
Obviously, doesn't work in scenarios where there's an intermediate parent. |
Unfortunately it’s not uncommon for Pipenv to be run with an intermediate parent, especially on Windows. |
This might be a good way to guess the preferred shell, however. Pipenv can always fall back to |
We aren’t shipping psutil. I literally spent 2 days writing bindings for windows process crawling to cut psutil out of our dependencies because it causes problems for people on windows. |
There is really no reason to change this behavior as far as I can tell, we have enough technical complexity as is. |
This would definitely add some complexity but after doing some research, it looks like the only real way of identifying the current shell is to look for the existence of shell-specific environment variables such as |
Sounds like stuck between a rock and a hard place then. If that's really the case, then the best solution would be to make this (the need to set |
click-completion (the library Pipenv uses for autocomplete) can already try to guess the shell being used, if psutil is available. I think extending click-completion's guessing ability (presumably by environment variables as @veggiedefender mentioned), and then relying on that guessing in Pipenv, would be better than implementing anything new in Pipenv itself. @uranusjr, it would be a ~3-line change to Pipenv to attempt to automatically detect the shell (via psutil), then fall back to parsing |
Thanks for the offer @anowlcalledjosh — our current stance is that we aren’t using psutil in pipenv. We literally just removed it and had to vendor pew and write c extension bindings for windows. PSUtil is slow and it breaks regularly for windows users, we just aren’t going to use it. We handle enough special edge cases, if we can’t trust your environment we aren’t really able to be responsible for maintaining logic to handle edge cases. If there’s an approach that works around this, I would be ok with that. But in my mind the easiest approach is to set your shell variable |
Also it should be worth some write-up in the documentation. Anyone care to contribute? |
I just ran into this exact problem after installing fish on the README's recommendation. Honestly, I feel like this issue does warrant further discussion given how easy it is to fall into this trap. The README strongly recommends using fish but then things immediately break down once you try to set it up. Most elegant solution as far as I can tell is to simply have It seems like people have ragequit out of #2045 but a solution along those lines would be simple and keep everything working smoothly. |
Fish is recommended in the docs. Not using bash, then fish, then whatever. And as was described in one of the numerous other issues on this, you can basically do that already anyway |
@techalchemy I'm not quite sure what you mean here. Yes, it is technically possible to hack together a working installation but no, it's definitely not user friendly. In the mind of a person on macOS following the readme,
That's just an awful user experience since they followed the exact instructions from the README. And I think the number of people that have commented and filed issues reporting this problem is some indication of its gravity. |
(argh, pressed submit too early...)
I don't think this is actually possible with Click. You can have |
@anowlcalledjosh mmm i see... is there any way to do like |
@anowlcalledjosh Ah or what about replacing @option(
'--completion',
is_flag=True,
default=False,
help="Output completion (to be eval'd).",
) with something like @option(
'--completion',
default=None,
help="Output completion (to be eval'd).",
) and then if |
Unfortunately that doesn't work – if you then run It looks like pallets/click#549 is tracking the lack of this feature in Click. |
@anowlcalledjosh oh right i misunderstood the docs. but it seems like |
I'm just going to chime in and say that it is probably legitimate to keep the user's Personally, I set |
It seems as though Pipenv does not correctly detect the fish shell when determining what to output for
pipenv --completion
. This is a regression that appeared within the last couple of weeks for me.$ python -m pipenv.help output
Pipenv version:
'11.8.0'
Pipenv location:
'/home/qasim/.local/lib/python3.6/site-packages/pipenv'
Python location:
'/usr/bin/python'
Other Python installations in
PATH
:2.7
:/usr/bin/python2.7
2.7
:/usr/bin/python2.7
3.6
:/usr/bin/python3.6m
3.6
:/usr/bin/python3.6
3.6.4
:/usr/bin/python
2.7.14
:/usr/bin/python2
3.6.4
:/usr/bin/python3
PEP 508 Information:
System environment variables:
COLORTERM
DBUS_SESSION_BUS_ADDRESS
DESKTOP_AUTOSTART_ID
DESKTOP_SESSION
DISPLAY
GDMSESSION
GDM_LANG
GNOME_DESKTOP_SESSION_ID
HOME
LANG
LOGNAME
MAIL
MOZ_PLUGIN_PATH
PATH
PWD
SESSION_MANAGER
SHELL
SHLVL
SSH_AUTH_SOCK
TERM
USER
USERNAME
VTE_VERSION
WINDOWID
WINDOWPATH
XAUTHORITY
XDG_CURRENT_DESKTOP
XDG_MENU_PREFIX
XDG_RUNTIME_DIR
XDG_SEAT
XDG_SESSION_DESKTOP
XDG_SESSION_ID
XDG_SESSION_TYPE
XDG_VTNR
PIP_PYTHON_PATH
PYTHONUNBUFFERED
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH
:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/qasim/.local/bin
SHELL
:/bin/bash
LANG
:en_GB.UTF-8
PWD
:/home/qasim
Expected result
I'd expect the completion to complete without errors :)
Actual result
When attempting to auto-complete on the first Pipenv command:
It seems as though this is the bash code being output from <???> rather than the fish code.
Steps to replicate
pip install --user --upgrade pipenv
~/.config/fish/completions/pipenv.fish
:eval (pipenv --completion)
Pipenv
and then try to auto-complete somethingThe text was updated successfully, but these errors were encountered: