вторник, 10 декабря 2019 г.

Install Rust

Rust
A language empowering everyone to build reliable and efficient software.

On Windows, download and run rustup-init.exe. It will start the installation in a console.
After this, you can use the rustup command to also install beta or nightly channels for Rust and Cargo.

It is default option to install Rust. Installers are still available, but you should use rustup if possible, because it makes it easy to update and to use multiple toolchains at once (e.g. stable, beta and nightly). If you must use the installer, just select the x86_64-pc-windows-gnu installer and follow the step from the Using Rust on Windows page. If you're using rustup, read on.

By default, rustup on Windows installs the compiler and tools targeting the MSVC toolchain (x86_64-pc-windows-msvc), rather than the GNU/MinGW-w64 toolchain. At the initial menu, select 2) Customize installation. When asked for a host triple, enter x86_64-pc-windows-gnu. Then make a choice for the other questions, then proceed with the installation.

For debugging in CLion we need GNU toolchain:
If rustup is already installed, then rerunning rustup-init won't actually install the requested toolchain. Instead, run:
> rustup toolchain install stable-x86_64-pc-windows-gnu
if you already have the MSVC-based toolchain.
 
Then run:
> rustup default stable-x86_64-pc-windows-gnu
to set the GNU-based toolchain as the default.

To install the MSVC-based toolchain:
> rustup toolchain install stable-x86_64-pc-windows-msvc

To set the MSVC-based toolchain as the defaul:
> rustup default stable-x86_64-pc-windows-msvc

If you have a previous version of Rust installed via rustup, getting new Rust is as easy as:
> rustup update stable

To uninstall Rust and rustup, run the following uninstall script from your shell:
> rustup self uninstall

To test that you have Rust and Cargo installed, you can run this in your terminal of choice:
> cargo --version
> cargo -V
> rustc --version
> rustc -V

The installer also includes a copy of the documentation locally, so you can read it offline:
> rustup doc

You can install a code formatting tool (Rustfmt) with:
> rustup component add rustfmt

and a linting tool (Clippy) with:
> rustup component add clippy

MSYS2:
Rustup will install the MinGW linker and platform libraries automatically (as part of the rust-mingw component) and refuses to let you remove them. If you prefer to use the MinGW linker and libraries you installed with MSYS2, you'll need to create a .cargo/config file (either in your profile directory, i.e. C:\Users\you\.cargo\config, or in your project's directory if this configuration is specific to a project). The contents of that file might look like this:

[target.x86_64-pc-windows-gnu]

linker = "C:\\msys2\\mingw64\\bin\\gcc.exe"
ar = "C:\\msys2\\mingw64\\bin\\ar.exe"

Rustup will modify the PATH environment variable unless you told it not to. However, MSYS2 resets PATH by default when you launch, so when you try to invoke cargo or rustc from your MSYS2 shell, it might not find it. You'll need to edit your .profile/.bash_profile script to set the PATH correctly (you need to prepend /c/Users/yourname/.cargo/bin: to PATH).
Original post

More info.

Комментариев нет:

Отправить комментарий