Common causes
1. The same section pasted twice
Installation instructions often show a complete [dependencies] section. Add the new lines to the existing section instead of pasting the header again.
[dependencies]
serde = "1"
[dependencies]
tokio = "1"[dependencies]
serde = "1"
tokio = "1"2. A table header after an inline table of the same name
server = { host = "x" } already defines the table server, and inline tables cannot be extended later. Use one style for the whole table.
server = { host = "0.0.0.0" }
[server]
port = 8080[server]
host = "0.0.0.0"
port = 80803. Mixing [[array]] and [table] for the same name
[[bin]] declares an array of tables, so a later [bin] tries to redefine it as a plain table. Repeat the double-bracket form for every element.
[[bin]]
name = "ingest"
[bin]
name = "export"[[bin]]
name = "ingest"
[[bin]]
name = "export"Frequently asked questions
Can I define [a.b] before [a]?
Yes. Defining a sub-table first and its parent later is valid, as long as the parent header appears only once and does not redefine keys the sub-table header already created.
Why does tomllib show a tuple like ('dependencies',)?
tomllib describes table paths as Python tuples of key names. (‘tool’, ‘poetry’) would mean the [tool.poetry] table.
How do I add many entries to the same table across a file?
You cannot reopen a table in TOML. Keep all of its keys under one header, or define the whole table with dotted keys in the root (dependencies.serde = “1”) and no header at all; the two styles cannot be mixed for the same table.