Skip to content

Document "invalid channel name '[toolchain]'" error #2697

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

Merged
merged 3 commits into from
Mar 23, 2021

Conversation

jstasiak
Copy link
Contributor

It took me a while to figure this out. I got this error when building a
project with rust-toolchain containing TOML and I had a fresh rustup,
rust nightly etc. but still there were errors. Running

rustup default stable
rustup default nightly

made it work for me. I'm not entirely sure if the explanation is totally
accurate, of course.

It took me a while to figure this out. I got this error when building a
project with rust-toolchain containing TOML and I had a fresh rustup,
rust nightly etc. but still there were errors. Running

    rustup default stable
    rustup default nightly

made it work for me. I'm not entirely sure if the explanation is totally
accurate, of course.
@kinnison
Copy link
Contributor

That error would likely only occur if you had an outdated (1.22 or earlier) rustup. It's possible that you upgraded as a side-effect of changing the default toolchain, but setting the default toolchain without updating would not trigger the update, and updating directly (e.g. via rustup self update) would have been sufficient.

it means you're running `rustup` pre-1.23.0 (or just a default toolchain set by
`rustup` pre-1.23.0) and trying to interact with a project that uses the new TOML
encoding in the `rust-toolchain` file. You need to upgrade `rustup` to 1.23.0+
and set the default toolchain again.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to 'set the default toolchain again'. You simply need to upgrade rustup (e.g. via rustup self update or rustup update)

@jstasiak
Copy link
Contributor Author

I would totally agree with your assesment (that upgrading rustup is enough) if not for one thing: I'm pretty sure I had been running rustup 1.23.1 already when I saw that error. I'll try to reproduce this quickly and if I fail to do so I'll modify the documentation per your suggestion.

@jstasiak
Copy link
Contributor Author

I changed the doc because I thought I failed to reproduce this. I did it too hastily, it seems, as I think I was wrong (as in: the initial version had some truth to it).

Steps to reproduce (Mac OS 10.14.6 and Homebrew, but I don't think it's relevant):

  1. install rustup-init 1.22.1 and run it, accept the default settings:
~% rustup-init 

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /Users/user/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /Users/user/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /Users/user/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /Users/user/.profile
  /Users/user/.zprofile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-apple-darwin
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>

info: profile set to 'default'
info: default host triple is x86_64-apple-darwin
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2021-02-11, rust version 1.50.0 (cb75ad5db 2021-02-10)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
 61.0 MiB /  61.0 MiB (100 %)  40.8 MiB/s in  1s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-docs'
 14.7 MiB /  14.7 MiB (100 %)   6.7 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
 23.3 MiB /  23.3 MiB (100 %)  13.6 MiB/s in  3s ETA:  0s
info: installing component 'rustc'
 61.0 MiB /  61.0 MiB (100 %)  14.0 MiB/s in  4s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable'

  stable installed - rustc 1.50.0 (cb75ad5db 2021-02-10)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run source $HOME/.cargo/env

Verify the expected state:

~% rustup --version
rustup 1.22.1 (2020-07-09)

~/projects/qrates% cat rust-toolchain 
[toolchain]
channel = "nightly-2021-03-15"
components = [ "rustfmt", "rustc-dev", "llvm-tools-preview", "rust-src" ]

 ~/projects/qrates% rustc -vV
error: invalid channel name '[toolchain]' in '/Users/user/projects/qrates/rust-toolchain'
error: caused by: invalid toolchain name: '[toolchain]'

The failure above is expected.

  1. Upgrade rustup-init/rustup to 1.23.1 (through Homebrew in my case)
  2. See the error:
~% which rustup
/Users/user/.cargo/bin/rustup

% which rustc
/Users/user/.cargo/bin/rustc

~% rustup --version
rustup 1.23.1 (2020-12-03)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.50.0 (cb75ad5db 2021-02-10)`

~/projects/qrates% rustc -vV
error: invalid channel name '[toolchain]' in '/Users/user/projects/qrates/rust-toolchain'
error: caused by: invalid toolchain name: '[toolchain]'

Funnily enough this time I can't get it to work by (re)setting the default toolchain. Am I doing something wrong here?

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the slight tweak needed to remove some repeated words, this looks good.

@kinnison
Copy link
Contributor

The example you give is fascinating, I wonder if the rustc wrapper hasn't updated.

Can you please try RUSTUP_FORCE_ARG0=rustup rustc --version ?

@jstasiak
Copy link
Contributor Author

Sure, the output:

~/projects/qrates% RUSTUP_FORCE_ARG0=rustup rustc --version
rustup 1.22.1 (2020-07-09)

rustup update does nothing:

~/projects/qrates% rustup update
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-x86_64-apple-darwin'

   stable-x86_64-apple-darwin unchanged - rustc 1.50.0 (cb75ad5db 2021-02-10)
  nightly-x86_64-apple-darwin unchanged - rustc 1.52.0-nightly (61edfd591 2021-03-20)

info: cleaning up downloads & tmp directories

~/projects/qrates% RUSTUP_FORCE_ARG0=rustup rustc --version
rustup 1.22.1 (2020-07-09)

PS. The steps above start with an implicit "0. nuke ~/.cargo and ~/.rustup to get clean slate" step.

@kinnison
Copy link
Contributor

Well that's fascinating - it implies that the rustc proxy hasn't been updated despite you successfully updating rustup. That's the "bug" which we need to look into. We should move that to an issue though, not this PR.

@jstasiak
Copy link
Contributor Author

You're right, of course. Now that I know that rustup-provided rustc is just rustup-in-disguise this all makes much more sense. I amended the documentation to remove the repetition, I have no idea how did I miss that earlier.

On the

Well that's fascinating - it implies that the rustc proxy hasn't been updated despite you successfully updating rustup.

front – I'm wondering if this isn't maybe an iassue with how Homebrew installs and updates rustup. When building from source it effectively does cargo install --features no-self-update[1], I don't know how are binary Homebrew packages interacting with that but I expect the outcome is similar. So – should the wrappers be updated when a never rustup is installed through cargo install from source? If the answer is no then I should report this to Homebrew, not here. :)

[1] https://github.com/Homebrew/homebrew-core/blob/cffc813f68912c369f766c23d64fbc2d0fb684ef/Formula/rustup-init.rb#L30

@jstasiak jstasiak force-pushed the document-rust-toolchain-error branch from 2a25a74 to f58a414 Compare March 23, 2021 00:20
@kinnison
Copy link
Contributor

When rustup is provided by a package manager other than rustup itself, then it it responsible for providing all the proxies as well. take the snap as an example - it contains all the proxies for rustc, cargo etc. It sounds like you have a combination of rustup provided proxies in ~/.cargo and a homebrew provided binary which isn't properly installed with proxies of its own.

@kinnison kinnison merged commit 84974df into rust-lang:master Mar 23, 2021
@jstasiak jstasiak deleted the document-rust-toolchain-error branch March 23, 2021 21:33
@jstasiak
Copy link
Contributor Author

I understand, your description sounds exactly right. There isn't a separate rustup subcommand to (re)set the proxies, is there? Would you think creating a subcommand for that is worth it? I could take a stab at it.

@kinnison
Copy link
Contributor

Nominally rustup update would do that but it might be amusing to split that out a bit more. Of course, with self-update disabled in the build I'm not certain if it will try and manage its proxies that hard. Open an issue with the details so far and we can discuss there, rather than on this closed PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants