rustup: Components occasionally become corrupted after rustup upgrade

Problem

At Embark we usually upgrade to using the latest stable rust compiler soon after its release. We’ve noticed a consistent spurious issue where your components become corrupted after being upgraded. This happens across different platforms, with different components, and it does not happen to the same install consistently, but we do usually have it happen to at least one or two people on the team every upgrade cycle.

This bug is usually fixed by just re-installing the component or toolchain altogether, so it’s not the worst bug, but it is pretty annoying.

Steps

  1. rustup upgrade
  2. Run a command with the new toolchain.

Errors

the 'cargo.exe' binary, normally provided by the 'cargo' component, is not applicable to the '1.50.0-x86_64-pc-windows-msvc' toolchain
error: the 'cargo-clippy' binary, normally provided by the 'clippy' component, is not applicable to the '1.51.0-aarch64-apple-darwin' toolchain

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 22 (15 by maintainers)

Most upvoted comments

cargo is not directly executed: you run cargo, but cargo is rustup, rustup the runs the real cargo which is located in the path in the toolchain dir that I gave. If its not there, (and you say it isn’t), then the component is either incorrectly unpacked, unpacked but has had elements deleted (e.g. by a virus scanner), or isn’t unpacked at all, irrespective of the toolchain config.

See if the following repairs it: rustup component remove cargo rustup component add cargo

If so thats pretty strong evidence for the bug with concurrency. How are you normally running rustup? Are you using an editor with rust integration of some sort?

@rbtcollins not sure if this is useful, but I came across this when I opened a folder with a rust-toolchain file inside in vs code with rust-analyzer and rust-analyzer downloaded the toolchain. Fixed it with: rustup component remove cargo rustup component add cargo

Also tried to reproduce by removing the toolchain, and letting rust-analyzer fetch it again, but it doesn’t seem to happen every time

Please perform the debugging steps I requested.

I got the same bug in macOS and it is only happening in one particular codebase terminal.

The error:

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

I tried updating using rustup update, I get this:

info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: checking for self-updates

  stable-x86_64-apple-darwin unchanged - rustc 1.51.0 (2fd73fabe 2021-03-23)

info: cleaning up downloads & tmp directories