Open1

error: the 'cargo' binary, normally provided by the 'cargo' component が出力された際の対応

com4dccom4dc

前提

  • rust-toolchain にバージョンが指定されてる

手順

rustup update を実行

$ rustup update
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2021-09-09, rust version 1.55.0 (c8dfcfe04 2021-09-06)
info: downloading component 'rls'
  7.2 MiB /   7.2 MiB (100 %)   5.2 MiB/s in  1s ETA:  0s
info: downloading component 'rust-src'
info: downloading component 'rust-analysis'
...

cargo --version

$ cargo --version
error: the 'cargo' binary, normally provided by the 'cargo' component, is not applicable to the '1.55.0-x86_64-apple-darwin' toolchain

一度 cargo を削除して再度追加する

$ rustup component remove cargo
info: removing component 'cargo'
warning: during uninstall component cargo was not found
$ rustup component add cargo
info: downloading component 'cargo'
info: installing component 'cargo'

参照 URL

https://github.com/rust-lang/rustup/issues/2704#issuecomment-815062952