pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

`--completion` flag not recognized in bash

Open ttecles opened this issue 2 years ago • 13 comments

The pipenv --completion command is not working:

$ pipenv --completion
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Try 'pipenv -h' for help.

Error: No such option: --completion Did you mean --python?
$ pipenv --support

Pipenv version: '2022.1.8'

Pipenv location: '/home/joan/.local/lib/python3.8/site-packages/pipenv'

Python location: '/usr/bin/python'

Python installations found:

  • 3.10.0: /home/joan/.pyenv/versions/3.10.0/bin/python3
  • 3.8.10: /home/joan/.pyenv/versions/list/bin/python3
  • 3.8.10: /home/joan/.pyenv/versions/PoC/bin/python3
  • 3.8.10: /usr/bin/python3.8
  • 3.8.10: /usr/bin/python3
  • 3.8.10: /usr/bin/python
  • 3.8.10: /bin/python3.8
  • 3.8.10: /bin/python3
  • 3.8.10: /bin/python
  • 3.7.7: /home/joan/.pyenv/versions/3.7.7/bin/python3.7
  • 3.7.6: /home/joan/.pyenv/versions/3.7.6/bin/python3.7
  • 3.7.5: /home/joan/.pyenv/versions/3.7.5/bin/python3.7
  • 3.7.0: /home/joan/.pyenv/versions/3.7.0/bin/python3.7
  • 3.6.15: /home/joan/.pyenv/versions/product-brewer/bin/python3.6
  • 3.6.15: /home/joan/.pyenv/versions/3.6.15/bin/python3.6m
  • 3.6.15: /home/joan/.pyenv/versions/WardrobeClient/bin/python3.6
  • 3.6.10: /home/joan/.pyenv/versions/3.6.10/bin/python3.6m
  • 3.6.7: /home/joan/.pyenv/versions/3.6.7/bin/python3.6m
  • 2.7.18: /home/joan/.pyenv/versions/2.7.18/bin/python2

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.8.10',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.14.0-1027-oem',
 'platform_system': 'Linux',
 'platform_version': '#30-Ubuntu SMP Mon Mar 7 15:00:29 UTC 2022',
 'python_full_version': '3.8.10',
 'python_version': '3.8',
 'sys_platform': 'linux'}

System environment variables:

  • SHELL
  • PIPENV_PYPI_MIRROR
  • SESSION_MANAGER
  • QT_ACCESSIBILITY
  • COLORTERM
  • XDG_CONFIG_DIRS
  • NVM_INC
  • XDG_MENU_PREFIX
  • GNOME_DESKTOP_SESSION_ID
  • LC_ADDRESS
  • GNOME_SHELL_SESSION_MODE
  • LC_NAME
  • SSH_AUTH_SOCK
  • ANDROID_SDK
  • XMODIFIERS
  • DESKTOP_SESSION
  • LC_MONETARY
  • SSH_AGENT_PID
  • GTK_MODULES
  • PWD
  • PYENV_VIRTUALENV_INIT
  • LOGNAME
  • XDG_SESSION_DESKTOP
  • XDG_SESSION_TYPE
  • GPG_AGENT_INFO
  • XAUTHORITY
  • WINDOWPATH
  • HOME
  • USERNAME
  • IM_CONFIG_PHASE
  • LC_PAPER
  • LANG
  • LS_COLORS
  • XDG_CURRENT_DESKTOP
  • VTE_VERSION
  • GNOME_TERMINAL_SCREEN
  • INVOCATION_ID
  • MANAGERPID
  • NVM_DIR
  • LESSCLOSE
  • XDG_SESSION_CLASS
  • TERM
  • LC_IDENTIFICATION
  • LESSOPEN
  • LIBVIRT_DEFAULT_URI
  • USER
  • GNOME_TERMINAL_SERVICE
  • DISPLAY
  • SHLVL
  • NVM_CD_FLAGS
  • LC_TELEPHONE
  • QT_IM_MODULE
  • LC_MEASUREMENT
  • XDG_RUNTIME_DIR
  • PS1
  • LC_TIME
  • JOURNAL_STREAM
  • XDG_DATA_DIRS
  • PATH
  • GDMSESSION
  • DBUS_SESSION_BUS_ADDRESS
  • NVM_BIN
  • LC_NUMERIC
  • OLDPWD
  • _
  • PIP_SHIMS_BASE_MODULE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_PYPI_MIRROR: http://pypi.edtd.net/EDITED/dev/+simple/

Debug–specific environment variables:

  • PATH: /home/joan/.nvm/versions/node/v10.7.0/bin:/home/joan/.poetry/bin:/home/joan/.pyenv/plugins/pyenv-virtualenv/shims:/home/joan/.pyenv/shims:/home/joan/.pyenv/bin:/home/joan/.poetry/bin:/home/joan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/joan/.fzf/bin:/opt/apache-storm/bin
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /home/joan/apps/hydra

and here is my env:

$ pip list
Package            Version
------------------ ---------
amqp               2.6.1
botocore           1.19.63
certifi            2021.10.8
chardet            3.0.4
click              8.0.3
distlib            0.3.4
docker             4.4.4
EasyProcess        0.3
filelock           3.4.0
google-auth        2.3.3
idna               3.3
importlib-metadata 4.11.3
itsdangerous       2.0.1
Jinja2             3.0.3
jmespath           0.10.0
kubernetes         20.13.0
limits             1.6
MarkupSafe         2.0.1
oauthlib           3.1.1
orderedmultidict   1.0.1
pip                22.0.4
pipenv             2022.1.8
platformdirs       2.5.1
pyasn1             0.4.8
pyasn1-modules     0.2.8
pyretry            1.0.0
requests-file      1.5.1
requests-oauthlib  1.3.0
rsa                4.8
s3transfer         0.3.7
setuptools         39.0.1
six                1.16.0
soupsieve          2.3.1
tabulate           0.8.9
typing_extensions  4.1.1
urllib3            1.26.7
vine               1.3.0
virtualenv         20.13.3
virtualenv-clone   0.5.7
websocket-client   1.2.1
Werkzeug           2.0.2
zipp               3.7.0

$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

ttecles avatar Mar 17 '22 13:03 ttecles

@ttecles I am having trouble finding any reference to a --completion flag in the code base. Can you reference me to the docs where it is specified?

matteius avatar Mar 17 '22 13:03 matteius

@ttecles I am having trouble finding any reference to a --completion flag in the code base. Can you reference me to the docs where it is specified?

@matteius there you go: https://pipenv-fork.readthedocs.io/en/latest/advanced.html#shell-completion

I found a commit that removed that flag: https://github.com/pypa/pipenv/commit/267ba191a5cb0623bc99e60b44e99045a11e07cd

ttecles avatar Mar 17 '22 14:03 ttecles

@ttecles I am having trouble finding any reference to a --completion flag in the code base. Can you reference me to the docs where it is specified?

@matteius there you go: https://pipenv-fork.readthedocs.io/en/latest/advanced.html#shell-completion

I found a commit that removed that flag: 267ba19

I see the docs in github do not have that anymore: https://github.com/pypa/pipenv/blob/main/docs/advanced.rst#-shell-completion

ttecles avatar Mar 17 '22 14:03 ttecles

@ttecles Thanks, and just noting that the correct page to access the pipenv docs is here: https://pipenv.pypa.io/en/latest/

matteius avatar Mar 17 '22 14:03 matteius

@ttecles Thanks, and just noting that the correct page to access the pipenv docs is here: https://pipenv.pypa.io/en/latest/

thanks @matteius

ttecles avatar Mar 17 '22 14:03 ttecles

@ttecles you probably did the same as me - upgrade pipenv and notice your shell completion broke. It looks like this breaking change was released in 2021.11.9, and the changelog doesn't say anything about it directly. I had to create a version check in my .profile to determine how to install pipenv completion, like so:

    # Set up magic shell completion for pipenv (works in bash and zsh)
    # Have to check version bc pipenv changed the implementation
    if version_greater_equal "$(pipenv --version)" "2021.11.9" ; then
        eval "$(_PIPENV_COMPLETE=zsh_source pipenv)"
    else
        eval "$(pipenv --completion)"
    fi

It would have been nice if this sort of thing had been updated in the docs along with this sort of breaking change. I'm also now going to have to make it shell-specific in my .profile...

EDIT: Now it looks like this:

      # Set up magic shell completion for pipenv (works in bash and zsh)-
      # Have to check version bc pipenv changed the implementation
      if version_greater_equal "$(pipenv --version)" "2021.11.9" ; then
          RUNNING_SHELL="$(ps -p$$ -ocmd=)"--
          case $RUNNING_SHELL in
              -zsh) eval "$(_PIPENV_COMPLETE=zsh_source pipenv)";;
              -bash) eval "$(_PIPENV_COMPLETE=bash_source pipenv)";;
              *) echo "SHELL $RUNNING_SHELL not supported for pipenv completions!"
          esac
      else
          # used to work this way for all shells
          eval "$(pipenv --completion)";;
      fi

timblaktu avatar Jun 17 '22 20:06 timblaktu

I added some tags to the ticket since it seems like there is a chance to improve something here. I don't have the bandwidth to directly make changes at the moment, but I could advise and review PR if there were an improvement to be made. My thoughts are we are trying to reduce the number of flags supported in some cases, where it makes sense. I am speculating that the change away from --completion is that shell completion is supposed to work by default, so passing a flag to enable it seems like we want to move away from that.

TLDR: Enhancement potential here if we can make it work nicer -- I didn't experience the issue directly, but also let's not add back --completion flag, let's try to make it work well out of the box.

matteius avatar Jun 17 '22 20:06 matteius

I think this can be closed. The last maintainer had dropped the --completion flag and we don't intend to add it back. We also recently fixed a different bug around completion being broken.

matteius avatar Aug 17 '22 07:08 matteius

I am speculating that the change away from --completion is that shell completion is supposed to work by default, so passing a flag to enable it seems like we want to move away from that.

Reducing the number of flags is a very admirable goal, but unless a completion script has been sourced by bash, I'm curious how this is supposed to work by default.

(note, also came here since my shell suddenly started shooting out this error—think a deprecation plan should have been considered in this case)

Screenshot 2022-08-17 at 07 48 40@2x

dlo avatar Aug 17 '22 12:08 dlo

@dlo - The flag as removed before I started working on the project; we have no plans to add it back in to add a deprecation warning and then removing it again.

unless a completion script has been sourced by bash, I'm curious how this is supposed to work by default.

Edited: I was reopening the issue and had a half typed out comment and it posted that. I am not sure -- this was before I started and I haven't used auto completion -- I just tried it and not sure if it fully works, I can have it recommend the first commands but say I type pipenv install + tab there are no recommendations. Should there be? Either way it sounds like more thought needs to go into how to move this issue forward.

matteius avatar Aug 17 '22 13:08 matteius

I just found this and for completeness, version_greater_equal is referenced here: https://unix.stackexchange.com/a/567537

    # Set up magic shell completion for pipenv (works in bash and zsh)
    # Have to check version bc pipenv changed the implementation
    if version_greater_equal "$(pipenv --version)" "2021.11.9" ; then
        eval "$(_PIPENV_COMPLETE=zsh_source pipenv)"
    else
        eval "$(pipenv --completion)"
    fi

TauPan avatar Nov 29 '22 06:11 TauPan

https://pipenv.pypa.io/en/stable/shell/#shell-completion

Guang1234567 avatar Aug 24 '23 19:08 Guang1234567

https://pipenv.pypa.io/en/stable/shell/#shell-completion

@Guang1234567 The link is broken.

Semnodime avatar Apr 02 '24 18:04 Semnodime