#Rustup/Cargo fmt issue

15 messages · Page 1 of 1 (latest)

thick grove
#

After installing a new toolchain, and getting an error during install, I reinstalled the toolchain successfully
But now, I cannot run cargo fmt anymore
All I get is :
error: no such command: `fmt`

I tried uninstall/installing all my toolchains again, and it does not fix the issue. Any idea ?

primal fossil
#

In a normal Rustup installation, there should be an ~/.cargo/bin/cargo-fmt, which is a hardlink to rustup itself (this is how rustup handles toolchain selection for all commands that come from a toolchain). It sounds like you're missing that.

#

So,

  • check what files you have in ~/.cargo/bin to see what the situation is
  • try reinstalling rustup, not toolchains
thick grove
#

I don't have it, and uninstall/reinstalling rustup does not bring it (fedora)

primal fossil
#

oh, this is a distro-installed rustup?

#

run which rustup and which cargo to find out what you have via your PATH, and please show the list of files that are in ~/.cargo/bin (if anything)

thick grove
#

$ which rustup
~/.cargo/bin/rustup

$ which cargo
~/.cargo/bin/cargo

ls ~/.cargo/bin
anchor cargo cargo-fuzz clippy-driver rls rustc rustfilt rust-gdbgui rustup spl-token
avm cargo-clippy cargo-miri ore rust-analyzer rustdoc rust-gdb rust-lldb sbjc

primal fossil
#

okay, so you have a non-distro, self-contained, rustup installed

#

if you had a distro rustup it would usually be in /usr/bin/rustup and not ~/.cargo/bin

#

try rustup self update, and if that doesn't help then rustup self uninstall and reinstall it from rust-lang.org

upper nebula
#

Try running rustup component add --toolchain <toolchain> rustfmt, with the toolchain that you're targeting.

thick grove
#

Idk what is wrong with my setup, but

rustup self update
error: self-update is disabled for this build of rustup
error: you should probably use your system package manager to update rustup

also tried the component add, does not do anything

info: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is up to date

upper nebula
thick grove
#

Really weird, I uninstalled fedora version, but still get same error when trying rustup self uninstall

thick grove
#

I removed the ~/.cargo folder to start fresh, seems OK now
Thanks