Back
Featured image of post Installing Rust n Cargo

Installing Rust n Cargo

A tiny set of code snippets to Install Rust on your laptop

Table of Content

The easiest way to get Cargo is to install the current stable release of Rust by using rustup. Installing Rust using rustup will also install cargo.

Rust Installation

On Linux and macOS systems, this is done as follows:

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

After request the installation, you should see the script downloading all required tools

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
info: downloading installer

Welcome to Rust!

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

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/r00t/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /home/r00t/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/r00t/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/r00t/.profile
  /home/r00t/.zshenv

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

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

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

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2022-01-13, rust version 1.58.0 (02072b482 2022-01-11)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
 53.2 MiB /  53.2 MiB (100 %)  45.9 MiB/s in  1s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 18.9 MiB /  18.9 MiB (100 %)  11.2 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
 25.1 MiB /  25.1 MiB (100 %)  13.4 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 53.2 MiB /  53.2 MiB (100 %)  15.5 MiB/s in  3s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.58.0 (02072b482 2022-01-11)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

## Rust environment setup

To configure your current shell, run:
source $HOME/.cargo/env

If you want to configure your terminal, just use the command provided

1
source $HOME/.cargo/env

However, to make it permanent, you can edit your $HOME/.profile adding the line

1
export PATH=$PATH:$HOME/.cargo/bin

And this is all, rust should be installed and configured in your machine.

References



💬 Share this post in social media

Thanks for checking this out and I hope you found the info useful! If you have any questions, don't hesitate to write me a comment below. And remember that if you like to see more content on, just let me know it and share this post with your colleges, co-workers, FFF, etc.

You are free to use the content, but mention the author (@MrSergioAnguita) and link the post!
Last updated on Jan 18, 2022 14:45 CET
Please, don't try to hack this website servers. Guess why...