Hi, I have a problem building the Rust project.
I have changed the Cargo.toml like the following:
[package]
name = "example"
version = "0.1.0"
edition = "2021"
[dependencies]
rand="0.8.5"
Only added rand to dependencies.
But, when I build the project, updating crates.io index took too long and the result was like the following.
E:\Workspace\Rust\projects\example>cargo build
Updating crates.io index
warning: spurious network error (2 tries remaining): failed to read data: The server returned an invalid or unrecognized response
; class=Os (2)
warning: spurious network error (1 tries remaining): failed to read data: The server returned an invalid or unrecognized response
; class=Os (2)
error: failed to get rand as a dependency of package game1 v0.1.0 (C:\Users\myname\Desktop\Files\game1)
Caused by:
failed to load source for dependency rand
Caused by:
Unable to update registry https://github.com/rust-lang/crates.io-index
Caused by:
failed to fetch https://github.com/rust-lang/crates.io-index
Caused by:
failed to read data: The server returned an invalid or unrecognized response
; class=Os (2)
This is the full error message. What is this? How can I fix it?
Please, help me.
According to your SO post you tried adding this to Cargo's config.toml without success:
[net]
git-fetch-with-cli = true
With that command Cargo uses your git executable to fetch the crates.io index, see here: Configuration - The Cargo Book. Maybe if you try fetching the index manually, we can get a more descriptive error message? I.e. can you create a new empty git repository somewhere and try fetching the index in there and tell us what happens: