pipenv: Pipenv provides incorrect completion if current shell does not match login shell
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:
{'implementation_name': 'cpython',
'implementation_version': '3.6.4',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '4.15.9-1-ARCH',
'platform_system': 'Linux',
'platform_version': '#1 SMP PREEMPT Sun Mar 11 17:54:33 UTC 2018',
'python_full_version': '3.6.4',
'python_version': '3.6',
'sys_platform': 'linux'}
System environment variables:
COLORTERMDBUS_SESSION_BUS_ADDRESSDESKTOP_AUTOSTART_IDDESKTOP_SESSIONDISPLAYGDMSESSIONGDM_LANGGNOME_DESKTOP_SESSION_IDHOMELANGLOGNAMEMAILMOZ_PLUGIN_PATHPATHPWDSESSION_MANAGERSHELLSHLVLSSH_AUTH_SOCKTERMUSERUSERNAMEVTE_VERSIONWINDOWIDWINDOWPATHXAUTHORITYXDG_CURRENT_DESKTOPXDG_MENU_PREFIXXDG_RUNTIME_DIRXDG_SEATXDG_SESSION_DESKTOPXDG_SESSION_IDXDG_SESSION_TYPEXDG_VTNRPIP_PYTHON_PATHPYTHONUNBUFFERED
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/binSHELL:/bin/bashLANG:en_GB.UTF-8PWD:/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:
qasim@qasim-desktop ~> pipenv - (line 1): Illegal command name “_pipenv_completion()”
begin; _pipenv_completion() { local IFS=$'\t' COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \ COMP_CWORD=$COMP_CWORD \ _PIPENV_COMPLETE=complete-bash $1 ) ) return 0 } complete -F _pipenv_completion -o default pipenv
^
from sourcing file -
called on line 60 of file /usr/share/fish/functions/eval.fish
in function “eval”
called on line 1 of file ~/.config/fish/completions/pipenv.fish
from sourcing file ~/.config/fish/completions/pipenv.fish
called on standard input
in command substitution
called on standard input
source: Error while reading file “-”
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- Setup fish completions inside
~/.config/fish/completions/pipenv.fish:eval (pipenv --completion) - Enter fish and type
Pipenvand then try to auto-complete something
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 35 (22 by maintainers)
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
Proof of concept:
Obviously, doesn’t work in scenarios where there’s an intermediate parent.
@techalchemy Not sure if I can be any less blunt, but it seems like Pipenv is using
$SHELLincorrectly. It’s kind of like creating a program with the documentation that$PATHis to be the location of your documents folder?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.
Pipenv uses click-completion, so you can use this instead:
however, it does seem like this is a Pipenv bug, if
$SHELLis not actually meant to reflect the current shell.