rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
52.69k stars 10.02k forks source link

`rustlings` command throws an error after first run #2088

Closed colinfwalsh closed 2 weeks ago

colinfwalsh commented 3 weeks ago

I wanted to report this just in case this was a simple oversight and I didn't see any similar open issues. Feel free to close if this is obvious but I figure it should be reported as a bug for those new to Rust and Cargo.

rustlings will successfully execute after running rustlings init but will fail after quitting. The error thrown is the following:

error: failed to parse manifest at `/Users/colinwalsh/code/rustlings/Cargo.toml`

Caused by:
  missing field `version`
  in `package`
Error: The command `cargo metadata …` failed. Are you in the `rustlings/` directory?

Simply adding a version="1.0.0" to the Cargo.toml file will fix the issue.

mo8it commented 2 weeks ago

This is weird. I can't reproduce it with stable, beta or nightly. The documentation of the manifest also says that version is optional and defaults to 0.0.0: https://doc.rust-lang.org/cargo/reference/manifest.html#the-version-field

I can just add the version. But I am interested in when this happens. Can you please post the output of cargo --version in your rustlings/ directory?

Maybe @epage could help? :)

epage commented 2 weeks ago

Looking at https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-version-field

MSRV: Before 1.75, this field was required

mo8it commented 2 weeks ago

Oh, I missed that sentence. Thanks!

Well, the MSRV of Rustlings is 1.80, so adding the version now won't help. I should have taken care of this in previous versions with MSRV lower than 1.75 😅

epage commented 2 weeks ago

That is only in the nightly version of the documentation. Eventually it will hit stable.