Skip to content

pipenv uninstall <package> --dev throws 'NonExistentKey' exception #6312

Open
@marwin-roth

Description

@marwin-roth

Issue description

When I want to remove a dev-package from the Pipfile and Pipfile.lock, I ran the command pipenv uninstall <package> --dev. The docs state, that pipenv uninstall takes the same arguments as pipenv install.

Expected result

Uninstall the dev-package and remove it from the Pipfile and Pipfile.lock.

Actual result

Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
             ~~~^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/cli/options.py", line 52, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/cli/command.py", line 288, in uninstall
    retcode = do_uninstall(
        state.project,
    ...<10 lines>...
        ctx=ctx,
    )
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/routines/uninstall.py", line 130, in do_uninstall
    if project.remove_package_from_pipfile(
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        normalized_name, category=pipfile_category
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ):
    ^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/project.py", line 1119, in remove_package_from_pipfile
    del p[category][name]
        ~~~~~~~~~~~^^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/tomlkit/items.py", line 1502, in __delitem__
    self.remove(key)
    ~~~~~~~~~~~^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/tomlkit/items.py", line 1472, in remove
    self._value.remove(key)
    ~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv/vendor/tomlkit/container.py", line 352, in remove
    raise NonExistentKey(key)
pipenv.vendor.tomlkit.exceptions.NonExistentKey: 'Key "ruff" does not exist.'

Steps to replicate

Contents of Pipfile:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = ">=2.27.0,<2.30.0"
pydantic = ">=1.9.0,<2.0"

[dev-packages]
vcrpy = "*"
build = "*"
twine = "*"
bump2version = "*"
pytest-cov = "*"
exceptiongroup = "*"
tomli = "*"
ruff = "*"

I tried it with the ruff package. Installed it with pipenv install ruff --dev. It was added to the Pipfile and Pipfile.lock. Then tried to remove it with pipenv uninstall ruff --dev, which threw the error above.


$ pipenv --support

Pipenv version: '2024.4.0'

Pipenv location: '/usr/local/Cellar/pipenv/2024.4.0/libexec/lib/python3.13/site-packages/pipenv'

Python location: '/usr/local/Cellar/pipenv/2024.4.0/libexec/bin/python'

OS Name: 'posix'

User pip version: '24.3.1'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.13.0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '23.5.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 23.5.0: Wed May  1 20:09:52 PDT '
                     '2024; root:xnu-10063.121.3~5/RELEASE_X86_64',
 'python_full_version': '3.13.0',
 'python_version': '3.13',
 'sys_platform': 'darwin'}

System environment variables:

  • COMMAND_MODE
  • TERM_SESSION_ID
  • LC_CTYPE
  • SHELL
  • __CFBundleIdentifier
  • TMPDIR
  • HOME
  • SSH_AUTH_SOCK
  • PATH
  • XPC_SERVICE_NAME
  • TERM
  • LOGNAME
  • USER
  • XPC_FLAGS
  • __CF_USER_TEXT_ENCODING
  • TERMINAL_EMULATOR
  • SHLVL
  • PWD
  • OLDPWD
  • ZSH
  • PAGER
  • LESS
  • LSCOLORS
  • LS_COLORS
  • KUBE_CONFIG_PATH
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PIPENV_ACTIVE
  • PS1
  • _
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_ACTIVE: 1

Debug–specific environment variables:

  • PATH: /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
  • SHELL: /bin/zsh
  • PWD: /Users/marwin.roth/IdeaProjects/sdk

Metadata

Metadata

Assignees

No one assigned

    Labels

    Contributor CandidateThe issue has been identified/triaged and contributions are welcomed/encouraged.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions