Skip to content

--skip-lock: tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.' #4141

Closed
@schuhschuh

Description

@schuhschuh

Issue description

When using pipenv install --skip-lock, I get the error

tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.'

because there is no [[source]] defined in the Pipfile.

The culprit is the following line of code from pipenv.project.Project.get_lockfile_meta:

sources = [dict(source) for source in self.parsed_pipfile["source"]]

which requires source key to be present in parsed Pipfile.

Workaround, add default [[source]] section for PyPI to your Pipfile:

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

Expected result

A [[source]] section should not be required and installation proceed as normal.

Actual result

Installing dependencies from Pipfile…
Traceback (most recent call last):
  File "/opt/miniconda3/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/cli/command.py", line 254, in install
    editable_packages=state.installstate.editables,
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/core.py", line 1874, in do_install
    keep_outdated=keep_outdated
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/core.py", line 1253, in do_init
    pypi_mirror=pypi_mirror,
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/core.py", line 795, in do_install_dependencies
    lockfile = project.get_or_create_lockfile(from_pipfile=True)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/project.py", line 754, in get_or_create_lockfile
    lockfile_dict.update({"_meta": self.get_lockfile_meta()})
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/project.py", line 790, in get_lockfile_meta
    sources = [dict(source) for source in self.parsed_pipfile["source"]]
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/tomlkit/container.py", line 500, in __getitem__
    raise NonExistentKey(key)
tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.'

Steps to replicate

Example Pipfile:

[packages]
pytest = "*"
tox = "*"

Run pipenv install --skip-lock.


Pipenv version: '2018.11.26'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug 🐛This issue is a bug.good first issueIssues suitable as a newcomer to get familiar with Pipenv!

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions