Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cargo build hangs with " Blocking waiting for file lock on the registry index" after building parity from source

I followed the readme instructions for building Parity from source and then executed:

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

as instructed, both of which returned the following message while the prompt hung:

 Blocking waiting for file lock on the registry index

I'm on a Mac.

like image 506
Naruto Sempai Avatar asked Nov 30 '17 02:11

Naruto Sempai


5 Answers

Running cargo clean seems to fix the problem.

like image 147
Russel Winder Avatar answered Nov 11 '22 15:11

Russel Winder


I had the same issue and got around it by using

rm -rf ~/.cargo/registry/index/*

I suggest looking at 'Cargo build hangs with " Blocking waiting for file lock on the registry index" after building parity from source' first.

like image 140
jvatic Avatar answered Nov 11 '22 16:11

jvatic


This happens when you run two 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 two 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 run pkill rls to solve the issue.

  • As a last resort, you can force the removal of the lock using rm -rf ~/.cargo/registry/index/* as said in jvatic's answer.

like image 133
Boiethios Avatar answered Nov 11 '22 15:11

Boiethios


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.

like image 56
Wilfried Kopp Avatar answered Nov 11 '22 17:11

Wilfried Kopp


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.

Edit:
If you accidentally hit ctrl+z like me, you can unsuspend the cargo run process by running fg instead of deleting the package cache file. ctrl+z actually sends a SIGTSTP signal to the process and that process will be suspended until you tell it to continue. See this answer for more info.

like image 30
bmdelacruz Avatar answered Nov 11 '22 16:11

bmdelacruz