Problem
If one is using a mirror of crates.io, the error message you get when you attempt to publish is confusing. It says:
error: crates cannot be published to crates.io with dependencies sourced from other
registries either publish `bitflags` on crates.io or pull it into this repository
and specify it with a path and version
(crate `bitflags` is pulled from registry `https://github.com/rust-lang/crates.io-index`)
The last line clearly says that it is from "crates.io".
Steps
.cargo/config file to set up the mirror:[source.crates-io]
replace-with="mirror"
[source.mirror]
registry = "file:///path/to/crates.io-index"
cargo publish --dry-runPossible Solution(s)
Notes
Same problem, annotated ~/.cargo/config temporarily.
# [source.crates-io]
# registry = "https://github.com/rust-lang/crates.io-index"
# replace-with = 'ustc'
# [source.ustc]
# registry = "git://mirrors.ustc.edu.cn/crates.io-index"
Connection to GitHub is basically trash for some ISPs in China, so a mirror is sometimes required. Having to comment out ~/.cargo/config every time I need to publish a crate can be annoying.
Most helpful comment
Same problem, annotated
~/.cargo/configtemporarily.