poetry: 'Key "extras" does not exist.'
-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: Mac Catalina 10.15.7
-
Poetry version: 1.1.11
-
Link of a Gist with the contents of your pyproject.toml file:
Issue
after multiple times building & upgrading my python package, poetry gives me a following error when i run poetry install: Installing dependencies from lock file
Package operations: 0 installs, 6 updates, 0 removals
• Updating importlib-metadata (1.7.0 -> 4.8.1) • Updating pyrsistent (0.17.3 -> 0.18.0) • Updating jsonschema (3.2.0 -> 4.1.2) • Updating charset-normalizer (2.0.0 -> 2.0.7) • Updating idna (3.1 -> 3.3) • Updating cffi (1.14.6 -> 1.15.0)
Installing the current project: FCDproc (0.9.0) NonExistentKey
‘Key “extras” does not exist.’
at ~/opt/anaconda3/envs/fcdproc/lib/python3.7/site-packages/tomlkit/container.py:553 in getitem 549│ key = Key(key) 550│ 551│ idx = self._map.get(key, None) 552│ if idx is None: → 553│ raise NonExistentKey(key) 554│ 555│ if isinstance(idx, tuple): 556│ # The item we are getting is an out of order table 557│ # so we need a proxy to retrieve the proper objects
i am not sure why this is coming up now. any suggestion how i can fix this?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (5 by maintainers)
This issue is not fixed, https://github.com/python-poetry/poetry-core/pull/404 should take care of it.
The issue is that before https://github.com/python-poetry/poetry-core/pull/40, the only use of the dictionary format for scripts was to add
extras
, as documented at https://python-poetry.org/docs/master/pyproject#scripts (still), so it is not surprising (but was still kind-of a bug) thatextras
was a required key, even though it was only being enforced by accident. That was the original bug, that this ticket was opened for in Poetry 1.1:has no reason not to be equivalent to
as none of the other uses of toml inline tables in Poetry would distinguish these cases.
The Poetry docs weren’t updated for https://github.com/python-poetry/poetry-core/pull/40 yet, but from that change, Poetry 1.2 introduced a new use of the dictionary format for scripts, the
type
key, which is @shubb30’s issue above. This has produced a new way to trigger the same underlying issue.The code in poetry-core was already mostly-correct (The actual stack-trace hit in the original bug report was fixed in https://github.com/python-poetry/poetry-core/pull/177), so the only missed spot appears to be
Factory.validate
which https://github.com/python-poetry/poetry-core/pull/404 is fixing.@ShervinAbd92, it doesn’t look like you attached your pyproject.toml to this issue. I don’t think attachments to email replies to GitHub get added to the GitHub issue.
I was running into the same issue, and I eventually figured out it was because I had a TOML key that had a period (
.
) in the name, which actually gets parsed as a nested property. E.g. I had something like:which ended up being parsed as something equivalent to
Putting quotes around the key allowed me to work past the issue I was facing, so if you have something similar in your pyproject.toml, you might try adding quotes.