Repository: pypa/pipenv

Issue:
Support `--system` to `pipenv sync`
I'm trying to install dependencies inside of tox, which I believe needs `--system` (to install into tox's virtualenv instead of into pipenvs own virtualenv). See also #154.

However, `pipenv sync`, which is the new way to install dependencies from `Pipfile.lock` does not support `--system` (it seems it was intentionally left out initially in #1463), so I have to resort to `pipenv install`.

It seems it would be useful to support `--system` for sync as well.



Discussion:
+1
I just tried aca8e1238e93aeb42ce20c660f3ec5d7ec4b5479 from @frostming's branch, and it works as expected in my usecase (see https://travis-ci.org/evolution-events/Artaxerxes/jobs/382857314). Thanks!
Hey, just in case pipenv uses Tox's virtualenv directly, with no intervention needed. ( for example https://circleci.com/gh/txomon/mosbot/17) 
I really would appreciate having `pipenv sync --system` as well. This would be the preferred way to use pipenv in a Docker container. At the moment I'm using `pipenv install --system --deploy` which is not as great of a solution.

It seems that this issue has stalled. Would it make sense to take 
https://github.com/pypa/pipenv/commit/aca8e1238e93aeb42ce20c660f3ec5d7ec4b5479 and make a PR from it?
Is there any difference between `pipenv install --ignore-pipfile` and `pipenv sync`?

I'm currently using `pipenv install --system --ignore-pipfile` when I want to install dependencies from the Pipfile.lock into the system.

**Update**: Found an explanation in #3150, it seems that using the `pipenv install --system --ignore-pipfile --deploy` should be equivalent to `pipenv sync`
I've managed to get `pipenv sync` and `pipenv install --system --ignore-pipfile --deploy` to mostly function under `tox`, but if I'm running directly through tox then something always fails to install and it never recovers. If I go into the virtualenv then everything installs just fine.
+1
there is a workaround which I'm using in my deployments.

in CI, I will check if `Pipfile.lock` and `Pipfile` are in sync in a CI pipeline during tests:

```shell
pipenv install --deploy
```

then, during creation of Docker images, I don't include `Pipfile` and use `pipenv install --ignore-pipfile --deploy --system`. 

```shell
rm Pipefile
touch Pipefile
pipenv install --ignore-pipfile --deploy --system
```

It is the fastest method I found.


Resolving patch:
diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py
--- a/pipenv/cli/command.py
+++ b/pipenv/cli/command.py
@@ -664,6 +664,7 @@ def run_open(state, module, *args, **kwargs):
     short_help="Installs all packages specified in Pipfile.lock.",
     context_settings=CONTEXT_SETTINGS
 )
+@system_option
 @option("--bare", is_flag=True, default=False, help="Minimal output.")
 @sync_options
 @pass_state
@@ -691,6 +692,7 @@ def sync(
         unused=unused,
         sequential=state.installstate.sequential,
         pypi_mirror=state.pypi_mirror,
+        system=state.system
     )
     if retcode:
         ctx.abort()
diff --git a/pipenv/core.py b/pipenv/core.py
--- a/pipenv/core.py
+++ b/pipenv/core.py
@@ -2883,6 +2883,7 @@ def do_sync(
     )
     do_init(
         dev=dev,
+        allow_global=system,
         concurrent=(not sequential),
         requirements_dir=requirements_dir,
         ignore_pipfile=True,  # Don't check if Pipfile and lock match.


Test patch: