Repository: pypa/pipenv

Issue:
`pipenv sync --system` failed in v2021.11.5
I use `pipenv sync --system` to install the container directly from Pipfile.lock.
But, In v2021.11.5, `pipenv sync --system` failed.

### Issue description

- `pipenv sync --system` failed.
- `pipenv install --system` failed, too.
- I first installed in virtualenv location and then installed in system. For example, `pipenv sync && pipenv sync --system`. but, I don't want to create virtualenv.

Python version is 3.8.X.

### Expected result

I expext `pipenv sync --system` to succeed as before.

### Actual result

- `pipenv sync --system`.
```
pipenv sync --system
Usage: pipenv sync [OPTIONS]

ERROR:: --system is intended to be used for pre-existing Pipfile installation, not installation of specific packages. Aborting.
```
- `pipenv install --system`.
```
pipenv install --system
Usage: pipenv install [OPTIONS] [PACKAGES]...

ERROR:: --system is intended to be used for pre-existing Pipfile installation, not installation of specific packages. Aborting.
```
- `pipenv sync && pipenv sync --system`
```
pipenv sync && pipenv sync --system
Creating a virtualenv for this project...
Pipfile: /opt/app/Pipfile
Using /usr/local/bin/python (3.8.6) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.8.6.final.0-64 in 1335ms
  creator CPython3Posix(dest=/root/.local/share/virtualenvs/app-ueEJiAOq, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/app-ueEJiAOq
Creating a Pipfile for this project...
Installing dependencies from Pipfile.lock (1d4130)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:09
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
Installing dependencies from Pipfile.lock (1d4130)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
All dependencies are now up-to-date!
```

### Steps to replicate

Pipfile.lock
```
{
    "_meta": {
        "hash": {
            "sha256": "6bb63ee956e08f88ca14bbe22f144bc6378af47f14deb5139b778e3a321d4130"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.8"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "pytz": {
            "hashes": [
                "sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c",
                "sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"
            ],
            "index": "pypi",
            "version": "==2021.3"
        }
    },
    "develop": {}
}
```

Please refer to actual result for the commands.


Discussion:
I'm seeing this on my github actions docker builds

pining pipenv fixes it

`pip3 install pipenv==2021.5.29`

```
Step 18/22 : RUN pipenv sync --system
 ---> Running in ab3324e6fc57
Installing dependencies from Pipfile.lock (b939eb)...
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/cli/command.py", line 671, in sync
    retcode = do_sync(
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 2839, in do_sync
    do_init(
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 1255, in do_init
    do_install_dependencies(
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 818, in do_install_dependencies
    batch_install(
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 682, in batch_install
    deps_to_install = [
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 683, in <listcomp>
    dep for dep in deps_to_install if not project.environment.is_satisfied(dep)
  File "/usr/local/lib/python3.8/site-packages/pipenv/project.py", line 349, in environment
    self._environment = self.get_environment(allow_global=allow_global)
  File "/usr/local/lib/python3.8/site-packages/pipenv/project.py", line 333, in get_environment
    environment = Environment(
  File "/usr/local/lib/python3.8/site-packages/pipenv/environment.py", line 72, in __init__
    self._base_paths = self.get_paths()
  File "/usr/local/lib/python3.8/site-packages/pipenv/environment.py", line 360, in get_paths
    c = subprocess_run(command)
  File "/usr/local/lib/python3.8/site-packages/pipenv/utils.py", line 2299, in subprocess_run
    return subprocess.run(
  File "/usr/local/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.8/subprocess.py", line 1706, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/root/.local/share/virtualenvs/task-rlWbeMzF/bin/python'
The command '/bin/sh -c pipenv sync --system' returned a non-zero code: 1
```

Resolving patch:
diff --git a/pipenv/core.py b/pipenv/core.py
--- a/pipenv/core.py
+++ b/pipenv/core.py
@@ -2837,6 +2837,9 @@ def do_sync(
     requirements_dir = vistir.path.create_tracked_tempdir(
         suffix="-requirements", prefix="pipenv-"
     )
+    if system:
+        project.s.PIPENV_USE_SYSTEM = True
+        os.environ["PIPENV_USE_SYSTEM"] = "1"
     do_init(
         project,
         dev=dev,


Test patch: