[SHUTDOWN]How to configure the `[dependencies]` in Cargo.toml


#1

I wrote this:

[dependencies]
rand = "0.3.0"

this didn’t work.

 Downloading winapi v0.2.5
Unable to get packages from source

Caused by:
  Failed to download package `winapi v0.2.5` from https://crates.io/api/v1/crates/winapi/0.2.5/download

Caused by:
  Timeout was reached

##Questions:

  1. Is the crates.io/…/download unaccessible? If so , what are the right URLs? How to configure it.
  2. Can I install those crates to local. And how to configure it in Cargo.toml.

#2

Maybe it’s because of network.


#3

@wxwhaha this should work fine. This is just a shot in the dark, but are you behind the great china firewall? I’ve heard people reporting similar issue with go packages for example - in any case, this looks like a networking issue :slightly_smiling:


#4

I am from China. Connecting to Amazon Services in China is always slow, especially the America Region.

When I play around with Elixir, I encountered the same problem。They told me the solution is to change the setting so you can using the southeast-asia mirror instead of the north america. But so far as I know, Cargo does not support that.I usually try at least three times.If those all fail,I’ll download the source code from github,then change the /home/psycho/.cargo/config file like this:

paths = ["/home/psycho/.cargo/registry/src/github.com-0a35038f75765ae4/curl-sys-0.1.29"]

#5

Thank you all.
I got around this problem by Overriding Dependencies.

http://doc.crates.io/guide.html#overriding-dependencies

The code is from https://doc.rust-lang.org/stable/book/guessing-game.html
From the Cargo.toml, I find it need winapi0.2.5, libc0.2.4, rand0.3.12 crates.
So I git clone them to the /path/to/project/src/
The Cargo.toml

[dependencies]
rand = "0.3.12"

Then in the root of that project

mkdir .cargo
cd .cargo
vi config

The config content:

paths=["src/rand", "src/libc", "src/winapi-rs"]

Finally, it works.:laughing: