Cargo build: warning: failed to save last-use data

When I use cargo build, cargo will first lag for a while and then give this prompt:

warning: failed to save last-use data
This may prevent cargo from accurately tracking what is being used in its global cache. This information is used for automatically removing unused data in the cache.

database is locked

Caused by:
Error code 5: The database file is locked

Although cargo can still continue to compile afterwards, this has resulted in an extension of cargo build time. How did this problem arise and how should I handle it?
I didn't find a similar issue on google

strace -rttT cargo build can be used to find that the operations related to ~/.cargo/.global-cache are very time-consuming, and deleting this file will remove this warning.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.