简体   繁体   中英

How to install Rust via CLI on Windows?

I am trying to install Rust via the command line on a Windows VM ( https://github.com/sansyrox/robyn/pull/263 ). The script on the main Rust installation website only supports *nix os.

What are the commands to download and install Rust on a Windows VM?

Follow directions in Other ways to install rustup . Download rustup-init.exe based on the target toolchain of your choice:

You can use --help to see what options there are to configure the installation:

> .\rustup-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

The basic -y should work for you; it will install rustup and the default toolchain. You can of course use wget to download the installer within a script.

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

Note, the MSVC toolchain will require you to install the Visual C++ Build Tools to function. I'm unsure how to install those in a CLI only environment. Hopefully the .exe for that functions similarly.

See also:

Install it with scoop for easier package management on your system with a single command:

scoop install rustup-gnu for GNU toolchain

or

scoop install rustup for MSVC toolchain

Then you can update rustup or uninstall it whenever you want with:

scoop upgrade rustup

scoop uninstall rustup .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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