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

cargo add and ctrl + c #11386

Closed
cavemanloverboy opened this issue Nov 17, 2022 · 3 comments · Fixed by #12744
Closed

cargo add and ctrl + c #11386

cavemanloverboy opened this issue Nov 17, 2022 · 3 comments · Fixed by #12744
Labels

Comments

@cavemanloverboy
Copy link

Problem

I hit ctrl+c when cancelling a redundant cargo add command, and discovered that my Cargo.toml had been entirely deleted.

Steps

  1. cargo add a crate
  2. ctrl+c before it finishes successfully

Possible Solution(s)

No response

Notes

No response

Version

cargo version --verbose
cargo 1.65.0 (4bc8f24d3 2022-10-20)
release: 1.65.0
commit-hash: 4bc8f24d3e899462e43621aab981f6383a370365
commit-date: 2022-10-20
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1q)
os: CentOS 7.9.2009 (Core) [64-bit]
@cavemanloverboy cavemanloverboy added the C-bug Category: bug label Nov 17, 2022
@epage
Copy link
Contributor

epage commented Nov 17, 2022

We are using std::fs::write, so the scope of this race condition is very small. Resolving this completely would require an atomic write.

@ChrisDenton
Copy link
Member

Could it not write to a temporary file and then atomically replace the original?

@epage
Copy link
Contributor

epage commented Nov 17, 2022

Yes, that was what I was referring to at the end.

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