From eafcfb2c1ea8e9ba9b61fdaab923c0f2c65fb114 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Wed, 17 Nov 2021 00:06:13 +0800 Subject: [PATCH] Fix a bug of deleting a virtualenv that is not managed by Pipenv Close #4867 --- news/4867.bugfix.rst | 1 + pipenv/cli/command.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 news/4867.bugfix.rst diff --git a/news/4867.bugfix.rst b/news/4867.bugfix.rst new file mode 100644 index 0000000000..4d949632fc --- /dev/null +++ b/news/4867.bugfix.rst @@ -0,0 +1 @@ +Fix a bug of deleting a virtualenv that is not managed by Pipenv. diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index 24d8c0e612..a3910b22e3 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -1,6 +1,7 @@ import os import sys +from pipenv import environments from pipenv.__version__ import __version__ from pipenv._compat import fix_utf8 from pipenv.cli.options import ( @@ -124,7 +125,7 @@ def cli( # --rm was passed... elif rm: # Abort if --system (or running in a virtualenv). - if state.project.s.PIPENV_USE_SYSTEM: + if state.project.s.PIPENV_USE_SYSTEM or environments.is_in_virtualenv(): echo( crayons.red( "You are attempting to remove a virtualenv that "