Open zoumi opened 7 years ago
The file /syntex_errors-0.42.0/Cargo.toml is empty.
If I delete the file, another error occur: error: unable to get packages from source
Caused by:
failed to download replaced source registry https://github.com/rust-lang/crates.io-index
Caused by:
failed to read /home/zoumi/.cargo/registry/src/mirrors.xxxx.com-07d6cef1b9e54f94/syntex_errors-0.42.0/Cargo.toml
Caused by: No such file or directory (os error 2)
How can I repaire my crate src? Delete /home/zoumi/.cargo/registry/src
?
If it is not too bad for you (if you have a good internet connection and are OK with downloading all the crates again), you can just remove the $HOME/.cargo/registry/
and $HOME/.cargo/git/
directories.
Curious!
As @Luthaf mentioned you can delete the whole registry
folder and Cargo will recreate it. In theory this shouldn't happen as Cargo's hardened against failures like this, but there's perhaps a bug in those mitigations!
It looks like I just experienced the same issue on Windows 10, with:
cargo 1.72.0 (103a7ff2e 2023-08-15)
rust-analyzer version: 0.3.1649-standalone (2df30e1e0 2023-09-03)
(VS Code extension)For me the PC crashed while rust-analyzer was building the project. After the PC restarted rust-analyzer failed to build the project.
For example:
Caused by:
unable to get packages from source
Caused by:
failed to download replaced source registry `crates-io`
Caused by:
failed to parse manifest at `<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\serde_json-1.0.106\Cargo.toml`
Caused by:
could not parse input as TOML
Caused by:
TOML parse error at line 1, column 1
That Cargo.toml
file indeed seems to be corrupted and contains ~2KB of NUL bytes (and nothing else). There was also a Cargo.toml.orig
file whose content seems to be correct wellformed TOML. And also a .cargo-ok
and a .cargo_vcs_info.json
file.
Running cargo clean
followed by cargo test
(which uses serde_json as dev-dependency) from the command line also causes this error.
Deleting those broken dependencies under <user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f
solved the issue.
The title of this issue is about interrupted downloads but the examples are for interrupted extractions which needs a separate solution.
Renaming accordingly.
This was opened in 2017 and our solution to this has changed a lot since then, for a history of it see
https://github.com/rust-lang/cargo/blob/c956e9f41c8a483385492b5b6c76cada8dd781cc/src/cargo/sources/registry/mod.rs#L551-L599
while we don't write the .cargo-ok
file atomically, if its not a valid json file, we clear the cache and re- extract it.
What would be useful to know for anyone having problems with interruption recovery when extracting the files
.cargo-ok
When I was running
cargo build --release
, my computer suddenly poweroff(cargo was downloading crate then). So,I restart my computer, runcargo build --release
again. The error occur:It seem the file is broken, and cargo isn't able to recover. (Sorry for my poor english.)