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

Error message should only recommend package, not project #3388

Closed
ghost opened this issue Dec 12, 2016 · 2 comments · Fixed by #4579
Closed

Error message should only recommend package, not project #3388

ghost opened this issue Dec 12, 2016 · 2 comments · Fixed by #4579
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug E-easy Experience: Easy T-cargo Team: Cargo

Comments

@ghost
Copy link

ghost commented Dec 12, 2016

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 (8118b02 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:

CargoError::from("no `package` or `project` section found.")

And then these two tests will need to be updated:

@steveklabnik
Copy link
Member

[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.

@alexcrichton
Copy link
Member

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

@carols10cents carols10cents changed the title No [project] section documentation / out-of-date error message Error message should only recommend package, not project Sep 29, 2017
@carols10cents carols10cents added A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug E-easy Experience: Easy E-help-wanted T-cargo Team: Cargo labels Sep 29, 2017
bors added a commit that referenced this issue Oct 4, 2017
Fix error message when Cargo.toml misses a [package] section

Fixes #3388.
@bors bors closed this as completed in #4579 Oct 4, 2017
bors added a commit that referenced this issue Sep 27, 2022
Reduce references to `[project]` within cargo

There was an issue (#11129) with `[project]` being put in the docs but nothing else stating what `[project]` is. This was an oversight by me when writing the docs as `[project]` is still supported in cargo. [Back in 2014](86b2a2a) `[project]` was [renamed to `[package]`](#3388 (comment)), since then it has kinda sat as something that exists and is supported but not really. I brought this up in a [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/removal.20of.20.60.5Bproject.5D.60), and it was suggested that we could show a warning when `[project]` is used in a manifest of a _top-level_ crate.

To go slightly further than this I tried to change as many references from `[project]` to `[package]` as possible. This should hopefully help with confusion between `[project]` and `[package]` in the future.

This PR also includes a cherry-picked commit from #11131 as it was having issues with bors and fits well with the changes that are being made in this PR.

This should ideally be reviewed commit by commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug E-easy Experience: Easy T-cargo Team: Cargo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants