rustyhorde / vergen

Generate cargo instructions at compile time in build scripts for use with the env! or option_env! macros
Apache License 2.0
384 stars 57 forks source link

cargo file-lock dead-lock in build.rs to get metadata: #323

Closed delta4chat closed 7 months ago

delta4chat commented 7 months ago

~~1. when you try compile your project with cargo build,

  1. then your build.rs generates a binary by rust compiler, and that is called by cargo package manager,
  2. but cargo itself already has a lock on some files located at ~/.cargo/registry/ (may),
  3. so vergen calls cargo metadata --format-version 1 to get the metadata for the crate.
  4. This is never done. This process can never end, because at the moment the down-stream project's compile command (such ascargo build) is waiting for the build script to finish, and vergen is waiting for the cargo build to release the file lock.~~

~~# what happen? see following screenshots:~~

waiting htop

delta4chat commented 7 months ago

It's probably very rare, and now it's suddenly works again, so leave it as an FYI, vergen calls the cargo command internally anyway... I personally don't think this is a good design