baoyachi / shadow-rs

A build-time information stored in your rust project.(binary,lib,cdylib,dylib)
https://docs.rs/shadow-rs
MIT License
455 stars 41 forks source link

Remove the generated Cargo.lock after build #184

Open tisonkun opened 2 hours ago

tisonkun commented 2 hours ago

It seems this code snippet will generate a Cargo.lock file that fails cargo publish as described in #135.

https://github.com/baoyachi/shadow-rs/blob/4358b4a0949fc50e50860ee625bc4dbfdc79166a/src/env.rs#L122-L130

@weihanglo suggested in https://github.com/rust-lang/cargo/issues/12195 that we may delete the Cargo.lock after build.

tisonkun commented 2 hours ago

Currently work it around by add this line to the build.rs file:

let _ = std::fs::remove_file(Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.lock"));

Ref - https://github.com/tisonkun/morax/pull/4