From 3fe5061682ed805db18a4104cd186b5e9eea9a8a Mon Sep 17 00:00:00 2001 From: Adam Goldschmidt Date: Sun, 20 Jan 2019 13:09:28 +0200 Subject: [PATCH] conservative check for known exceptions in subprocess stderr. --- pipenv/core.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 768e7ee7..9dd2784e 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -925,9 +925,17 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None): ) click.echo(crayons.blue("{0}".format(c.out)), err=True) if c.returncode != 0: - sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(u"Failed creating virtual environment")) + sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed creating virtual environment")) + known_exceptions = { + "PermissionError": "Permission denied:", + } + # PermissionError - hide the traceback for better UX + for partition in (part + for e, part in known_exceptions.items() if e in c.err): + known_exceptions_partition = c.err.rpartition(partition) + c.err = "{} {}".format(known_exceptions_partition[1], known_exceptions_partition[2]) raise exceptions.VirtualenvCreationException( - extra=[crayons.blue("{0}".format(c.err)),] + extra=[crayons.red("{0}".format(c.err)),] ) else: