Difference between revisions of "Rust/C2/Installation-of-Rust-on-Linux/English"
Pravin1389 (Talk | contribs) |
Nancyvarkey (Talk | contribs) |
||
Line 3: | Line 3: | ||
Author: Jayesh Katta Ramalingaiah | Author: Jayesh Katta Ramalingaiah | ||
− | Domain Reviewer: | + | Domain Reviewer: Vigneshwer Dhinakaran |
Novice Reviewer: Praveen S | Novice Reviewer: Praveen S |
Latest revision as of 11:17, 21 June 2021
Title of the script: Installation of Rust on Linux OS
Author: Jayesh Katta Ramalingaiah
Domain Reviewer: Vigneshwer Dhinakaran
Novice Reviewer: Praveen S
Keywords: Rust, version, rustc, cargo, rustup
|
|
Slide: Title | Welcome to the spoken tutorial on Installation of Rust on Linux OS. |
Slide:
Learning Objectives |
In this tutorial, we will learn:
|
Slide: System Specifications | This tutorial is recorded using:
However you may use any other editor of your choice. |
Slide: Pre-requisites | To practice this tutorial,
|
Slide: Code files |
|
Only narration | Let us begin with the installation of Rust. |
Show commands.txt in text editor | I have opened the Commands.txt file in a text editor on my machine.
And I will use the same file to copy-paste the commands during the demonstration. Shortcut to paste commands on the terminal is Shift, Ctrl and V keys. |
Narration only | Let us begin. |
Press Ctrl+Alt+T keys | Open the terminal by pressing Ctrl,Alt and T keys simultaneously on the keyboard.
Ensure that you have root permissions to run the commands. |
Only Narration | Here onwards, please remember to press the Enter key after typing each command. |
[Terminal]
Type: sudo apt-get install curl -y [Enter] |
We will be installing Rust with the help of the curl command line tool.
So, we have to first install curl if we haven’t done so earlier. To do so type the command as shown on the terminal. |
[Terminal]
Enter admin password |
If prompted, enter the admin password to proceed further. |
[Terminal] Type:
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh [Enter] |
We have successfully installed curl.
Next let us download and install Rust using Curl. To do so type the command as shown on the terminal. |
Only Narration | The download may take some time depending upon your internet speed. |
[Terminal] Highlight one by one:
Proceed with installation (default) Customize installation Cancel installation |
Once the package is downloaded, we will be prompted to choose one of the following options:
Proceed with installation (default) Customize installation Cancel installation |
[Terminal] Type: 1 [Enter] | To proceed with default installation, type 1 and press Enter. |
[Terminal] Highlight:
Rust is installed now. Great! |
We have successfully installed Rust. |
[Terminal] Type:
sudo reboot [Enter] |
Once the installation is done, we need to restart our computer.
To do so, type sudo reboot in the terminal. This will restart your computer. |
Press Ctrl+Alt+T keys | Once you have restarted the computer, open the terminal again. |
[Terminal] Type:
rustc --version [Enter] |
Now let us cross verify the Rust installation.
Type the command as shown in the terminal. |
[Terminal] Highlight:
rustc 1.47.0 |
This command shows the version of Rust installed in your computer.
The version number may be different in your case. |
[Terminal] Type:
rustup [Enter] |
Now type rustup on the terminal. |
Only narration | This shows us a list of commands to run.
rustup is responsible for the complete Rust installation using the curl command. |
Slide: Rust Update
rustup update [Enter] |
If you wish to update your Rust version, then execute this command on the terminal. |
Slide: rustup toolchain list | rustup toolchain command lists the various toolchains of Rust installed in your machine.
For now, I have only one stable version installed. If you have any other versions, then that version would be displayed. |
Slide: cargo | cargo is a package manager to maintain a Rust project with dependencies. |
[Terminal] Type:
cargo [Enter] |
You can check whether cargo is installed or not using the cargo command in the terminal.
This shows a list of commands which can be executed using cargo. |
[Terminal] Type:
cargo --version [Enter] |
This command shows the version of the cargo package manager installed in your machine. |
Slide: Common Errors After Installation | Common Errors After Installation
|
Only narration | Next let us learn how to create and execute a Rust file. |
Open Visual Studio Code editor. | You may use any editor of your choice.
I will use Visual Studio Code editor for this demonstration. |
[Editor] Type:
fn main() { println!("Hello World"); } |
In the code editor, type the code as shown. |
[Editor] Highlight:
fn main(){ } |
This is our main function. |
[Editor] Highlight: fn | The keyword fn is used as a syntax to create a function in Rust. |
[Editor] Highlight: main() | main indicated the name of the function.
The Rust execution starts from the main function. |
[Editor] Highlight:
{ } |
The code written in between the open and closed curly braces would be the function body. |
[Editor] Highlight print! | Print!() is the print function in Rust. |
[Editor] Highlight
Hello World |
Here we have Hello World in double quotes as a parameter in the function call. |
[Editor] Highlight
print!(“Hello World”) |
So, when we run the program, Hello World gets printed. |
Press Ctrl + S | Let us save the file by pressing Ctrl + S keys together. |
Point to Save As dialog box | Save dialog box opens. |
Select Desktop on the left side | Select Desktop location. |
Point to Name >> type "hello-world.rs" | In the Name field, type the name of the file as hello-world.rs |
Highlight .rs | The extension .rs states that this is a Rust code file. |
Under Desktop >> Create MyRustProject folder | And then create a folder named MyRustProject. |
Point to MyRustProject | From now on, I will be saving my Rust files in this folder. |
Click on Save button. | Then click on the Save button on the top right corner of the dialog box. |
We have created a Rust file and have written the Hello World program.
Now, it’s time to compile and run the file. | |
Switch to terminal | Switch back to the terminal. |
[Terminal] Type:
cd Desktop/MyRustProject [Enter] |
Using cd command go to the location where the Rust file is saved.
In my case, it is MyRustProject on the Desktop. |
[Terminal] Type:
rustc hello-world.rs [Enter] |
To compile, type rustc space filename with extension .rs
In my case it is hello-world.rs |
[Terminal] Type:
./hello-world [Enter] |
The compilation is done without any error.
Now, to run type the dot slash filename and press Enter. In my case it is ./hello-world |
[Terminal] Highlight:
Hello World |
Hello world text gets printed. |
Slide: Common Errors
sudo apt install build-essential |
|
Only narration | We have successfully installed Rust and executed the Hello World program.
With this we have come to the end of this tutorial. Let’s summarize. |
Slide: Summary | In this tutorial, we have learnt
|
Slide: Assignment | As an assignment,
|
Slide: About Spoken Tutorial Project |
|
Slide: Spoken tutorial workshops |
|
Slide:Answers for THIS Spoken Tutorial |
|
Slide: Forum for specific Questions |
|
Slide: Acknowledgement | Spoken Tutorial Project is funded by Ministry of Education, Government of India |
Slide: Thanks | This is Jayesh signing off. Thank you for joining |