Cargo: Blocking waiting for file lock on package cache / on build directory
Another cargo process (or rust-analyzer/IDE) holds the lock, so this command waits.
Blocking waiting for file lock on package cacheBlocking waiting for file lock on build directoryBlocking waiting for file lock on artifact directoryBlocking waiting for file lock on shared package cachecargo blocking waiting for file lock Meaning
Wait for the other process, or stop it (pkill cargo). Common with rust-analyzer running cargo check in the same target dir — set a separate rust-analyzer.cargo.targetDir or CARGO_TARGET_DIR. A stale lock on network filesystems can also hang. It's not an error unless it never finishes.
Common causes
- IDE/rust-analyzer running checks
- Parallel terminals running cargo
- Hung cargo process
- Shared network filesystem for CARGO_HOME or target
- CI jobs sharing a cache dir
⚡ Quick fix
- Wait or
pkill -f cargoif stuck - Separate target dir for rust-analyzer (
rust-analyzer.cargo.targetDir: true) - Avoid sharing
~/.cargoacross concurrent jobs without care
Detailed fix by platform
Linux
ps aux | grep -E "cargo|rustc|rust-analyzer" | head
How to diagnose
- Process — Who holds it?
- IDE — rust-analyzer?
- FS — Network?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Cannot start a runtime from within a runtime (Tokio) Rust: thread 'main' panicked: Cannot start a runtime from within a runtime — a function like `block_on` tried to block a thread that drives async tasks
- cargo: failed to get from registry (spurious network error) Cargo: warning: spurious network error (2 tries remaining): [35] SSL connect error / error: failed to download from `https://index.crates.io/...`
- cargo: failed to select a version for the requirement Cargo: error: failed to select a version for the requirement `serde = "^2.0"` — candidate versions found which didn't match: 1.0.197
Most viewed in Rust
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026