question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pipenv provides incorrect completion if current shell does not match login shell

See original GitHub issue

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:

  • 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:

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
  1. pip install --user --upgrade pipenv
  2. Setup fish completions inside ~/.config/fish/completions/pipenv.fish: eval (pipenv --completion)
  3. Enter fish and type Pipenv and then try to auto-complete something

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:35 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
techalchemycommented, Apr 8, 2018

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

1reaction
tsiq-olivercommented, Apr 7, 2018

How else would you suggest we get the users shell on Linux?

Proof of concept:

>>> import os
>>> import psutil
>>> print(psutil.Process(os.getppid()).exe())
/bin/zsh

Obviously, doesn’t work in scenarios where there’s an intermediate parent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pipenv shell, does not activate the virtual environment
Try doing this: pip uninstall pipenv. this will uninstall existing pipenv after doing that re-install pipenv by doing this:
Read more >
pipenv Documentation - Read the Docs
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the. Python...
Read more >
Advanced Usage of Pipenv - Python Packaging Authority
Dependencies of wheels provided in a Pipfile will not be captured by $ pipenv lock . There are some known issues with using...
Read more >
Advanced Usage of Pipenv - Read the Docs
Dependencies of wheels provided in a Pipfile will not be captured by $ pipenv ... If a .env file is present in your...
Read more >
Advanced Usage of Pipenv — pipenv 7.7.9 documentation
Here is a simple example of a Pipfile and the resulting Pipfile.lock . ... If a .env file is present in your project,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found