102
votes

I followed the readme instructions for building Parity from source and then I execute this command:

cargo build --release

and then:

~/.cargo/bin/cargo build --release

.. as instructed; both of which cause me to receive the following message while the prompt hangs:

 Blocking waiting for file lock on the registry index

I'm on a Mac.

16

16 Answers

84
votes

I had the same issue and got around it with rm -rf ~/.cargo/registry/index/*.

Edit: I suggest looking at this answer first.

103
votes

Running cargo clean seems to fix the problem.

77
votes

This happens when you run 2 compilations of the same project at the same time. The compiler uses a lock file to avoid having data race issues. There are some possibilities:

  • If you ran the 2 compilations yourself, the solution is obvious: you need to cancel one of them.

  • If you use an IDE that automatically compiles your project: you can wait for the job to be finished or close the IDE. If it does not work, this is probably because of RLS hanging out. You can just pkill rls to solve the issue.

  • As a last resort, you can remove the lock forcefully: rm -rf ~/.cargo/registry/index/* as said in another answer.

28
votes

It is important to ensure you have no other rls or cargo running. sudo pkill rls cargo is a good way to ensure they are not.

18
votes

Removing rm $CARGO_HOME/.package-cache worked for me.

I accidentally hit ctrl+z instead of ctrl+c while executing cargo run and the next execution of cargo run showed me Blocking waiting for file lock on the registry index. I removed the said file and then it worked again.

10
votes

You usually get this error when you run cargo build command twice at the same time. If you are using an IDE check if a plugin is running a cargo command in the background, this was the case for me with VS Code.

9
votes

My issue was the IDE was running cargo and had locked the directory. Try closing your IDE

6
votes

My VSCode intellisense was working on a build. Make sure your intellisense is not builing. It displays a little gear icon spinning on bottom. Happens mostly when you update Cargo.toml

4
votes

Before removing the Cargo registry index as suggested in the accepted answer, make sure no other process is currently compiling Parity or any other Rust package.

3
votes

I tried to create a Polkadot Node by following the Readme instructions.

I was able to build it by running the following commands (copy/paste into Bash Terminal):

git clone https://github.com/paritytech/polkadot;
cd polkadot; git checkout master;
rustup update nightly;
rustup target add wasm32-unknown-unknown --toolchain nightly;
rustup update stable;
rustup default stable;
cargo install --git https://github.com/alexcrichton/wasm-gc --force;
cargo install --git https://github.com/pepyakin/wasm-export-table.git --force;
brew install openssl; brew upgrade openssl;
rustc --version; cargo --version;
./build.sh;
cargo build;
cargo run -- --help;
./target/debug/polkadot --help;

I then tried to run a Polkadot Node with the following commands (which are equivalent):

./target/debug/polkadot -- --chain=dev --validator --key Alice -d /tmp/alice;
cargo run -- --chain=dev --validator --key Alice -d /tmp/alice;

But instead it showed the following:

Blocking waiting for file lock on the git checkouts
Blocking waiting for file lock on build directory

I found it was caused by CLion (Jetbrains IDE).

I solved the problem by closing CLion. I used Visual Studio Code editor instead, which also allows for debugging Rust code with breakpoints

3
votes

Same issue in VScode : if you've installed RLS

  1. File | Preferences | Settings
  2. Search for "rls"
  3. In "rust" extension, uncheck "Start RLS automatically when opening a file or project"

Re-open your project, and it should be solved.

1
votes

if you ever hit "Blocking waiting for file lock on package cache",

Run the command below and run cargo again. rm $CARGO_HOME/.package-cache

0
votes

You Should Temporarily Stop the rls Process.

0
votes

On the risk of coming late to the party, while cargo, rls or rust-analyzer are responsible for the lock to avoid data races. An underlying issue maybe the number of inotify filewatchers.

Usually they work fine by spawning a new watcher and wait their turn but if they run out of watchers space this can be a problem. Agreeing to all the above solutions but suggesting to check the number of max_user_watches

# view current settings
cat /proc/sys/fs/inotify/max_user_watches

# increasing it, /etc/sysctl.conf
fs.inotify.max_user_watches=524288

# The new value can then be loaded in by running s
$sudo sysctl -p.
0
votes

I fixed this issue by running the following commands:

  1. Search for all rust related processes by $ ps aux | grep rls
  2. Stop all of them one by one with $ sudo kill -9 <PID>
-1
votes

If you are sure that there is no other cargo process executing, but this problem still occur frequently, it might be your network problem.