Error: failed to parse manifest at .......Desktop/Cargo.toml`

Hi, I've been running my codes as usual and from the last time I terminated it to amend the code a bit and when I tried to rerun it gave an explicit error at first
,,,,,,,,,
error: failed to parse manifest at .......Desktop/Cargo.toml`
,,,,,,

After which I tried to include in my cargo.toml file section to drive cargo to the path of the main.rs file
,,,,
[bin]
name = "main"
path = "src/main.rs"
,,,,,

But it gave this error
.........
error: invalid type: map, expected a sequence
--> Cargo.toml:12:1
|
12 | / [bin]
13 | | name = "main"
14 | | path = "src/main.rs"
| |____________________^
,,,,,,,,,

Please any pointers to where this problem emanates from?
Note I uninstalled the nightly build I install just some hours before to check if it was the cause but the problem persists..... I would appreciate any guide to solving this

This path means that either you have a stray Cargo.toml in your Desktop folder, or that you are developing your project files in your Desktop folder. These are both bad ideas; you should create a folder that is for your project and move all its files (Cargo.toml and src/) in that folder.

(And make sure that you have no extraneous Cargo.toml files in any parent directory.)

This is because you wrote [bin] (a table with the name bin) instead of [[bin]] (a table in a list named bin). This syntax is required because a single Cargo manifest can define many binary targets.

However, you do not need to write a [[bin]] section at all. src/main.rs is the default path used by target auto-discovery so everything you tried to tell Cargo is already the default. This syntax error is just hiding whatever the other error is.

Please remove the [bin] section and show us the full text of the error you originally got — you can redact the paths but we need to see the rest of the failure to parse. Also, please take a look at how to format code blocks on this forum; you need to use the ` character, not the , character.

This did it for me, I was kinda messy with the replacement of the cargo file leaving it on my desktop and other places but as soon as I removed all of them and put them in one place everything started working well... Thanks @kpreid

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.