I'm reviewing a GUI framework (Rustbox) and while I was writing my first example, I encountered this Cargo error:
error: failed to parse manifest at `/home/willem/p/rust/gui-reviews/reviews/rustbox/Cargo.toml`
Caused by:
no `package` or `project` section found.
The content of my Cargo.toml:
[dependencies]
rustbox = "*"
[[bin]]
name = "window"
path = "src/window.rs"
Now, I am aware that I am missing the [package] section, I've since added it, but I'm puzzled by the error message I got. What is a [project] section? I looked at the documentation on the Cargo.toml Manifest Format here but it did not contain a section on [project].
I found references to the [project] section in these three files:
https://github.com/rust-lang/cargo/blob/master/tests/metadata.rs
https://github.com/rust-lang/cargo/blob/master/tests/build.rs
https://github.com/rust-lang/cargo/blob/master/src/cargo/util/toml.rs
Does this section still exist but missing in the docs, did I read the docs badly, or does this section no longer exist and is the error erroneous?
Instructions to fix added by @carols10cents:
This is still an issue as of cargo 0.23.0-nightly (8118b02ac 2017-09-14). If your Cargo.toml doesn't have a [package] section and you run cargo build, the error message says:
no `package` or `project` section found.
The error message should instead say:
no `package` section found.
The error message comes from this spot: https://github.com/rust-lang/cargo/blob/7da5c847776913c3a499d62753903b9ae8451639/src/cargo/util/toml/mod.rs#L516
And then these two tests will need to be updated:
[package] used to be called [project] long ago, but was re-named. It still works, technically.
The error isn't erroneous but probably shouldn't suggest deprecated things.
Ah yeah we at one point had a vision for distinguishing between these two sections, but at this point they're just synonymous (the distinction was never implemented). We should probably change the error message to just mention the one generated by cargo new
Most helpful comment
Ah yeah we at one point had a vision for distinguishing between these two sections, but at this point they're just synonymous (the distinction was never implemented). We should probably change the error message to just mention the one generated by
cargo new