如何在没有互联网的环境中安装生锈依赖性?

发布于 2025-02-10 21:10:51 字数 393 浏览 2 评论 0原文

我想使用 Tango Client crate crate 在一个Rust Project有效,但是我将要开发的环境没有直接访问互联网。这意味着将依赖关系添加到cargo.toml和运行货物构建由于网络错误而失败的标准方法。

环境并不能阻止我将下载的数据复制到与Internet连接的计算机中,因此我希望我可以在本地包装必要的文件,然后点CARGO.TOML 到该位置。

这可能吗?如果是这样,怎么样?

I would like to use the tango client crate for a Rust project at work, however the environment that I will be developing this in does not have direct access to the internet. This means that the standard method of adding the dependency to Cargo.toml and running cargo build fails due to a network error.

The environment doesn't prevent me from copying data downloaded to an internet-connected computer, and so I was hoping that there would be a way for me to package the necessary files locally, and then point Cargo.toml to that location.

Is this possible? If so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

大海や 2025-02-17 21:10:51

回答我自己的问题,这要归功于@dogbert的评论中的提示。

诀窍是在具有Internet连接的机器上使用货物供应商。这将产生一个称为供应商的目录,该目录可以转移到其他环境中。在该环境以及将运行货物构建的目录中,在.cargo/config中创建一个新文件。

[source]
[source.local_vendor]
directory = "vendor"

[source.crates-io]
replace-with = "local_vendor"

完成此操作后,货物构建应该有效。

Answering my own question, thanks to a tip in a comment from @Dogbert.

The trick was to use cargo vendor on the machine that has an internet connection. This will produce a directory called vendor that can be transferred to the other environment. On that environment, and within the directory from which you will run cargo build, create a new file in .cargo/config.

[source]
[source.local_vendor]
directory = "vendor"

[source.crates-io]
replace-with = "local_vendor"

Once you've done this, then cargo build should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文