Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the generated Cargo.lock after build #184

Closed
tisonkun opened this issue Oct 7, 2024 · 8 comments · Fixed by #185
Closed

Remove the generated Cargo.lock after build #184

tisonkun opened this issue Oct 7, 2024 · 8 comments · Fixed by #185

Comments

@tisonkun
Copy link

tisonkun commented Oct 7, 2024

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

shadow-rs/src/env.rs

Lines 122 to 130 in 4358b4a

if let Ok(out) = Command::new("cargo")
.args(["metadata", "--format-version", "1"])
.output()
{
update_val(
CARGO_METADATA,
String::from_utf8(out.stdout)?.trim().to_string(),
);
}

@weihanglo suggested in rust-lang/cargo#12195 that we may delete the Cargo.lock after build.

@tisonkun
Copy link
Author

tisonkun commented Oct 7, 2024

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 - tisonkun/morax#4

@weihanglo
Copy link

BTW --locfile-path has been implemented: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lockfile-path
While it is still an unstable feature, it would be appreciated if you could give feedback :)

@baoyachi
Copy link
Owner

baoyachi commented Oct 8, 2024

@tisonkun The next version will fix it.

@tisonkun
Copy link
Author

tisonkun commented Oct 8, 2024

@baoyachi Cool! Would you please link the related changes to this issue so that we can cross ref each other?

@baoyachi
Copy link
Owner

baoyachi commented Oct 8, 2024

@baoyachi Cool! Would you please link the related changes to this issue so that we can cross ref each other?

No problem.

@baoyachi
Copy link
Owner

baoyachi commented Oct 8, 2024

@tisonkun New version publised,please use:

shadow-rs = "0.35.1"

By the way, the code with let _ = std::fs::remove_file(Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.lock")); can be remove in morax .

@tisonkun
Copy link
Author

tisonkun commented Oct 8, 2024

Cheers! Thank you!

@tisonkun
Copy link
Author

tisonkun commented Oct 8, 2024

Update it. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants