Skip to content

Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated. #6220

@bakemocho

Description

@bakemocho

Issue description

When deactivating a virtual environment created by pipenv shell and then trying to reactivate it using pipenv shell, I receive the error:

Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.
New shell not activated to avoid nested environments.

However, running unset PIPENV_ACTIVE resolves the issue. Modifying the deactivate function in the virtual environment's activate script to include unset PIPENV_ACTIVE also works.

Expected result

The virtual environment should reactivate without errors when running pipenv shell after deactivating it.

Actual result

The error message is displayed, and the virtual environment is not reactivated.

Steps to replicate

  1. Create and activate a virtual environment using pipenv shell.
  2. Deactivate the environment using the deactivate command.
  3. Attempt to reactivate the environment using pipenv shell.

System details

  • OS: Darwin Machinename.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:17:33 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6031 arm64
  • pyenv version: pyenv 2.4.7
  • pipenv version: pipenv, version 2024.0.1
  • Python version: Python 3.12.4

Additional information

To resolve the issue temporarily, adding unset PIPENV_ACTIVE to the deactivate function in the virtual environment's activate script works. However, this seems to be an issue with pipenv itself.

pipenv_support.md

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions