Difference between revisions of "Rust/C2/Installation-of-Rust-on-Linux/English"
Nancyvarkey (Talk | contribs) |
|||
Line 24: | Line 24: | ||
Learning Objectives | Learning Objectives | ||
|| In this tutorial, we will learn: | || In this tutorial, we will learn: | ||
− | |||
− | |||
* How to install '''Rust'''. | * How to install '''Rust'''. | ||
* Create and execute a '''Rust''' file | * Create and execute a '''Rust''' file | ||
− | |||
− | |||
|- | |- | ||
|| Slide: System Specifications | || Slide: System Specifications | ||
|| This tutorial is recorded using: | || This tutorial is recorded using: | ||
− | |||
* '''Ubuntu Linux''' OS version 18.04 | * '''Ubuntu Linux''' OS version 18.04 | ||
* '''Rust''' version 1.47.0 | * '''Rust''' version 1.47.0 | ||
Line 48: | Line 43: | ||
* You should be familiar with basic '''Linux commands.''' | * You should be familiar with basic '''Linux commands.''' | ||
* If not, please go through the prerequisite '''Linux''' tutorials on this website. | * If not, please go through the prerequisite '''Linux''' tutorials on this website. | ||
− | |||
− | |||
|- | |- | ||
Line 57: | Line 50: | ||
* Pls download and extract the file. | * Pls download and extract the file. | ||
* Make a copy and then use it for practising. | * Make a copy and then use it for practising. | ||
− | |||
− | |||
|- | |- | ||
Line 101: | Line 92: | ||
− | So, we have to first | + | So, we have to first '''install curl''' if we haven’t done so earlier. |
Line 110: | Line 101: | ||
Enter admin password | Enter admin password | ||
− | || If prompted enter the '''admin password''' to proceed further. | + | || If '''prompted''', enter the '''admin password''' to proceed further. |
|- | |- | ||
Line 119: | Line 110: | ||
<nowiki>[Enter]</nowiki> | <nowiki>[Enter]</nowiki> | ||
− | || We have successfully | + | || We have successfully '''installed curl'''. |
− | Next let us download and | + | Next let us download and '''install Rust''' using '''Curl'''. |
Line 140: | Line 131: | ||
Cancel installation | Cancel installation | ||
− | || Once the '''package''' is downloaded, we will be prompted to choose one of the following options: | + | || Once the '''package''' is downloaded, we will be '''prompted''' to choose one of the following options: |
Line 176: | Line 167: | ||
|- | |- | ||
|| Press '''Ctrl+Alt+T '''keys | || Press '''Ctrl+Alt+T '''keys | ||
− | || Once you have restarted the computer, open the terminal again | + | || Once you have restarted the computer, open the '''terminal''' again. |
|- | |- | ||
Line 183: | Line 174: | ||
<nowiki>rustc --version [Enter]</nowiki> | <nowiki>rustc --version [Enter]</nowiki> | ||
− | || Now let us cross verify the '''Rust''' | + | || Now let us cross verify the '''Rust installation'''. |
Line 236: | Line 227: | ||
<nowiki>cargo [Enter]</nowiki> | <nowiki>cargo [Enter]</nowiki> | ||
− | || You can check whether '''cargo''' is installed or not using the '''cargo command''' in the '''terminal.''' | + | || You can check whether '''cargo''' is '''installed''' or not using the '''cargo command''' in the '''terminal.''' |
Line 245: | Line 236: | ||
cargo <nowiki>--version [Enter] </nowiki> | cargo <nowiki>--version [Enter] </nowiki> | ||
− | || This '''command''' shows the '''version''' of the '''cargo package manager''' | + | || This '''command''' shows the '''version''' of the '''cargo package manager installed''' in your machine. |
|- | |- | ||
|| Slide: Common Errors After Installation | || Slide: Common Errors After Installation | ||
− | || | + | || Common Errors After '''Installation''' |
* '''System restart''' is required after '''installing rust'''. | * '''System restart''' is required after '''installing rust'''. | ||
* If not, we could land with these errors | * If not, we could land with these errors | ||
Line 255: | Line 246: | ||
** '''Rustc''' | ** '''Rustc''' | ||
** '''Cargo - command not found''' | ** '''Cargo - command not found''' | ||
− | |||
− | |||
|- | |- | ||
|| Only narration | || Only narration | ||
− | || Next let us learn how to create and execute a '''Rust''' file. | + | || Next let us learn how to create and '''execute''' a '''Rust''' file. |
|- | |- | ||
Line 278: | Line 267: | ||
} | } | ||
− | || In the '''code''' | + | || In the '''code editor''', type the code as shown. |
|- | |- | ||
Line 290: | Line 279: | ||
|- | |- | ||
|| <nowiki>[Editor] </nowiki>Highlight: '''fn ''' | || <nowiki>[Editor] </nowiki>Highlight: '''fn ''' | ||
− | || The '''keyword | + | || The '''keyword fn''' is used as a '''syntax''' to create a '''function''' in '''Rust'''. |
|- | |- | ||
Line 315: | Line 304: | ||
'''Hello World''' | '''Hello World''' | ||
− | || Here we have | + | || Here we have '''Hello World''' in double quotes as a '''parameter''' in the '''function call'''. |
|- | |- | ||
Line 321: | Line 310: | ||
'''print!(“Hello World”)''' | '''print!(“Hello World”)''' | ||
− | || So, when we '''run''' the '''program''', ''' | + | || So, when we '''run''' the '''program''', '''Hello World''' gets printed. |
|- | |- | ||
Line 330: | Line 319: | ||
|| Point to Save As dialog box | || Point to Save As dialog box | ||
|| '''Save''' dialog box opens. | || '''Save''' dialog box opens. | ||
+ | |||
+ | |- | ||
+ | || Select '''Desktop''' on the left side | ||
+ | || Select '''Desktop''' location. | ||
|- | |- | ||
|| Point to Name >> type "hello-world.rs" | || Point to Name >> type "hello-world.rs" | ||
− | || In the '''Name''' field type the name of the file as '''hello-world.rs''' | + | || In the '''Name''' field, type the name of the file as '''hello-world.rs''' |
|- | |- | ||
Line 340: | Line 333: | ||
|- | |- | ||
− | || | + | || Under '''Desktop''' >> Create '''MyRustProject '''folder |
− | + | || And then create a folder named '''MyRustProject.''' | |
− | + | ||
− | Create '''MyRustProject '''folder | + | |
− | || | + | |
|- | |- | ||
Line 356: | Line 346: | ||
|- | |- | ||
|| | || | ||
− | || We have created a '''Rust file''' and have written the ''' | + | || We have created a '''Rust file''' and have written the '''Hello World program'''. |
Line 382: | Line 372: | ||
<nowiki>rustc hello-world.rs [Enter]</nowiki> | <nowiki>rustc hello-world.rs [Enter]</nowiki> | ||
− | || To '''compile''' type '''rustc | + | || To '''compile,''' type '''rustc space filename''' with extension '''.rs''' |
Line 414: | Line 404: | ||
* You could land up with this error while '''compiling - linker ‘cc’ not found. ''' | * You could land up with this error while '''compiling - linker ‘cc’ not found. ''' | ||
* It means you don’t have '''gcc''' in your machine. | * It means you don’t have '''gcc''' in your machine. | ||
− | * To resolve this, '''install''' the '''build | + | * To resolve this, '''install''' the '''build essentials''' with this '''command'''. |
− | + | ||
− | + | ||
|- | |- | ||
Line 423: | Line 411: | ||
− | || We have successfully | + | || We have successfully '''installed Rust''' and executed the '''Hello World program'''. |
− | With this we have come to the end of this tutorial | + | With this we have come to the end of this tutorial. Let’s summarize. |
|- | |- | ||
|| Slide: Summary | || Slide: Summary | ||
|| In this tutorial, we have learnt | || In this tutorial, we have learnt | ||
− | |||
* How to install '''Rust''' | * How to install '''Rust''' | ||
Line 437: | Line 424: | ||
* How to overcome common errors during '''installation''' | * How to overcome common errors during '''installation''' | ||
* Create and execute '''Rust file''' | * Create and execute '''Rust file''' | ||
− | |||
− | |||
|- | |- | ||
Line 448: | Line 433: | ||
* '''Compile '''and '''execute '''the file. | * '''Compile '''and '''execute '''the file. | ||
* Observe the output in the '''Terminal''' | * Observe the output in the '''Terminal''' | ||
− | |||
− | |||
|- | |- | ||
Line 456: | Line 439: | ||
* The video at the following link summarises the Spoken Tutorial project. | * The video at the following link summarises the Spoken Tutorial project. | ||
* Please download and watch it | * Please download and watch it | ||
− | |||
− | |||
|- | |- | ||
Line 464: | Line 445: | ||
* We conduct workshops using spoken tutorials and give certificates. | * We conduct workshops using spoken tutorials and give certificates. | ||
* For more details, please write to us. | * For more details, please write to us. | ||
− | |||
− | |||
|- | |- | ||
Line 476: | Line 455: | ||
* The Spoken Tutorial project team will ensure an answer | * The Spoken Tutorial project team will ensure an answer | ||
* You will have to register on this website to ask questions. | * You will have to register on this website to ask questions. | ||
− | |||
− | |||
|- | |- | ||
Line 486: | Line 463: | ||
* This will help reduce the clutter. | * This will help reduce the clutter. | ||
* With less clutter, we can use these discussions as instructional material. | * With less clutter, we can use these discussions as instructional material. | ||
− | |||
− | |||
|- | |- |
Revision as of 11:18, 21 January 2021
Title of the script: Installation of Rust on Linux OS
Author: Jayesh Katta Ramalingaiah
Domain Reviewer:
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.
|
Narration only | Let us begin. |
Press Ctrl+Alt+T keys | Open the terminal by pressing Ctrl,Alt and T keys simultaneously on the keyboard.
|
Only Narration | Here onwards, please remember to press the Enter key after typing each command. |
[Terminal]
sudo apt-get install curl -y [Enter] |
We will be installing Rust with the help of the curl command line tool.
|
[Terminal]
Enter admin password |
If prompted, enter the admin password to proceed further. |
[Terminal] Type:
[Enter] |
We have successfully installed curl.
|
Only Narration | The download may take some time depending upon your internet speed. |
[Terminal] Highlight one by one:
Customize installation Cancel installation |
Once the package is downloaded, we will be prompted to choose one of the following options:
|
[Terminal] Type: 1 [Enter] | To proceed with the default installation, type 1 and press Enter. |
[Terminal] Highlight:
Rust is installed now. Great! |
We have successfully installed Rust. |
[Terminal] Type:
|
Once the installation is done, we need to restart our computer.
|
Press Ctrl+Alt+T keys | Once you have restarted the computer, open the terminal again. |
[Terminal] Type:
|
Now let us cross verify the Rust installation.
|
[Terminal] Highlight:
rustc 1.47.0 |
This command shows the version of Rust installed in your computer.
|
[Terminal] Type:
rustup [Enter] |
Now type rustup on the terminal. |
Only narration | This shows us a list of Rust commands to run.
|
Slide: Rust Update
|
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.
|
Slide: cargo | cargo is a package manager to maintain a Rust project with dependencies. |
[Terminal] Type:
|
You can check whether cargo is installed or not using the cargo command in the terminal.
|
[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.
|
[Editor] Type:
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.
|
[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 at the top right corner of the dialog box. |
We have created a Rust file and have written the Hello World program.
| |
Switch to terminal | Switch back to the terminal. |
[Terminal] Type:
[Enter] |
Using cd command go to the location where the Rust file is saved.
|
[Terminal] Type:
|
To compile, type rustc space filename with extension .rs
|
[Terminal] Type:
|
The compilation is done without any error.
|
[Terminal] Highlight:
Hello World |
Hello world text gets printed. |
Slide: Common Errors
|
|
Only narration
|
We have successfully installed Rust and executed the Hello World program.
|
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 |