rustup: Fresh install on macos can't install rustfmt and clippy using rustup

Following the instructions in https://beta.rust-lang.org/learn/get-started I ran the commands:

rustup add component rustfmt and rustup add component clippy and got the following errors:

error: toolchain 'stable-x86_64-apple-darwin' does not contain component 'rustfmt' for target 'x86_64-apple-darwin'

and

error: toolchain 'stable-x86_64-apple-darwin' does not contain component 'clippy' for target 'x86_64-apple-darwin'

I am new to the community, so apologies if this has an obvious explanation.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 25
  • Comments: 24 (8 by maintainers)

Commits related to this issue

Most upvoted comments

$ rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: checking for self-updates

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.31.0 (abe02cefd 2018-12-04)

$ rustup -V
rustup 1.16.0 (beab5ac2b 2018-12-06)
$ rustup self update
info: checking for self-updates
$ rustup -V
rustup 1.16.0 (beab5ac2b 2018-12-06)
$ rustup default stable
info: using existing install for 'stable-x86_64-unknown-linux-gnu'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.31.0 (abe02cefd 2018-12-04)

$ rustup component add rustfmt
error: toolchain 'stable-x86_64-unknown-linux-gnu' does not contain component 'rustfmt' for target 'x86_64-unknown-linux-gnu'

But:

$ rustup default 1.31.0
info: using existing install for '1.31.0-x86_64-unknown-linux-gnu'
info: default toolchain set to '1.31.0-x86_64-unknown-linux-gnu'

  1.31.0-x86_64-unknown-linux-gnu unchanged - rustc 1.31.0 (abe02cefd 2018-12-04)

$ rustup component add rustfmt
info: downloading component 'rustfmt'
  3.2 MiB /   3.2 MiB (100 %)   1.1 MiB/s ETA:   0 s                 
info: installing component 'rustfmt'

But still does not work with “stable”:

$ rustup default stable
info: using existing install for 'stable-x86_64-unknown-linux-gnu'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.31.0 (abe02cefd 2018-12-04)

$ rustup component add rustfmt
error: toolchain 'stable-x86_64-unknown-linux-gnu' does not contain component 'rustfmt' for target 'x86_64-unknown-linux-gnu'

EDIT:

rustup toolchain remove stable && rustup toolchain add stable

fixed the problem.

FWIW I had to run the following to get to a working state.

rustup toolchain remove stable && rustup toolchain install stable

I’m seeing the same issue on macOS 10.12.

error: toolchain 'stable-x86_64-apple-darwin' does not contain component 'rustfmt' for target 'x86_64-apple-darwin'

I did rustup self update and here is the output of -V

rustup 1.16.0 (beab5ac2b 2018-12-06)

And here is the output of rustfmt component list

cargo-x86_64-apple-darwin (default)
clippy-preview-x86_64-apple-darwin (installed)
lldb-preview-x86_64-apple-darwin
llvm-tools-preview-x86_64-apple-darwin
rls-preview-x86_64-apple-darwin
rust-analysis-x86_64-apple-darwin
rust-docs-x86_64-apple-darwin (default)
rust-src
rust-std-aarch64-apple-ios
rust-std-aarch64-fuchsia
rust-std-aarch64-linux-android
rust-std-aarch64-unknown-cloudabi
rust-std-aarch64-unknown-linux-gnu
rust-std-aarch64-unknown-linux-musl
rust-std-arm-linux-androideabi
rust-std-arm-unknown-linux-gnueabi
rust-std-arm-unknown-linux-gnueabihf
rust-std-arm-unknown-linux-musleabi
rust-std-arm-unknown-linux-musleabihf
rust-std-armebv7r-none-eabi
rust-std-armebv7r-none-eabihf
rust-std-armv5te-unknown-linux-gnueabi
rust-std-armv5te-unknown-linux-musleabi
rust-std-armv7-apple-ios
rust-std-armv7-linux-androideabi
rust-std-armv7-unknown-cloudabi-eabihf
rust-std-armv7-unknown-linux-gnueabihf
rust-std-armv7-unknown-linux-musleabihf
rust-std-armv7r-none-eabi
rust-std-armv7r-none-eabihf
rust-std-armv7s-apple-ios
rust-std-asmjs-unknown-emscripten
rust-std-i386-apple-ios
rust-std-i586-pc-windows-msvc
rust-std-i586-unknown-linux-gnu
rust-std-i586-unknown-linux-musl
rust-std-i686-apple-darwin
rust-std-i686-linux-android
rust-std-i686-pc-windows-gnu
rust-std-i686-pc-windows-msvc
rust-std-i686-unknown-cloudabi
rust-std-i686-unknown-freebsd
rust-std-i686-unknown-linux-gnu
rust-std-i686-unknown-linux-musl
rust-std-mips-unknown-linux-gnu
rust-std-mips-unknown-linux-musl
rust-std-mips64-unknown-linux-gnuabi64
rust-std-mips64el-unknown-linux-gnuabi64
rust-std-mipsel-unknown-linux-gnu
rust-std-mipsel-unknown-linux-musl
rust-std-powerpc-unknown-linux-gnu
rust-std-powerpc-unknown-linux-gnuspe
rust-std-powerpc64-unknown-linux-gnu
rust-std-powerpc64le-unknown-linux-gnu
rust-std-powerpc64le-unknown-linux-musl
rust-std-riscv32imac-unknown-none-elf
rust-std-riscv32imc-unknown-none-elf
rust-std-s390x-unknown-linux-gnu
rust-std-sparc-unknown-linux-gnu
rust-std-sparc64-unknown-linux-gnu
rust-std-sparcv9-sun-solaris
rust-std-thumbv6m-none-eabi
rust-std-thumbv7em-none-eabi
rust-std-thumbv7em-none-eabihf
rust-std-thumbv7m-none-eabi
rust-std-wasm32-unknown-emscripten
rust-std-wasm32-unknown-unknown
rust-std-x86_64-apple-darwin (default)
rust-std-x86_64-apple-ios
rust-std-x86_64-fuchsia
rust-std-x86_64-linux-android
rust-std-x86_64-pc-windows-gnu
rust-std-x86_64-pc-windows-msvc
rust-std-x86_64-rumprun-netbsd
rust-std-x86_64-sun-solaris
rust-std-x86_64-unknown-cloudabi
rust-std-x86_64-unknown-freebsd
rust-std-x86_64-unknown-hermit
rust-std-x86_64-unknown-linux-gnu
rust-std-x86_64-unknown-linux-gnux32
rust-std-x86_64-unknown-linux-musl
rust-std-x86_64-unknown-netbsd
rust-std-x86_64-unknown-redox
rustc-x86_64-apple-darwin (default)
rustfmt-preview-x86_64-apple-darwin

Went with rustup toolchain remove nightly && rustup toolchain add nightly instead - seems ok

What happens if you then rustup component add --toolchain nightly rustfmt || rustup component add --toolchain nightly clippy? On my system, I get:

> rustup component add --toolchain nightly rustfmt || rustup component add --toolchain nightly clippy
error: component 'rustfmt' for target 'x86_64-apple-darwin' is unavailable for download
info: backtrace:

stack backtrace:
…
error: component 'clippy' for target 'x86_64-apple-darwin' is unavailable for download
info: backtrace:

stack backtrace:
…

Which makes sense, given that both rustfmt and clippy are missing from today’s nightly according to https://mexus.github.io/rustup-components-history/x86_64-apple-darwin.html.

No luck with rustup self update. By the way the same problem arose on a Ubuntu 18.04.1 LTS box:

error: toolchain 'stable-x86_64-unknown-linux-gnu' does not contain component 'rustfmt' for target 'x86_64-unknown-linux-gnu'

As for the beta and nightly toolchains, is the documentation at https://beta.rust-lang.org/ supposed to work only with those? I think the website should explicitly mention it, because the wording suggests that the only beta is the website, not the tooling.

I could also fix this issue by removing and adding stable again.

@jxub I think you just need to re-install cargo-clippy via rustup component add clippy.

Had the same issue with rustc 1.33.0 on Darwin (macos Mojave) and fish shell.

Following the consensus (rustup toolchain remove nightly && rustup toolchain add nightly) from the comments above seems to fail, so I guess what does apply to nightly applies to 1.33 as well.

$ cargo clippy
error: toolchain 'stable-x86_64-apple-darwin' does not have the binary `cargo-clippy`
$ rustup toolchain remove stable; and rustup toolchain add stable
info: uninstalling toolchain 'stable-x86_64-apple-darwin'
info: toolchain 'stable-x86_64-apple-darwin' uninstalled
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2019-02-28, rust version 1.33.0 (2aa4c46cf 2019-02-28)
info: downloading component 'rustc'
 78.7 MiB /  78.7 MiB (100 %)   7.9 MiB/s ETA:   0 s
info: downloading component 'rust-std'
 51.5 MiB /  51.5 MiB (100 %)  12.4 MiB/s ETA:   0 s
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'

  stable-x86_64-apple-darwin installed - rustc 1.33.0 (2aa4c46cf 2019-02-28)

$ cargo clippy
error: toolchain 'stable-x86_64-apple-darwin' does not have the binary `cargo-clippy`

Regardless, it isn’t unclear that it’s the same issue, since this issue was originally that the stable toolchain “does not contain component”, whereas this error message says it’s “unavailable for download.”

Indeed, it’s unrelated. My issue is that clippy is actually unavailable for today’s nightly, per https://mexus.github.io/rustup-components-history/x86_64-apple-darwin.html.

Could you try running rustup self update and then try again please? You’ll also need to try on eitherr beta or nightly toolchains, not stable.