Repository: pypa/pipenv

Issue:
`pipenv install` with no arguments results in UnboundLocalError
```
$ pipenv install
Creating a Pipfile for this project...
Creating a virtualenv for this project...
⠋Using base prefix '/usr'
New python executable in /home/josh/.local/share/virtualenvs/pipenv-test-42RWOVQR/bin/python3
Also creating executable in /home/josh/.local/share/virtualenvs/pipenv-test-42RWOVQR/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/josh/.local/share/virtualenvs/pipenv-test-42RWOVQR
No package provided, installing all dependencies.
Pipfile found at /tmp/pipenv-test/Pipfile. Considering this to be the project home.
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
⠸Locking [packages] dependencies...
⠴Updated Pipfile.lock!
Installing dependencies from Pipfile.lock...
[================================] 0/0 - 00:00:00
Traceback (most recent call last):
  File "/home/josh/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 827, in install
    do_init(dev=dev, allow_global=system, ignore_hashes=ignore_hashes, ignore_pipfile=ignore_pipfile)
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 616, in do_init
    ignore_hashes=ignore_hashes)
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 279, in do_install_dependencies
    if c.return_code != 0:
UnboundLocalError: local variable 'c' referenced before assignment
```

Presumably, the fix to this would be to indent [lines 279–285 of cli.py](https://github.com/kennethreitz/pipenv/blob/master/pipenv/cli.py#L279,L285) to be included in the `if len(vcs_deps):`.


Discussion:
I've run into this myself. 
@kennethreitz do you recall why `if len(vcs_deps)` was added? If not, I don't see a reason why we can't remove it. Otherwise, the other option is to indent the error handling inside of that conditional.
Is there a workaround until this is fixed?
@iandees, we're currently having some trouble with our CI, but I have a patch ready to go for this. I'm going to try to get a bugfix release out in the next few hours.
Ok great, thanks @nateprewitt!
@nateprewitt should be working now

Resolving patch:
diff --git a/pipenv/cli.py b/pipenv/cli.py
--- a/pipenv/cli.py
+++ b/pipenv/cli.py
@@ -249,20 +249,19 @@ def do_install_dependencies(dev=False, only=False, bare=False, requirements=Fals
                 del v['hash']
 
     # Convert the deps to pip-compatible arguments.
-    hashed_deps = convert_deps_to_pip(deps, r=False)
-    vcs_deps_path = convert_deps_to_pip(vcs_deps)
+    deps_list = [(d, ignore_hashes) for d in convert_deps_to_pip(deps, r=False)]
+    if len(vcs_deps):
+        deps_list.extend((d, True) for d in convert_deps_to_pip(vcs_deps, r=False))
 
     # --requirements was passed.
     if requirements:
-        click.echo('\n'.join(hashed_deps))
-        with open(vcs_deps_path) as f:
-            click.echo(f.read())
+        click.echo('\n'.join(deps_list))
         sys.exit(0)
 
     # pip install:
-    for dep in progress.bar(hashed_deps):
+    for dep, ignore_hash in progress.bar(deps_list):
 
-        c = pip_install(dep, ignore_hashes=ignore_hashes, allow_global=allow_global)
+        c = pip_install(dep, ignore_hashes=ignore_hash, allow_global=allow_global)
 
         if c.return_code != 0:
             click.echo(crayons.red('An error occured while installing!'))
@@ -271,25 +270,9 @@ def do_install_dependencies(dev=False, only=False, bare=False, requirements=Fals
             click.echo(crayons.blue(format_pip_error(c.err)))
             if 'PACKAGES DO NOT MATCH THE HASHES' in c.err:
                 click.echo(crayons.yellow('You can supply the --ignore-hashes option to '
-                                        '\'pipenv install\' to bypass this feature.'))
+                    '\'pipenv install\' to bypass this feature.'))
             sys.exit(c.return_code)
 
-    if len(vcs_deps):
-        with spinner():
-            c = pip_install(r=vcs_deps_path, ignore_hashes=True, allow_global=allow_global)
-
-    if c.return_code != 0:
-        click.echo(crayons.red('An error occured while installing!'))
-        click.echo(crayons.blue(format_pip_error(c.err)))
-        if 'PACKAGES DO NOT MATCH THE HASHES' in c.err:
-            click.echo(crayons.yellow('You can supply the --ignore-hashes option to '
-                                      '\'pipenv install\' to bypass this feature.'))
-        sys.exit(c.return_code)
-
-    # Cleanup the temp requirements file.
-    if requirements:
-        os.remove(vcs_deps_path)
-
 
 def do_download_dependencies(dev=False, only=False, bare=False):
     """"Executes the download functionality."""


Test patch:
diff --git a/tests/test_project.py b/tests/test_project.py
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -1,6 +1,3 @@
-from hashlib import sha256
-from base64 import urlsafe_b64encode
-
 import delegator
 
 import pipenv.project
@@ -10,13 +7,9 @@ class TestProject():
 
     def test_project(self):
         proj = pipenv.project.Project()
-        hash = urlsafe_b64encode(
-            sha256(proj.pipfile_location.encode()).digest()[:6]).decode()
 
-        # assert proj.name == 'pipenv'
         assert proj.pipfile_exists
         assert proj.virtualenv_exists
-        # assert proj.virtualenv_name == 'pipenv-' + hash
 
     def test_proper_names(self):
         proj = pipenv.project.Project()