Technology Sharing

Rust development environment setup

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Rust development environment setup

environment

rust: 1.79.0(2024-06-13)
  • 1

1. Rustup downloader online installation

windows:

https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe

unix:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • 1

2. Rust independent installation package offline installation

windows:

https://static.rust-lang.org/dist/rust-1.79.0-x86_64-pc-windows-msvc.msi

linux:

https://static.rust-lang.org/dist/rust-1.79.0-x86_64-unknown-linux-gnu.tar.xz

macos:

https://static.rust-lang.org/dist/rust-1.79.0-x86_64-apple-darwin.pkg

3. Rust Command Line

  • Check the Rust version
$ rustc -V
rustc 1.79.0
  • 1
  • 2
  • Create a new rust project
cargo new hello_world
  • 1
  • Compile the Rust project with cargo
$ cargo build
  • 1
  • rustc compiles rust project
$ rustc src/main.rs
  • 1
  • Running a Rust program
$ ./target/debug/hello_world
Hello, world!
  • 1
  • 2

4. IDE Integrated Development Environment

4.1 VSCode

Rust with Visual Studio Code

4.2 vs2022

[User Manual (rust-analyzer.github.io)

5. Use mirroring to speed up cargo

Add the following content to $CARGO_HOME/config

[source.crates-io]
replace-with = 'mirror'

[source.mirror]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
  • 1
  • 2
  • 3
  • 4
  • 5

Note:$CARGO_HOME: On Windows the default is:%USERPROFILE%.cargo, the default on Unix-like systems is:$HOME/.cargo


Reference:

  1. Other Installation Methods - Rust Forge (rust-lang.org)