首页 > 编程语言 > 详细

Win7 VSCode Rust语言配置

时间:2019-08-17 12:25:34      阅读:427      评论:0      收藏:0      [点我收藏+]

最折腾的语言配置

下载

https://www.rust-lang.org/learn/get-started

安装必需用rustup-init.exe,什么离线安装包你装上也没用,VSCode识别不了,反正我试了几次都不行。

而rustup-init.exe不用代理安装不了,必须有代理才行。

安装前你还应该有Visual Studio Build Tool,或者你的电脑装过Visual Studio就自带Visual Studio Build Tool,没有的话需要安装一下,这也是看其他博客写的,我没遇到过这个问题,因为我的电脑一定会有Visual Studio

 

首先新建2个环境变量

CARGO_HOME

RUSTUP_HOME

技术分享图片

技术分享图片

建个Rust目录,然后新建这2个目录,加入到环境变量中。

然后把下载的rustup-init.exe丢到

E:\Rust

管理员权限(也可能不用)运行Powershell,打开代理,Powershell中设置代理

$proxy=http://127.0.0.1:1080
$ENV:HTTP_PROXY=$proxy
$ENV:HTTPS_PROXY=$proxy
.\rustup-init.exe

不用代理的话铁定出现

info: syncing channel updates for stable-x86_64-pc-windows-msvc
error: could not download file from https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256 to C:\Users\350627\.rustup\tmp\l3ogei4e89gnb1df_file
info: caused by: error during download

国内这垃圾网络就这样。

一切正常的话显示,安装会显示类似下面的内容,我是按1默认安装。

Welcome to Rust!

This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to Cargos bin
directory, located at:

  E:\Rust\cargo\bin

This path will then be added to your PATH environment variable by modifying the
HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and these changes will
be reverted.

Current installation options:

   default host triple: x86_64-pc-windows-msvc
     default toolchain: stable
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: syncing channel updates for stable-x86_64-pc-windows-msvc
info: latest update on 2019-08-15, rust version 1.37.0 (eae3437df 2019-08-13)
info: downloading component rustc
 60.4 MiB /  60.4 MiB (100 %) 712.0 KiB/s in 51s ETA:  0s
info: downloading component rust-std
 56.1 MiB /  56.1 MiB (100 %) 582.5 KiB/s in 56s ETA:  0s
info: downloading component cargo
  3.0 MiB /   3.0 MiB (100 %) 670.0 KiB/s in  4s ETA:  0s
info: downloading component rust-docs
 11.3 MiB /  11.3 MiB (100 %) 312.2 KiB/s in 23s ETA:  0s
info: installing component rustc
 60.4 MiB /  60.4 MiB (100 %)  12.7 MiB/s in  4s ETA:  0s
info: installing component rust-std
 56.1 MiB /  56.1 MiB (100 %)  10.6 MiB/s in  6s ETA:  0s
info: installing component cargo
  3.0 MiB /   3.0 MiB (100 %)  32.0 KiB/s in  5s ETA:  0s
info: installing component rust-docs
 11.3 MiB /  11.3 MiB (100 %)  12.8 KiB/s in  1m 12s ETA:  0s
info: default toolchain set to stable

  stable installed - rustc 1.37.0 (eae3437df 2019-08-13)


Rust is installed now. Great!

To get started you need Cargos bin directory (E:\Rust\cargo\bin) in your PATH
environment variable. Future applications will automatically have the correct
environment, but you may need to restart your current shell.

Press the Enter key to continue.

 

这样Rust算是安装成功了。

 

打开VSCode搜Rust扩展

Rust

Rust(rls)

装完后,新建一个main.rs

内容如下

fn main()
{
    println!("Hello World!");
}

运行

技术分享图片

VSCode可能会自动下载相关内容

 

Win7 VSCode Rust语言配置

原文:https://www.cnblogs.com/kileyi/p/11367866.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!