Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Methods and steps for Windows WSL2 to install Rust development environment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the methods and steps of installing Rust development environment in Windows WSL2, which interested friends may wish to take a look at. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Windows WSL2 installation of Rust development environment methods and steps" it!

Install WSL

Alpine Linux is installed here, which is small in size and consumes less resources.

Install Apline WSL

Https://www.microsoft.com/en-us/p/alpine-wsl/9p804crf0395#activetab=pivot:overviewtab

Installation and configuration: sudo command

# Log in to rootsu# to install sudoapk add sudo# and add the user name to wheel before you can execute sudoaddgroup [username] wheel# to remove sudo, enter the password visudo# to find the line "#% wheel ALL= (ALL) NOPASSWD: ALL", remove the'# 'sign to uncomment, and: wq save.

Add Aliyun Apline source to speed up software installation

Sudo sed-I's Universe dlmurcdn.alpinelinux.orgUniver mirrors.aliyun.com Universe g' / etc/apk/repositories

Install the basic software package

Sudo apk add bash wget curl git vim tar gzip build-base install Rust

1. Accelerate Rust installation

Export RUSTUP_DIST_SERVER= https://mirrors.ustc.edu.cn/rust-staticexport RUSTUP_UPDATE_ROOT= https://mirrors.ustc.edu.cn/rust-static/rustup

two。 Install Rust

Curl-- proto'= https'-- tlsv1.2-sSf https://sh.rustup.rs | sh

3. Configure cargo Ali cloud source to accelerate cargo install

Vim / .cargo/config

Put the following in the file above, and then: wq

[source.crates-io] registry = "https://github.com/rust-lang/crates.io-index"replace-with =" rustcc "[source.rustcc] registry =" https://code.aliyun.com/rustcc/crates.io-index.git" Test Rust

Check the version:

Rustc-V# output: rustc 1.51.0 (2fd73fabe 2021-03-23) cargo-V# output: cargo 1.51.0 (43b129a20 2021-03-16)

two。 Check if the build is normal.

# create a demo project cargo new first_democd first_democargo build## output: Compiling first_demo v0.1.0 (/ home/xxx/workspace/vscode/demo/first_demo) # # Finished dev [unoptimized + debuginfo] target (s) in 0.78scargo run## output: Finished dev [unoptimized + debuginfo] target (s) in 0.00s## Running `target/debug/first_ demo` # Hello, world! Install vscode (Visual Studio Code)

Install vscode in windows:

Https://code.visualstudio.com/download

Open VSCode and install Remote-WSL and Rust plug-ins.

"ctrl + shift + p" calls up the command, enter wsl, select "Remote-WSL:New Window using Distro...", and then select "Apline".

Open the "first_demo" you created and you can start playing.

At this point, I believe that you have a deeper understanding of the "methods and steps for Windows WSL2 to install the Rust development environment". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report