【问题标题】:How to install Rust via CLI on Windows?如何在 Windows 上通过 CLI 安装 Rust?
【发布时间】:2023-02-01 10:52:12
【问题描述】:

我正在尝试通过 Windows VM (https://github.com/sansyrox/robyn/pull/263) 上的命令行安装 Rust。主要 Rust installation website 上的脚本仅支持 *nix 操作系统。

在 Windows VM 上下载和安装 Rust 的命令是什么?

【问题讨论】:

  • 有一个指向具有 Windows 特定方法的 the other installation page 的链接。
  • @wkl,他们都希望您使用 gui 安装程序。据我了解。
  • 您可以使用 Chocolatey、Scoop,该页面还将您链接到 rustup。这些都不需要 GUI 安装程序。
  • @wkl,从 cli 安装所有内容的命令是什么?因为简单的 curl 或 wget 不起作用。

标签: windows rust rustup


【解决方案1】:

按照Other ways to install rustup中的说明进行操作。根据您选择的目标工具链下载rustup-init.exe

您可以使用--help 查看有哪些选项可以配置安装:

> .
ustup-init.exe --help
rustup-init 1.24.3 (ce5817a94 2021-05-31)
The installer for rustup

USAGE:
    rustup-init.exe [FLAGS] [OPTIONS]

FLAGS:
    -v, --verbose                        Enable verbose output
    -q, --quiet                          Disable progress output
    -y                                   Disable confirmation prompt.
        --no-update-default-toolchain    Don't update any existing default toolchain after install
        --no-modify-path                 Don't configure the PATH environment variable
    -h, --help                           Prints help information
    -V, --version                        Prints version information

OPTIONS:
        --default-host <default-host>              Choose a default host triple
        --default-toolchain <default-toolchain>    Choose a default toolchain to install
        --profile <profile>                         [default: default]  [possible values: minimal, default, complete]
    -c, --component <components>...                Component name to also install
    -t, --target <targets>...                      Target name to also install

基本的-y 应该适合你;它将安装rustup 和默认工具链。您当然可以使用wget 在脚本中下载安装程序。

> wget https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe
> .
ustup-init.exe -vy

请注意,MSVC 工具链需要您安装 Visual C++ 构建工具才能运行。我不确定如何在仅限 CLI 的环境中安装它们。希望 .exe 的功能类似。

也可以看看:

【讨论】:

    【解决方案2】:

    使用 scoop 安装它,以便使用一个命令在您的系统上更轻松地管理包:

    scoop install rustup-gnu 用于 GNU 工具链

    或者

    scoop install rustup 用于 MSVC 工具链

    然后你可以随时更新rustup或卸载它:

    scoop upgrade rustup

    scoop uninstall rustup

    【讨论】:

      猜你喜欢
      • 2020-10-06
      • 2014-02-07
      • 2015-09-20
      • 1970-01-01
      • 2022-11-27
      • 2020-04-26
      • 1970-01-01
      • 2016-09-11
      • 2023-03-22
      相关资源
      最近更新 更多