話說前面: 若是你 以前安裝過老版本的 rust 請先卸載 我說的是以 msi 文件安裝的那種, 請進控制面板–> 程序中進行卸載
首先 下載官網 的 rustup-init.exe 當前版本是 1.18.0
而後下載完 而後點擊 rusupt-init.exe
奇蹟發生了:
選 2 進行自定義安裝 會一步一步問你 第一個問你是否用 default host tripe 我選的是
第二個會問你 用哪一個版本 我輸入 stable
第三個會問你是否 默認修改環境變量 (這個無所謂了能夠後期改) 我選是
而後就會安裝…html
安裝完成後你會發如今 c 盤–> 用戶—->(你的登錄名下) 會多出兩個文件夾. rustup 文件夾和. cargo 文件夾
若是你不想將這兩個文件夾放置在 c 盤下那麼就把它們剪切到別的盤符下我是移動到了別的盤符了, 單單移動是不行的
那麼你還得 修改環境變量: git
CARGO_HOME = "%USERPROFILE%\.cargo"
RUSTUP_HOME = "%USERPROFILE%\.rustup"
接着添加中科大 rust 源:
在. cargo 文件夾根目錄下建立一個 config 文件 沒有任何文件後綴, 內容爲:github
[registry] index = "https://mirrors.ustc.edu.cn/crates.io-index/" [source.crates-io] registry = "https://github.com/rust-lang/crates.io-index" replace-with = 'ustc' [source.ustc] registry = "https://mirrors.ustc.edu.cn/crates.io-index/"
下載安裝鏡像時,你只須要把sql
https://static.rust-lang.org
換成 https://mirrors.ustc.edu.cn/rust-static
便可!windows
接着再添加環境變量:ruby
RUSTUP_DIST_SERVER = "http://mirrors.ustc.edu.cn/rust-static" RUSTUP_UPDATE_ROOT = "http://mirrors.ustc.edu.cn/rust-static/rustup"
將 cargo 加入 path 環境變量:ui
%CARGO_HOME%\bin
前期工做就能夠了 那麼打開 cmd 輸入
檢查 rustup 有無安裝成功spa
rustup -V
cargo -V
檢查 cargo 安裝
若是 提示沒有默認的 toolchain 那麼 install:插件
rustup install stable-x86_64-pc-windows-msvc
將 msvc 版設爲 defaultcode
rustup default stable-x86_64-pc-windows-msvc
若是設置成功 那麼 console 會打印出正確的版本號
安裝插件:
安裝 rustfmt:
首先 cmd 輸入:
rustup show
查看 當前 toolchain, 初次安裝應該只有 stable-msvc
那麼進行安裝 stable-gnu
rustup install stable-x86_64-pc-windows-gnu
rustup install nightly-x86_64-pc-windows-msvc
rustup install nightly-x86_64-pc-windows-gnu
安裝 rls-preview rust-analysis rust-src:
參考 https://github.com/rust-lang-nursery/rls
Note (nightly only)
Sometimes the rls-preview component is not included in a nightly build due to certain issues. To see if the component is included in a particular build and what to do if it's not, check #641.
rustup component add rls-preview rust-analysis rust-src --toolchain stable-x86_64-pc-windows-msvc
rustup component add rls-preview rust-analysis rust-src --toolchain stable-x86_64-pc-windows-gnu
rustup component add rust-analysis rust-src --toolchain nightly-x86_64-pc-windows-msvc
rustup component add rust-analysis rust-src --toolchain nightly-x86_64-pc-windows-gnu
安裝 cargo-release:
cargo +stable-x86_64-pc-windows-msvc install cargo-release
安裝 cargo-check:
cargo +stable-x86_64-pc-windows-msvc install cargo-check
安裝 rustfmt:
cargo +stable-x86_64-pc-windows-msvc install rustfmt
安裝 rustsym:
cargo +stable-x86_64-pc-windows-msvc install rustsym
安裝 racer:
cargo +stable-x86_64-pc-windows-msvc install racer
設置 rust_src_path 環境變量(此環境變量不該該寫死,在Linux中能夠採用靈活的方式肯定該變量值)
RUST_SRC_PATH = "%USERPROFILE%\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src"
參考 https://github.com/racer-rust/racer
Fetch the Rust sourcecode
automatically via rustup and run rustup component add rust-src in order to install the source to $(rustc --print sysroot)/lib/rustlib/src/rust/src. Rustup will keep the sources in sync with the toolchain if you run rustup update.
manually from git, or download from https://www.rust-lang.org/install.html (the 'rustc' source download behind the 'source' link is the right one).
Set the RUST_SRC_PATH environment variable to point to the 'src' dir in the Rust source installation
(e.g. % export RUST_SRC_PATH=/usr/local/src/rust/src or % export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src" )
Test on the command line:
racer complete std::io::B (should show some completions)