Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipenv update fails if freeze output contains comments #1268

Merged
merged 1 commit into from
Jan 11, 2018

Conversation

mkai
Copy link
Contributor

@mkai mkai commented Jan 4, 2018

If the output of pip freeze contains comments (e. g. a line like ## !! Could not determine repository location), then the pipenv update command fails when it tries to parse the requirements:

(project-cIS5-zzV) bash-3.2$ pipenv update -d
Updating all dependencies from Pipfile…
Traceback (most recent call last):
  File "/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/.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 "/.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 "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 2559, in update
    do_purge()
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 1230, in do_purge
    dep = convert_deps_from_pip(package)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/utils.py", line 624, in convert_deps_from_pip
    req = get_requirement(dep)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/utils.py", line 311, in get_requirement
    req = [r for r in requirements.parse(dep)][0]
IndexError: list index out of range

It tries to make sense of the ## "requirement", which fails.

This commit adds a simple fix to ignore comments in the pip freeze output.

If the output of ``pip freeze`` contains comments (e. g. a line like ``## !! Could not determine repository location``), then the ``pipenv update`` command fails when it tries to parse the requirements:

``python
(project-cIS5-zzV) bash-3.2$ pipenv update -d
Updating all dependencies from Pipfile…
Traceback (most recent call last):
  File "/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/.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 "/.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 "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 2559, in update
    do_purge()
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 1230, in do_purge
    dep = convert_deps_from_pip(package)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/utils.py", line 624, in convert_deps_from_pip
    req = get_requirement(dep)
  File "/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/utils.py", line 311, in get_requirement
    req = [r for r in requirements.parse(dep)][0]
IndexError: list index out of range
``

It tries to make sense of the ``##`` "requirement", which fails.

This commit adds a simple fix to ignore comments in the ``pip freeze`` output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants