From 4189df0ab62f5c877e2e1edee21f5a4dbfbf827d Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Sun, 10 Dec 2017 15:09:26 -0800 Subject: [PATCH] warn user if requirements.txt is missing --- pipenv/cli.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index dcd4db1f..6fdfb750 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -1794,26 +1794,29 @@ def install( remote = True if requirements: + error, e = None, None click.echo(crayons.normal(u'Requirements file provided! Importing into Pipfile…', bold=True), err=True) try: import_requirements(r=project.path_to(requirements), dev=dev) except (UnicodeDecodeError, pip.exceptions.PipError) as e: # Don't print the temp file path if remote since it will be deleted. req_path = requirements_url if remote else project.path_to(requirements) - click.echo( - crayons.red( - u'Unexpected syntax in {0}. Are you sure this is a ' - 'requirements.txt style file?'.format(req_path) - ) - ) - click.echo(crayons.blue(str(e)), err=True) - sys.exit(1) + error = (u'Unexpected syntax in {0}. Are you sure this is a ' + 'requirements.txt style file?'.format(req_path)) + except AssertionError as e: + error = (u'Requirements file doesn\'t appear to exist. Please ensure the file exists in your ' + 'project directory or you provided the correct path.') finally: # If requirements file was provided by remote url delete the temporary file if remote: os.close(fd) # Close for windows to allow file cleanup. os.remove(project.path_to(temp_reqs)) + if error and e: + click.echo(crayons.red(error)) + click.echo(crayons.blue(str(e)), err=True) + sys.exit(1) + if code: click.echo(crayons.normal(u'Discovering imports from local codebase…', bold=True)) for req in import_from_code(code):