Can't install package due to 'unexpected end of file`

Hey everyone!

When I tried to bump my version of async-std to 0.6.2 from 0.6.1, I started encountering the following error:

>cargo run
error: failed to download `async-std v1.6.2`

Caused by:
  unable to get packages from source

Caused by:
  failed to unpack package `async-std v1.6.2`

Caused by:
  failed to unpack entry at `async-std-1.6.2/CHANGELOG.md`

Caused by:
  failed to unpack `/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.6.2/CHANGELOG.md`

Caused by:
  failed to unpack `async-std-1.6.2/CHANGELOG.md` into `/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.6.2/CHANGELOG.md`

Caused by:
  unexpected end of file

Then when I tried reverted the Cargo.toml entry to downgrade the version back to 0.6.1, the Cargo.lock still retained the 0.6.2 version, even after regenerating it.

I'm not really sure what to do now, and any help would be appreciated! Thanks in advance

You can pin the version in your Cargo.toml with:

[dependencies]
async-std = "=1.6.2"

The error is strange, it looks like you might be out of free disk space or something? I don't know what kind of validation cargo does for packages, it might also just be a corrupted archive. You can clear the cargo cache with rm -rf ~/.cargo/registry/cache/ if necessary.

Clearing the cargo cache solved the problem.

You're right in that I was encountering disk space issues earlier, but after fixing that problem, this cargo issue still persisted.

It would be nice if cargo had a built-in command to clear the cache, but you live and learn! Thanks for the help!

1 Like

There is a cargo-cache utility. But I agree it would be better if cargo had a built-in way of removing or fixing a broken cache.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.