rust环境配置
Windows
- 环境配置:
1. 创建2个文件夹
2.
CARGO_HOME : 刚才创建的对应文件路径, 如: E:\Environment\RUST\CARGO
RUSTUP_HOME: 刚才创建的对应文件路径, 如: E:\Environment\RUST\RUSTUP
3. 配置安装源: [设置环境变量]
RUSTUP_DIST_SERVER : https://mirrors.ustc.edu.cn/rust-static
RUSTUP_UPDATE_ROOT : https://mirrors.ustc.edu.cn/rust-static/rustup
- 运行 rustup-init.exe (从官网下载)
-
WIN:基于mingw64
自定义安装 :x86_64-pc-windows-gnu,stable,y
-
WIN 基于 msvc(推荐):
安装:visual c++ build tools
Linux
0. 确保拥有c编译环境(gcc/cc等均可)
1. 创建2个文件夹并配置环境变量
CARGO_HOME=刚才创建的对应文件路径, RUSTUP_HOME=刚才创建的对应文件路径,
export CARGO_HOME=~/Environment/RUST/CARGO
export RUSTUP_HOME~/Environment/RUST/RUSTUP
2. 配置安装源: [设置环境变量]
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
如下命令也可以
(#echo 'export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup' >> ~/.bash_profile )
(#echo 'export RUSTUP_UPDATE_ROOT : https://mirrors.ustc.edu.cn/rust-static/rustup' >> ~/.bash_profile )
3. curl https://sh.rustup.rs -sSf | sh
4. . $HOME/.cargo/env (安装程序最后提示 source xxxxx ,不一致则以此为准
5. 将以上路径设置环境变量
rustc -V 查看版本,如果正常显示则OK
Update & Other:
rust更新比较频繁,每隔一段时间可以使用以下命令更新: rustup update
rustc -V 可查看当前rust版本
配置cargo镜像源
window用户 在以下路径 C:\Users[用户名].cargo\config
linux用户在 ~/.cargo/config
(如果不存在手动创建即可)
填入如下内容(两个源任选其一
#以下任选一个即可
# ustc 源
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index/"
#tuna 源
[source.crates-io]
replace-with = 'tuna'
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
cargo常用命令
cargo new hello
cargo run
cargo check
推荐的书:
在线文档:https://kaisery.gitbooks.io/rust-book-chinese/content/
https://doc.rust-lang.org/stable/rust-by-example/
https://doc.rust-lang.org/book/
rust死灵书
….
以下内容与rust无关:
vscode插件:
tabnine
rust-analyzer
##需要node环境且vscode/bin在环境变量
git clone https://github.com/rust-analyzer/rust-analyzer.git
cd rust-analyzer
cargo xtask install//cargo install-ra
vscode配置远程开发:
centos :
sudo yum install openssh-server && sudo systemctl start sshd.service && sudo systemctl enable sshd.service
windows:
- **安装*Remote Development*插件
ssh-keygen -t rsa -b 4096
Host xxx.xxx.xxx.xxx HostName xxx.xxx.xxx.xxx User root ForwardAgent yes
- Author: DY
- Link: http://4fan.top/posts/rust%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.