From aefaff9f12f0919dce5022fca7511417101dc1b4 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 22 Apr 2018 11:24:10 -0400 Subject: [PATCH] Fix buggy implementation of `--system` check Signed-off-by: Dan Ryan --- pipenv/core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 73932de6..31538033 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -69,6 +69,7 @@ from .environments import ( PIPENV_DOTENV_LOCATION, PIPENV_SHELL, PIPENV_PYTHON, + PIPENV_VIRTUALENV, ) # Backport required for earlier versions of Python. @@ -247,12 +248,12 @@ def import_from_code(path='.'): def ensure_pipfile(validate=True, skip_requirements=False, system=False): """Creates a Pipfile for the project, if it doesn't exist.""" - global USING_DEFAULT_PYTHON + global USING_DEFAULT_PYTHON, PIPENV_VIRTUALENV # Assert Pipfile exists. python = which('python') if not (USING_DEFAULT_PYTHON or system) else None if project.pipfile_is_empty: # Show an error message and exit if system is passed and no pipfile exists - if system: + if system and not PIPENV_VIRTUALENV: click.echo( '{0}: --system is intended to be used for pre-existing Pipfile ' 'installation, not installation of specific packages. Aborting.'.format( @@ -1756,7 +1757,7 @@ def do_install( keep_outdated = project.settings.get('keep_outdated') remote = requirements and is_valid_url(requirements) # Warn and exit if --system is used without a pipfile. - if system and package_name: + if system and package_name and not PIPENV_VIRTUALENV: click.echo( '{0}: --system is intended to be used for Pipfile installation, ' 'not installation of specific packages. Aborting.'.format(