Skip to main content
  1. Documentation/

Install Rust

477 words·3 mins
Rust
Table of Contents

Macos
#

https://www.rust-lang.org/tools/install

Centos 7
#

Note: Before installing Rust, make sure that the system has installed C and C++ compilers, as well as other necessary dependencies. You can use the following command to install these dependencies:

sudo yum install -y gcc gcc-c++ make openssl-devel

Open a terminal and update the system:
#

sudo yum update

Install Rust:
#

curl https://sh.rustup.rs -sSf | sh

This command will download and run the Rust installation script. During the installation process, you will be prompted to choose the default options or customize the installation as needed.

Configure the Rust environment variables:
#

After Rust is installed, you need to add the Rust binary file path to the system’s PATH environment variable. You can use the following command to add the Rust binary file path to the PATH environment variable:

source $HOME/.cargo/env

Verify that Rust is installed successfully:
#

You can use the following command to verify that Rust is installed successfully:

rustc --version

small exercise
#

install exercise tool manually

git clone -b 5.6.1 --depth 1 https://github.com/rust-lang/rustlings
cd rustlings
cargo install --force --path .

doing exercises with rustlings

rustlings watch
# rustlings run myuExercise
# rustlings hint myExercise
# ruslings verify
# rustlings list

uninstalling rustlings

cargo uninstall rustlings

Ubuntu22.04
#

To install Rust on Ubuntu 22.04, you can use rustup, which is the recommended way to install the Rust programming language. Here are the steps:

  1. First, download and install rustup by running the following command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. The above command will download a script and start the installation. You will be prompted to proceed with the installation. Press “1” and then “Enter” to proceed with the default installation.

  2. Once the installation is complete, close the terminal and open a new one.

  3. Add the cargo and rustc binaries to your PATH with the following command:

source $HOME/.cargo/env
  1. Verify the installation by running the following command:
rustc --version

This should display the installed version of Rust.

Run the source $HOME/.cargo/env command in every new terminal you open or add the command to your .bashrc or .zshrc file to automatically set the PATH for every new terminal session.

Errors may Occur
#

The error “linker cc not found” typically means that the C compiler is not installed on your system. Rust needs the C compiler for linking.

On Ubuntu, you can install the C compiler (gcc) by installing the build-essential package. This package also includes other tools that are necessary for building software.

You can install it by running the following command in your terminal:

sudo apt update
sudo apt install build-essential
sudo apt-get install manpages-dev

After the installation is complete, you should be able to compile your Rust program. If you still encounter the same error, you might need to restart your terminal or your computer for the changes to take effect.

Related

Rust 宏使用方法以及属性说明
468 words·3 mins
Rust
#[derive(Debug)] 是一个 Rust 内置的属性,用于为结构体或枚举类型自动生成 Debug trait 的实现。
Rust 生命周期参数及Trait的说明
496 words·3 mins
Rust
use std::fmt; // 结构体实现了 Display trait, 和实现 Debug trait.
数据结构&控制结构实现原理
564 words·3 mins
Golang
Map 扩容条件与操作原理 # 负载因子 > 6.
How Networks work 笔记
119 words·1 min
Book Note
《How Networks work》 # 第一章 浏览器生成消息 # 浏览器的第一步工作就是对URL进行解析
Building Multi-Architecture Docker images
744 words·4 mins
Kiga-Hub
Casual Essay
Architecture docker Arm64
Leverage multi-CPU architecture support # Docker images can support multiple architectures, which means that a single image may contain variants for different architectures, and sometimes for different operating systems, such as Windows.