Rustup: cargo fmt: no such subcommand after switching to component

Created on 5 Jan 2018  路  7Comments  路  Source: rust-lang/rustup

I uninstalled rustfmt-nightly and installed the rustfmt-preview component instead. cargo fmt gives an error although cargo-fmt is installed.

 % rustup show | tail -n 6
active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.24.0-nightly (8e7a609e6 2018-01-04)

% cargo uninstall rustfmt
error: package id specification `rustfmt` matched no packages

% cargo uninstall rustfmt-nightly
error: package id specification `rustfmt-nightly` matched no packages

% rustup component add rustfmt-preview
info: downloading component 'rustfmt-preview'
info: installing component 'rustfmt-preview'

% cargo fmt
error: no such subcommand: `fmt`
[鈥

% rustup which cargo-fmt
/home/sam/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-fmt

Did I miss some step?

Edit: context is rustup 1.8.0 from ArchLinux community repository. "rustup self update" has been disabled in this build.

Most helpful comment

Do you have a shim at /home/sam/.rustup/bin/cargo-fmt? If not, does rustup self update resolve it for you?

All 7 comments

Several people in #rust-beginners with this today, but I cannot reproduce personally.

Do you have a shim at /home/sam/.rustup/bin/cargo-fmt? If not, does rustup self update resolve it for you?

I don't have a bin/ directory under /home/sam/.rustup/. Unfortunately I use rustup 1.8.0 packaged for ArchLinux so I cannot self update as this feature has been disabled. I hope somebody reading this thread will be able to.

Edit to add: of course I could reinstall rustup separately from my distro, and it would probably work, but it would not correspond to the current settings. I'll update the top-post to include this rustup version information.

Oh right sorry I mean /home/sam/.cargo/bin, although if you're using a version packaged from ArchLinux then all bets are off in that it may not be a bug here.

No cargo-fmt shim in /home/sam/.cargo/bin. Switching to a rustup version from rustup.rs solved the problem (and created the missing shims), but I don't know where it came from in the first place.

Ok thanks for the info! In that case I'll close.

I ran into this again with clippy-preview and found what I think caused it:

  • rustup component add would say that the component was added
  • ~/.cargo/bin/ did not contain a cargo-clippy binary.

I tracked this down to a non-"standard" toolchain (nightly-2018-03-01-x86_64-apple-darwin) being installed. I removed this toolchain, removed & re-added the clippy-preview component on the nightly toolchain, and that created ~/.cargo/bin/cargo-clippy

Was this page helpful?
0 / 5 - 0 ratings