`rustup update` failing with could not rename component file
[santiago@galago ~]$ rustup --version
rustup 1.23.1 (2020-12-18)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.53.0-nightly (b84932674 2021-04-21)`
[santiago@galago ~]$ rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'beta-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2021-04-23, rust version 1.53.0-nightly (7f4afdf02 2021-04-22)
info: downloading component 'rust-std' for 'i686-unknown-linux-gnu'
info: downloading component 'rustc-dev'
95.0 MiB / 95.0 MiB (100 %) 36.6 MiB/s in 2s ETA: 0s
info: downloading component 'rust-src'
info: downloading component 'rust-analyzer-preview'
info: downloading component 'rust-analysis'
info: downloading component 'rls'
info: downloading component 'miri'
info: downloading component 'llvm-tools-preview'
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
48.8 MiB / 48.8 MiB (100 %) 36.8 MiB/s in 1s ETA: 0s
info: downloading component 'rustfmt'
info: removing previous version of component 'rust-std' for 'i686-unknown-linux-gnu'
info: removing previous version of component 'rustc-dev'
info: removing previous version of component 'rust-src'
info: removing previous version of component 'rust-analyzer-preview'
info: removing previous version of component 'rust-analysis'
info: removing previous version of component 'rls'
info: removing previous version of component 'miri'
info: removing previous version of component 'llvm-tools-preview'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'rust-std' for 'i686-unknown-linux-gnu'
info: using up to 500.0 MiB of RAM to unpack components
24.3 MiB / 24.3 MiB (100 %) 13.0 MiB/s in 2s ETA: 0s
info: installing component 'rustc-dev'
95.0 MiB / 95.0 MiB (100 %) 13.1 MiB/s in 7s ETA: 0s
info: installing component 'rust-src'
info: installing component 'rust-analyzer-preview'
info: installing component 'rust-analysis'
info: installing component 'rls'
info: installing component 'miri'
info: installing component 'llvm-tools-preview'
21.4 MiB / 21.4 MiB (100 %) 13.9 MiB/s in 1s ETA: 0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
16.0 MiB / 16.0 MiB (100 %) 9.6 MiB/s in 1s ETA: 0s
info: rolling back changes
error: could not rename component file from '/home/santiago/.rustup/tmp/zf6jna9jd15jb4u__dir/bk' to '/home/santiago/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/man'
error: could not rename component file from '/home/santiago/.rustup/tmp/cduhrqr9cfacgp11_dir/bk' to '/home/santiago/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu'
error: could not rename component file from '/home/santiago/.rustup/tmp/df3zlcanlr6x35r5_dir/bk' to '/home/santiago/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/zsh'
error: could not rename component file from '/home/santiago/.rustup/tmp/ix1dug784t7aeozn_dir/bk' to '/home/santiago/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/etc'
error: could not rename component file from '/home/santiago/.rustup/tmp/l9rfug8ahze2fpjn_dir/bk' to '/home/santiago/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src'
...
@spastorino Kinnison said on discord:
This happens if the component file gets corrupted. The easiest fix is to uninstall and reinstall the toolchain.
wheres the actual end of the output? I see the rollback start, but not the actual original error that triggered the rollback.
The could-not-renames are just symptoms of whatever the problem was I think
ohh yeah I see the problem
error: failed to install component: 'rust-docs-x86_64-unknown-linux-gnu', detected conflict: '"share/doc/rust/html"'
Uninstalled and installed again and it's now working. Anyway, unsure what happened or how the component file got corrupted.
dup of #2417
Newbie to rust here. Exactly how to "uninstall and reinstall the toolchain", please? This is my year to grok rust and this is my first issue.
rustup toolchain uninstall stable && rustup toolchain install stable, replacing stable with the toolchain name that errored for you.
Thanks! I'm a pretty goof guesser, but I could've gone a long time before coming up wit that on my own!
what lol ! FR just trying the install again worked smh ugghhhh thanks all lol
Had the exact same problem, fixed by closing the IDE (vscode in my case) hehe
I think rust-analyzer plugin was blocking the folder.
Had the exact same problem, fixed by closing the IDE (vscode in my case) hehe
I think rust-analyzer plugin was blocking the folder.
@not4rt Thanks for the heads up. Given that, I think it'd be better to close this in favor of https://github.com/rust-lang/rustup/issues/2441.
Rustup will sometimes successfully remove the old toolchain and then repeatedly fail to install it fresh - even when the problem isn't file conflicts. I've had it before and didn't think too much of rustup toolchain uninstall $FAILING_TOOLCHAIN && rustup toolchain install $FAILING_TOOLCHAIN until today. Where I spent about 20 minutes updating just the stable toolchain (nightlies rarely error for me, luckily).
Not sure if it's better to reopen the existing issue, or to open a new one. After all, the issue title perfectly reflects the actual problem
Failing output, $RUSTUP_HOME to substitute the full path
❯ rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
info: latest update on 2025-04-03, rust version 1.86.0 (05f9846f8 2025-03-31)
info: downloading components # snip, this just works
info: removing previous version of components # snip, this just works
# snipping progress reports for brevity
info: installing component 'rust-std' for 'i686-pc-windows-gnu'
info: installing component 'rust-analyzer'
info: installing component 'rust-src'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-mingw'
info: installing component 'rust-std'
info: installing component 'rustc'
9 IO-ops / 9 IO-ops (100 %) 2 IOPS in 4s
info: rolling back changes
error: could not rename component file from # snip!
# This repeats for literally every file in $RUSTUP_HOME/tmp downloaded for the current toolchain
# The final bit is interesting, note the ordering:
warn: could not delete temp directory: $RUSTUP_HOME\tmp\gkcvss83zmmb8r11_dir
error: could not rename component file
from '$RUSTUP_HOME\tmp\gkcvss83zmmb8r11_dir\rustc\lib\rustlib\x86_64-pc-windows-gnu\bin\rust-lld.exe'
to '$RUSTUP_HOME\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\bin\rust-lld.exe'
Subsequent failures happened in the form of a single rename failing instead, or the spurious:
error: failure removing component 'rustc-x86_64-pc-windows-gnu', directory does not exist: 'bin\rustc_driver-42db67a2a6008d5f.dll'
There was no IDE running, nothing else touching my Rust install, and just retrying it a couple times eventually leads to success, sort of:
stable-x86_64-pc-windows-gnu installed - (timeout reading rustc version)
edit: formatting fix to prevent sidescrolling
rustup toolchain uninstall stable && rustup toolchain install stable
this sh cmd work for me
The downside to that is that you then also need to reinstall any extra components on those toolchains, e.g. rust-analyzer and miri
Also ran into this issue on Ubuntu 24.04 when running rustup update. Have rebuilt my Docker image, and it's working again.
We observe this occasionally happening in CI as well, so it definitely is not rust-analyzer locking the file system. Nor is it a Windows issue. So certainly not a duplicate of #2441.
We observe this occasionally happening in CI as well, so it definitely is not rust-analyzer locking the file system. Nor is it a Windows issue. So certainly not a duplicate of #2441.
I tracked down our specific issue, I think. The error message looked very similar to the OP, but it may have been unrelated.
Our message:
info: syncing channel updates for '1.91.0-x86_64-unknown-linux-gnu'
info: latest update on 2025-10-30, rust version 1.91.0 (f8297e351
2025-10-28)
info: downloading component 'cargo'
error: component download failed for cargo-x86_64-unknown-linux-gnu:
could not rename downloaded file from
'/root/.rustup/downloads/7103c03fb8abe85b23307005a9dfe4f01c826a89945d84b96fa2d03fd4d2d138.partial'
to
'/root/.rustup/downloads/7103c03fb8abe85b23307005a9dfe4f01c826a89945d84b96fa2d03fd4d2d138':
No such file or directory (os error 2)
The problem was that our CI script could trigger multiple rustup installs concurrently. I understand this is a well known issue. In a way, the problem was that the download of the toolchain could happen in unexpected places...
Fixing my script seems to have resolved the spurious errors.
Toolchain auto install can be disabled, e.g.:
rustup set auto-install disable
Or by setting RUSTUP_AUTO_INSTALL environment variable to 0.
Then installs will only happen with an explicit install step (rustup install ...).