简体   繁体   English

如何从 crates.io 指向 crate 文件的本地副本?

[英]How to point to local copy of .crate file of crate from crates.io?

I am behind a corporate proxy that won't let me access crates.io from our development hosts.我的公司代理不允许我从我们的开发主机访问 crates.io。 I have downloaded all the crates I need and have them locally.我已经下载了我需要的所有 crate 并将它们放在本地。 The project I am building is from a 3rd party who have provided their own (~100 of them) Cargo.toml files.我正在构建的项目来自第三方,他们提供了自己的(约 100 个)Cargo.toml 文件。 How do I override the location of every dependency instead of changing every Cargo.toml to point to my local copy?如何覆盖每个依赖项的位置,而不是将每个 Cargo.toml 更改为指向我的本地副本?

I tried adding paths = [ "path/to/crates" ] to ~/.cargo/config & ~/.cargo/config.toml , but to no avail.我尝试将paths = [ "path/to/crates" ]添加到~/.cargo/config & ~/.cargo/config.toml ,但无济于事。 Is it possible or is there an alternative?有可能还是有替代方案?

I tried this in my ~/.cargo/config.toml我在我的~/.cargo/config.toml中试过这个

[source]
[source.my-crates]
local-registry = "/absolute/path/to/location/where/i/have/star.crate"
[source.crates-io]
replace-with = "my-crates"

However, it doesn't even look like it is being used.但是,它甚至看起来都没有被使用。 It still looks for crates.io-index它仍然在寻找 crates.io-index

The problem turned out to be missing CARGO_HOME environment variable.问题原来是缺少CARGO_HOME环境变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM