Repository: pypa/pipenv

Issue:
2021.11.9: pipenv ignores active virtual environment
### Issue description

pipenv installed in a virtual environment installs packages to the same environment despite a different virtual environment is active. This behavior is different than it was in version `v2021.5.29`. If this is correct and not a bug, how can I tell pipenv to install packages to the active venv?

### Expected result

pipenv should install packages to the active virtualenv no matter where pipenv itself is installed.

### Actual result

pipenv installs packages to the same virtualenv it's installed in even it's not active.

### Steps to replicate

Create two environments:
```
# python3 -m venv first
# python3 -m venv second
```
Install pipenv to one of them:
```
# source first/bin/activate
(first) # pip install pipenv
(first) # pip list
Package                           Version
--------------------------------- ---------
backports.entry-points-selectable 1.1.1
certifi                           2021.10.8
distlib                           0.3.3
filelock                          3.3.2
pip                               21.2.3
pipenv                            2021.11.9
platformdirs                      2.4.0
setuptools                        57.4.0
six                               1.16.0
virtualenv                        20.10.0
virtualenv-clone                  0.5.7

```
Activate the second one:
```
(first) # deactivate 
# source second/bin/activate
(second) # pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 57.4.0
```
Install some package to the active one:
```
(second) # first/bin/pipenv install tldr
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Creating a Pipfile for this project...
Installing tldr...
Adding tldr to Pipfile's [packages]...
✔ Installation Succeeded 
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Updated Pipfile.lock (497d54)!
Installing dependencies from Pipfile.lock (497d54)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 4/4 — 00:00:01
```
The package is not there:
```
(second) # pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 57.4.0
```
But it is in the first virtual environment:
```
# ls -la first/lib/python3.10/site-packages/ | grep tldr
drwxr-xr-x.  2 root root  4096 Nov  9 12:55 tldr-2.0.0.dist-info
-rw-r--r--.  1 root root 15251 Nov  9 12:55 tldr.py
```

-------------------------------------------------------------------------------

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
<details><summary>$ pipenv --support</summary>

Pipenv version: `'2021.11.9'`

Pipenv location: `'/first/lib64/python3.10/site-packages/pipenv'`

Python location: `'/first/bin/python3'`

Python installations found:

  - `3.10.0`: `/first/bin/python3`
  - `3.10.0`: `/first/bin/python`
  - `3.10.0`: `/first/bin/python3`
  - `3.10.0`: `/first/bin/python`
  - `3.10.0`: `/usr/bin/python3`
  - `3.10.0`: `/bin/python3`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.10.0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.14.16-201.fc34.x86_64',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Wed Nov 3 13:57:29 UTC 2021',
 'python_full_version': '3.10.0',
 'python_version': '3.10',
 'sys_platform': 'linux'}
```

System environment variables:

  - `HOSTNAME`
  - `DISTTAG`
  - `PWD`
  - `container`
  - `HOME`
  - `LANG`
  - `LS_COLORS`
  - `FGC`
  - `VIRTUAL_ENV`
  - `TERM`
  - `SHLVL`
  - `VIRTUAL_ENV_PROMPT`
  - `PS1`
  - `PATH`
  - `_`
  - `PIP_SHIMS_BASE_MODULE`
  - `PIP_DISABLE_PIP_VERSION_CHECK`
  - `PYTHONDONTWRITEBYTECODE`
  - `PIP_PYTHON_PATH`
  - `PYTHONFINDER_IGNORE_UNSUPPORTED`

Pipenv–specific environment variables:


Debug–specific environment variables:

  - `PATH`: `/first/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`
  - `LANG`: `C.UTF-8`
  - `PWD`: `/`
  - `VIRTUAL_ENV`: `/first`


---------------------------

Contents of `Pipfile` ('/Pipfile'):

```toml
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
tldr = "*"

[dev-packages]

[requires]
python_version = "3.10"

```


Contents of `Pipfile.lock` ('/Pipfile.lock'):

```json
{
    "_meta": {
        "hash": {
            "sha256": "0fb5484afc9a2e36e528f35bfe42b989488bcaa9c723a5a2ec3c607310497d54"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.10"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "argcomplete": {
            "hashes": [
                "sha256:291f0beca7fd49ce285d2f10e4c1c77e9460cf823eef2de54df0c0fec88b0d81",
                "sha256:2c7dbffd8c045ea534921e63b0be6fe65e88599990d8dc408ac8c542b72a5445"
            ],
            "version": "==1.12.3"
        },
        "colorama": {
            "hashes": [
                "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
                "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
            "version": "==0.4.4"
        },
        "termcolor": {
            "hashes": [
                "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b"
            ],
            "version": "==1.1.0"
        },
        "tldr": {
            "hashes": [
                "sha256:731b10bf38bb84a73560408a783b26d08ac52eab2e9a55f89dba9a3c23a72892",
                "sha256:d91d4a24de6f96359fb5ac84f41da5fcbfc6b3546f3d65a422e4bc27334f2161"
            ],
            "index": "pypi",
            "version": "==2.0.0"
        }
    },
    "develop": {}
}

```
</details>


Discussion:

Resolving patch:
diff --git a/pipenv/environments.py b/pipenv/environments.py
--- a/pipenv/environments.py
+++ b/pipenv/environments.py
@@ -357,7 +357,6 @@ def initialize(self):
         self.PIPENV_VIRTUALENV = None
         if "PIPENV_ACTIVE" not in os.environ and not self.PIPENV_IGNORE_VIRTUALENVS:
             self.PIPENV_VIRTUALENV = os.environ.get("VIRTUAL_ENV")
-            self.PIPENV_USE_SYSTEM = bool(self.PIPENV_VIRTUALENV)
 
         # Internal, tells Pipenv to skip case-checking (slow internet connections).
         # This is currently always set to True for performance reasons.


Test patch: