Repository: pypa/pipenv

Issue:
NameError: name 'resolver' is not defined
Be sure to check the existing issues, both open and closed.

I encounter a NameError on locking my Pipfile.

```
Traceback (most recent call last):
  File "/home/stephen-bunn/.local/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==9.0.0', 'console_scripts', 'pipenv')()
  File "/home/stephen-bunn/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/stephen-bunn/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/stephen-bunn/.local/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/stephen-bunn/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/stephen-bunn/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/stephen-bunn/.local/lib/python3.6/site-packages/pipenv/cli.py", line 2054, in lock
    do_lock(verbose=verbose, clear=clear, pre=pre)
  File "/home/stephen-bunn/.local/lib/python3.6/site-packages/pipenv/cli.py", line 1099, in do_lock
    pre=pre
  File "/home/stephen-bunn/.local/lib/python3.6/site-packages/pipenv/utils.py", line 593, in resolve_deps
    collected_hashes = list(list(resolver.resolve_hashes([result]).items())[0][1])
NameError: name 'resolver' is not defined
```

##### Describe your environment

1. OS Type: `Ubuntu 17.10`
1. Python version: `3.6.3`
1. Pipenv version: `9.0.0`

##### Expected result

I would prefer for there not to be a NameError 😢 

##### Actual result

This issue relates to the `ibm-db-sa-py3` package where the required version `0.3.1-1` _technically_ doesn't exist (I'm sure I'm the only person using it).
[For reference](https://pypi.org/pypi/ibm-db-sa-py3/json)

##### Steps to replicate

Here is my Pipfile contents, locking them should cause this error.

```
[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true


[packages]

simplejson = "*"
json-log-formatter = "*"
jsonschema = "*"
camel = "*"
pyyaml = "*"
pyexcel = "*"
pyexcel-io = "*"
pyexcel-xlsx = "*"
sqlparse = "*"
sqlalchemy = "*"
sqlalchemy-postgres-copy = "*"
"psycopg2" = "*"
pymssql = "*"
celery = "*"
kombu = "*"
redis = "*"
walrus = "*"
flower = "*"
requests = "*"
dateparser = "*"
emails = "*"
pysftp = "*"
pysmb = "*"
psutil = "*"
simple-salesforce = "*"
"ibm-db-sa-py3" = "==0.3.1-1"
pyodbc = "==3.1.1"


[dev-packages]

ptpython = "*"
"flake8" = "*"
nose = "*"
coverage = "*"
cprofilev = "*"
sphinx = "*"
sphinx-rtd-theme = "*"
pypager = "*"
prompt-toolkit = "*"
pygments = "*"
colorama = "*"
invoke = "*"
pytest = "*"
pytest-cov = "*"
"pytest-flake8" = "*"
```



Discussion:

Resolving patch:
diff --git a/pipenv/utils.py b/pipenv/utils.py
--- a/pipenv/utils.py
+++ b/pipenv/utils.py
@@ -523,7 +523,8 @@ class PipCommand(pip.basecommand.Command):
 
         raise RuntimeError
 
-    return resolved_tree
+    return resolved_tree, resolver
+
 
 def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, python=False, clear=False, pre=False):
     """Given a list of dependencies, return a resolved list of dependencies,
@@ -542,7 +543,7 @@ def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, p
     with HackedPythonVersion(python_version=python, python_path=python_path):
 
         try:
-            resolved_tree = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre)
+            resolved_tree, resolver = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre)
         except RuntimeError:
             # Don't exit here, like usual.
             resolved_tree = None
@@ -554,12 +555,11 @@ def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, p
             try:
                 # Attempt to resolve again, with different Python version information,
                 # particularly for particularly particular packages.
-                resolved_tree = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre)
+                resolved_tree, resolver = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre)
             except RuntimeError:
                 sys.exit(1)
 
 
-
     for result in resolved_tree:
         if not result.editable:
             name = pep423_name(result.name)


Test patch:
diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py
--- a/tests/test_pipenv.py
+++ b/tests/test_pipenv.py
@@ -498,6 +498,23 @@ def test_sequential_mode(self):
             c = p.pipenv('run python -c "import requests; import idna; import certifi; import records; import tpfd; import parse;"')
             assert c.return_code == 0
 
+    @pytest.mark.install
+    @pytest.mark.resolver
+    @pytest.mark.backup_resolver
+    def test_backup_resolver(self):
+        with PipenvInstance() as p:
+            with open(p.pipfile_path, 'w') as f:
+                contents = """
+[packages]
+"ibm-db-sa-py3" = "==0.3.1-1"
+                """.strip()
+                f.write(contents)
+
+            c = p.pipenv('install')
+            assert c.return_code == 0
+            assert 'ibm-db-sa-py3' in p.lockfile['default']
+
+
     @pytest.mark.sequential
     @pytest.mark.install
     @pytest.mark.update