-
Notifications
You must be signed in to change notification settings - Fork 985
Labels
Description
Verification
- I searched for recent similar issues at https://github.com/rust-lang/rustup/issues?q=is%3Aissue and found no duplicates.
- I am on the latest version of Rustup according to https://github.com/rust-lang/rustup/tags and am still able to reproduce my issue.
Problem
When rustup-init -y runs in parallel, multiple processes write the same partial file, and then try to move it to the same target location. One of those process succeeds and renames the file, the other processes error due to the missing file:
error: component download failed for cargo-x86_64-unknown-linux-gnu: could not rename 'downloaded' file from '/home/konsti/projects/rustup/rustup/downloads/8d17d5a4734e684228adee4ea4a75da94eb7f71993804adf29f344709e65fe09.partial' to '/home/konsti/projects/rustup/rustup/downloads/8d17d5a4734e684228adee4ea4a75da94eb7f71993804adf29f344709e65fe09': No such file or directory (os e
After locking those files, the transaction step fails when running in parallel:
error: failed to install component: 'cargo-x86_64-unknown-linux-gnu', detected conflict: 'bin/cargo'
Steps
MRE:
rm -rf $PWD/cargo $PWD/rustup
CARGO_HOME=$PWD/cargo/ RUSTUP_HOME=$PWD/rustup target/debug/rustup-init -y --no-modify-path --profile minimal & \
CARGO_HOME=$PWD/cargo/ RUSTUP_HOME=$PWD/rustup target/debug/rustup-init -y --no-modify-path --profile minimal & \
CARGO_HOME=$PWD/cargo/ RUSTUP_HOME=$PWD/rustup target/debug/rustup-init -y --no-modify-path --profile minimal
wait -n
Possible Solution(s)
There's two popular options:
- Use a unique (temporary) file or directory instead of just
.partial - Use file locks
Prototype: #4606
A temp file has wider support (no requirement on OS level locking), file locks actually prevent multiple processes downloading the same, and may be required for fixing parallel transactions. For the unique file name solution, I wouldn't know how to implement cleaning up previous failures, while there's an existing implementation when using locking.
Notes
No response
Rustup version
rustup-init 1.28.2+424 (4ae201236 2025-11-19)Installed toolchains
n/aOS version
Ubuntu 24.04