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 on a full disk results in Cargo.toml becoming empty #12704

Closed
rustrust opened this issue Sep 19, 2023 · 3 comments
Closed

cargo add on a full disk results in Cargo.toml becoming empty #12704

rustrust opened this issue Sep 19, 2023 · 3 comments
Labels
Command-add S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Comments

@rustrust
Copy link

I ran cargo add on a disk which was already full and this resulted in my Cargo.toml becoming an empty file.

$ rustc --version
rustc 1.72.0 (5680fa18f 2023-08-23)
$ cargo --version
cargo 1.72.0 (103a7ff2e 2023-08-15)
$ cargo add clap --features derive
    Updating crates.io index
      Adding clap v4.4.4 to dependencies.
             Features:
             + color
             + derive
             + error-context
             + help
             + std
             + suggestions
             + usage
             - cargo
             - debug
             - deprecated
             - env
             - string
             - unicode
             - unstable-doc
             - unstable-styles
             - unstable-v5
             - wrap_help
error: failed to write `/myproject/Cargo.toml`

Caused by:
  No space left on device (os error 28)

After this Cargo.toml is a blank file!

@saethlin saethlin added the T-cargo Team: Cargo label Sep 19, 2023
@ehuss ehuss transferred this issue from rust-lang/rust Sep 19, 2023
@ehuss ehuss added Command-add S-triage Status: This issue is waiting on initial triage. and removed T-cargo Team: Cargo labels Sep 19, 2023
@epage
Copy link
Contributor

epage commented Sep 19, 2023

The fix for this would have overlap with the fix for #11386 (atomic writes)

@ehuss ehuss added S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. and removed S-triage Status: This issue is waiting on initial triage. labels Sep 25, 2023
@calavera
Copy link
Contributor

I believe #12744 fixed this problem. The new write_atomic operation will fail to create the temp file without deleting the content of the Cargo.toml file.

@weihanglo
Copy link
Member

Nice catch. I believe so. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-add S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.
Projects
None yet
Development

No branches or pull requests

6 participants