【问题标题】:How can I install using cargo when offline?离线时如何使用 cargo 安装?
【发布时间】:2021-08-06 07:28:27
【问题描述】:

我想在我的工作区使用 bat 和 lsd。

但是为了安全起见,我公司的 Centos 6 Linux 服务器已与 Internet 断开连接。

但我们可以安装一些有助于工作的东西。

> cargo install --locked bat
    Updating crates.io index
warning: spurious network error (2 tries remaining): failed to resolve address for github.com: Temporary failure in name resolution; class=Net (12)
warning: spurious network error (1 tries remaining): failed to resolve address for github.com: Temporary failure in name resolution; class=Net (12)
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to resolve address for github.com: Temporary failure in name resolution; class=Net (12)

我该怎么做?

【问题讨论】:

    标签: installation rust rust-cargo


    【解决方案1】:

    下面的说明对于任何其他板条箱都没有太大的不同。

    1. 下载存储库:

      git clone https://github.com/sharkdp/bat.git --depth 1 --branch v0.18.1
      cd bat
      

      这只是获取bat crate 的0.18.1 版本。

    2. 使用cargo vendor在本地机器上下载和捆绑包的依赖:

      cargo vendor
      
      • 如果与另一台机器不同(即cargo +<TOOLCHAIN> vendor),可选择指定toolchain
      • 如果与另一台机器不同(即cargo vendor --target <TARGET>),则可选择指定target

      请务必按照末尾的说明创建/添加到.cargo/config.toml 文件。您还可以检查现在位于 vendor/ 目录中的所有依赖项。

    3. 压缩并将整个当前目录传输到另一台机器。

    4. 使用cargo install进行安装:

      cargo install --offline --path <PATH>
      
      • 使用--path 告诉它安装目录
      • 使用--offline 阻止它以任何理由访问网络

    【讨论】:

    • 他们将如何在没有互联网连接的情况下克隆 GitHub 存储库?
    猜你喜欢
    • 1970-01-01
    • 2020-01-27
    • 2015-07-07
    • 2015-10-22
    • 2017-08-21
    • 2012-07-11
    • 2012-06-20
    • 2019-01-26
    相关资源
    最近更新 更多