zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Rust 安装

2023-09-14 09:16:04 时间

1,Rust 安装

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ source $HOME/.cargo/env
$ rustc --version
rustc 1.37.0 (eae3437df 2019-08-13)

2,国内安装

# export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
# export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# source $HOME/.cargo/env
# rustc --version
rustc 1.42.0 (b8cedc004 2020-03-09)

3,macos安装rust

$ brew install rust
  • 更新
brew upgrade golang

4,macos vscode

  • Rust (rls)
    在这里插入图片描述
  • CodeLLDB
    在这里插入图片描述
$ rustc --version
rustc 1.37.0 (eae3437df 2019-08-13)
$ rustup component add rls rust-analysis rust-src
info: downloading component 'rls'
  6.0 MiB /   6.0 MiB (100 %) 211.2 KiB/s in 37s ETA:  0s
info: installing component 'rls'
info: component 'rust-analysis' for target 'x86_64-apple-darwin' is up to date
info: downloading component 'rust-src'
  2.5 MiB /   2.5 MiB (100 %) 236.8 KiB/s in 13s ETA:  0s
info: installing component 'rust-src'
  • crates
    在这里插入图片描述
  • TOML
    在这里插入图片描述

5,ubuntu安装rust

  • 安装报错
# curl https://sh.rustup.rs -sSf | sh
info: downloading installer
error: it looks like you have an existing installation of Rust at:
error: /usr/bin
error: rustup should not be installed alongside Rust. Please uninstall your existing Rust first.
error: Otherwise you may have confusion unless you are careful with your PATH
error: If you are sure that you want both rustup and your already installed Rust
error: then please restart the installation and pass `-y' to bypass this check.
error: cannot install while Rust is installed
  • 加参数-y
curl https://sh.rustup.rs -sSf | sh -s -- -y
  • 安装成功
# source $HOME/.cargo/env
# rustc --version
rustc 1.43.1 (8d69840ab 2020-05-04)
# rust
rustc      rustdoc    rustfmt    rust-gdb   rust-lldb  rustup

6,rust卸载

rustup self uninstall

参考:

  1. 安装 Rust
  2. Rust Toolchain 反向代理使用帮助
  3. 如何用VSCode调试Rust(译)
  4. macOS 安装 Rust 开发环境
  5. Other Rust Installation Methods
  6. 卸载 Rust 环境