apt install rust
这个是不带cargo/rustup那些的
wget https://github.com/rust-lang-nursery/rustup.rs/archive/1.14.0.tar.gz
tar xzvf 1.14.0.tar.gz
cd rustup.rs-1.14.0
./rustup-init.sh
需。。如果半天不动,手动去下载如下安装文件。。
wget https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
vim rustup-init.sh
注释掉103行的下载步骤。手动指定刚刚下载的安装文件rustup-init
# ensure downloader "$_url" "$_file"
_file="/root/download/rustup.rs-1.14.0/rustup-init"
注释掉132行左右的rm,免得被误删。。
#ignore rm "$_file"
#ignore rmdir "$_dir"
保存退出
//加上中科大镜像
vim /etc/profile
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
md ~/.cargo && vim ~/.cargo/config
[source.crates-io]
registry="https://github.com/rust-lang/crates.io-index"
replace-with='ustc'
[source.ustc]
registry='git://mirrors.ustc.edu.cn/crates.io-index'
./rustup-init.sh -y
这时候无需就会自动安装了。
$ ./rustup-init.sh -y
info: downloading installer
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2018-09-25, rust version 1.29.1 (b801ae664 2018-09-20)
info: downloading component 'rustc'
69.7 MiB / 69.7 MiB (100 %) 528.0 KiB/s ETA: 0 s
info: downloading component 'rust-std'
51.0 MiB / 51.0 MiB (100 %) 528.0 KiB/s ETA: 0 s
info: downloading component 'cargo'
5.0 MiB / 5.0 MiB (100 %) 528.0 KiB/s ETA: 0 s
info: downloading component 'rust-docs'
8.2 MiB / 8.2 MiB (100 %) 524.8 KiB/s ETA: 0 s
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: default toolchain set to 'stable'
stable installed - rustc 1.29.1 (b801ae664 2018-09-20)
Rust is installed now. Great!
To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done automatically.
To configure your current shell run source $HOME/.cargo/env
设置环境变量
source $HOME/.cargo/env
cargo update
rustup self update
$ rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: checking for self-updates
stable-x86_64-unknown-linux-gnu unchanged - rustc 1.29.1 (b801ae664 2018-09-20)
root at debian in ~/download/rustup.rs-1.14.0
$ cargo update
Updating registry `git://mirrors.ustc.edu.cn/crates.io-index`
Updating curl-sys v0.4.11 -> v0.4.12
Updating digest v0.7.5 -> v0.7.6
Updating encoding_rs v0.8.6 -> v0.8.7
Updating httparse v1.3.2 -> v1.3.3
Updating lazycell v1.1.0 -> v1.2.0
Updating libflate v0.1.16 -> v0.1.18
Updating libz-sys v1.0.22 -> v1.0.23
Updating lock_api v0.1.3 -> v0.1.4
Updating schannel v0.1.13 -> v0.1.14
Updating serde_json v1.0.27 -> v1.0.31
Updating syn v0.15.4 -> v0.15.6
Updating tar v0.4.16 -> v0.4.17
Updating tokio v0.1.8 -> v0.1.11
Updating tokio-codec v0.1.0 -> v0.1.1
Updating tokio-current-thread v0.1.1 -> v0.1.3
Updating tokio-executor v0.1.4 -> v0.1.5
Updating tokio-io v0.1.8 -> v0.1.9
Updating tokio-reactor v0.1.5 -> v0.1.6
Updating tokio-tcp v0.1.1 -> v0.1.2
Updating tokio-threadpool v0.1.6 -> v0.1.7
Updating tokio-timer v0.2.6 -> v0.2.7
Updating tokio-uds v0.2.1 -> v0.2.2
Updating toml v0.4.6 -> v0.4.7
Updating version_check v0.1.4 -> v0.1.5
Updating winapi v0.3.5 -> v0.3.6
安装toolchain
rustup toolchain install nightly-x86_64-unknown-linux-gnu
rustup toolchain install nightly
rustup default nightly
查看toolchain
# rustup toolchain list
stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
安装插件。。
rustup component add rls
rustup component add rust-src
rustup component add rust-analysis
vim hello.rs
fn main(){
let s="hi";
println!{"{}",s};
}
# rustc hello.rs
# ./hello
hi