Skip to content

Parentheses escaping bug when running pipenv shell #4615

@leohku

Description

@leohku

Summary:

When running pipenv shell in POSIX (zsh), running /bin/activate will fail if there are parentheses in the virtualenv path due to the regex in _get_activate_script() (Line 53, pipenv/shells.py) not escaping parentheses properly.

How to reproduce the issue:

  1. Create a new directory a ( )
  2. Create .venv folder inside the directory
  3. Run pipenv install in a ( )
  4. Run pipenv shell. The issue should now be reproduced.
  5. To verify, run pipenv shell again to confirm the improper activation.

What is expected to happen:

Step 4 successfully activates virtual environment without error return code (1).

What actually happens:

Step 4 output:

$ pipenv shell
Launching subshell in virtual environment...
 . /Users/leohku/a\ (\ )/.venv/bin/activate
zsh: no matches found: /Users/leohku/a ( )/.venv/bin/activate

Step 5 output:

$ pipenv shell
Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.
No action taken to avoid nested environments.

Environment:

pipenv, version 2020.11.15
running zsh on macOS Big Sur v11.1 x86

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions