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/`

Caused by:
  failed to unpack `/home/user/.cargo/registry/src/`

Caused by:
  failed to unpack `async-std-1.6.2/` into `/home/user/.cargo/registry/src/`

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:

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.


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.