rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.14k stars 884 forks source link

Unintelligible Error Messages Make Troubleshooting Rust Impossible - Please FIX! #3124

Open Librechain opened 1 year ago

Librechain commented 1 year ago

Problem you are trying to solve

This needs to be fixed. I've had to spend over an hour trying to install ONE crate. First, I thought I had to update my version of Rust. No problem. But wait, no - I'm on the "wrong channel", so now I have to switch to Nightly.

Ok...no biggie. rustup default nightly. Okay, great. Finally, let's download this project and get running.

NOPE. Another compilation error. Apparently, cargo-features = ["edition2021"] isn't added. But wtf does that mean? Is this an environment variable? Does this get added to a Cargo.toml? If so, which one? I'm in the root of the project directory I'm trying to use. I'm also not understanding where Rust is seeing that I need to opt for this edition as a default. Also, if so, what's the big deal? Its 2022 right now. No matter, I'm being literal.

I need to download this project, so let's play along and see what's going on here. I run the command again and pay a little more attention to the output this time.

    Updating crates.io index
error: failed to download `pest v2.5.1`

Caused by:
  unable to get packages from source

Caused by:
  failed to parse manifest at `/home/libre/.cargo/registry/src/github.com-1ecc6299db9ec823/pest-2.5.1/Cargo.toml`

Caused by:
  feature `edition2021` is required

  this Cargo does not support nightly features, but if you
  switch to nightly channel you can add
  `cargo-features = ["edition2021"]` to enable this feature

Now I'm starting to rage a little bit. What do you mean, "this cargo does not support nightly features, but if you switch to nightly channel you can add cargo-features = ["edition2021"] to enable this feature"?

After I carefully read that sentence 2-3 times, I'm now really raging because I don't understand what the fuck it means in plain English because its worded so poorly.

edit: Sorry for profanity but we're adults and I'm not calling anyone names here, so please do not dilute / wave off my issue for some profanity. That's worse than the profanity itself

  1. "This cargo does not support nightly features" - Ok, so why tf do I need to use a nightly feature? Now, I'm thoroughly confused as to what's going on. This has gone from git cloning a simple project and running cargo build & a couple of other commands (or so I thought), to an actual fishing expedition.
  2. "..but if you switch to nightly channel" - I thought I just did that. I explicitly ran rustup default nightly right on the command line and received confirmation directly on stdout that the toolchain had been switched. So now I'm even more irritated because now I don't know wtf is actually going on. Is the Rust installation broken or what? Thinking about aborting mission entirely on even installing the project, but I figured, "Nah, you came this far - stick w the course". Huge mistake.
  3. "you can add cargo-features = ["edition2021"] to enable this feature - This is where I lost it. Understand that in these three separate points I've listed here, I've identified three conflicting directives from the toolchain's output. So, I actually have no clue what's going on. This is ridiculous at this point.

I speak fluent English. I also type 180+ WPM. If you guys need someone to look over your error messages for free and convert them into coherent directives that actually provide users with useful contextual information then I'd be more than happy to contribute, because this is unacceptable on every level imaginable.

In case you guys didn't catch it, I was (a) initially told the issue was with the cargo itself not supporting the nightly features (b) despite this, I was still told that I could fix the problem by switching to the 'nightly channel' [which I already did] (c) then I was told that in order to switch to the nightly channel I'd have to add cargo-features = ["edition2021"]...which now contradicts (a)....and all of this was in ONE sentence.

Additionally, at no point in time does the error message state WHERE to put this cargo-features = ["edition2021"] line at. Its clearly not an environment variable & I'm not making it one because it would likely break any other installation process / I don't see the need for doing so. However, I did add another config flag to my install / build command that specified the toolchain. Of course...that didn't work either. Perhaps this needs to be added to the Cargo.toml file - that's fine. Except there's a syntactical ordering to that file, so it would've helped if there was some directive given about that rather than just reiterating a blanket, uninformative frankly lazy error prompt that provides no further enlightenment on how to fix the situation or what the situation even is.

This Needs to be Addressed

Its honestly unacceptable on many different levels. I get that Rust is an open source language, but I'm not judging it based on that. I'm judging it on the basis of what the project can be - and this is not sufficient. Whatever is going on here, its clear that someone got lazy on the documentation / error / writing end and that's now left us in a situation where there's a problem that's virtually unfixable because the error being spit out is unintelligible.

Again, I'd be more than happy to contribute some semantic descriptions / error messages if that'll help because I have a strong grasp of the English language or its at least strong enough to where I would be able to help this project write coherent feedback from the various toolings of Rust.

Diggsey commented 1 year ago

First, I thought I had to update my version of Rust. No problem.

Then your first thought was correct. Did you try this?

The initial error you are getting is because your rust/cargo is too old. If you updated Rust, it should have fixed the issue. The error message could be improved here, but the error is coming from cargo, not rustup, so you should probably report it against cargo.

Let me explain:

However, there is one message you shouldn't have got:

I explicitly ran rustup default nightly right on the command line and received confirmation directly on stdout that the toolchain had been switched.

The fact that it still gave the "nightly" error after running rustup default nightly implies that something is misconfigured. Are you running cargo in a folder that has a toolchain override? (either through rustup override, or via a toolchain override file?) rustup default nightly changes the default toolchain, but you may not be using the default one if you have an override set. If you are unsure, you can check the current version using rustup show. I would suggest also running cargo --version to be sure.

rbtcollins commented 1 year ago

@Librechain if you could answer @Diggsey we might be able to get an understanding of what was going on, which could lead to recommendations for what-and-where things should change. Right now I don't think we entirely understand what was happening.

If you can't, or don't want to, thats fine, we'll close this : without understanding what happened, it would be pure guesswork to make changes on the information we have, and we have enough non-guesswork bugs to be working on. And if you are busy or whatever, we'll do the same in a bit.

workingjubilee commented 1 year ago

Again, I'd be more than happy to contribute some semantic descriptions / error messages if that'll help because I have a strong grasp of the English language or its at least strong enough to where I would be able to help this project write coherent feedback from the various toolings of Rust.

Unfortunately, no matter what gets changed, that won't affect the error messages on old toolchains, as we cannot travel back in time and rewrite any new messages into your binary or anyone else's. If you have such a time machine, that would be appreciated, however!

The current error message Cargo will emit is instead

The package requires the Cargo feature called edition{next}, \ but that feature is not stabilized in this version of Cargo (1.[..]). Consider trying a newer version of Cargo (this may require the nightly release). See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} \ for more information about the status of this feature.

With {next} replaced by the relevant edition number in this case.