# Cargo: Blocking waiting for file lock on package cache / on build directory

**Code:** `Blocking waiting for file lock on package cache / build directory` · **Category:** Rust · **Seen on:** Rust, Linux

Another cargo process (or rust-analyzer/IDE) holds the lock, so this command waits.

## 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

1. Wait or `pkill -f cargo` if stuck
2. Separate target dir for rust-analyzer (`rust-analyzer.cargo.targetDir: true`)
3. Avoid sharing `~/.cargo` across concurrent jobs without care

## Detailed fix by platform

### Linux

1. `ps aux | grep -E "cargo|rustc|rust-analyzer" | head`

## How to diagnose

1. **Process** — Who holds it?
2. **IDE** — rust-analyzer?
3. **FS** — Network?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/rust/cargo-blocking-waiting-for-file-lock)
