Rust Installation in Ubuntu 13.10

I have been trying to install Rust, the programming language in the past by source code compilation but the whole process was pain in the arse due to the time taken (like forever) just to compile and install all the components. Luckily these days, you can just install it from PPA, as shown below.

Install the PPA and update your local packages.
$ sudo apt-add-repository ppa:hansjorg/rust
$ sudo apt-get update
Search for all available Rust version.

$ apt-cache search ^rust-*
rust-0.7 - Rust compiler and tools
rust-nightly - Rust compiler and tools
rust-0.8 - Rust compiler and tools
rust-0.9 - Rust compiler and tools

Install the most recent stable version.
$ sudo apt-get install rust-0.9
$ rustc --version
rustc 0.9
host: x86_64-unknown-linux-gnu

If you've been following "This Week in Rust" newsletter, better for you to install the latest greatest nightly version to test out certain feature.
$ sudo apt-get install rust-nightly
$ rustc --version
rustc 0.10-pre
host: x86_64-unknown-linux-gnu

As you can have multiple versions installed side-by-side, to switch between these versions, just run this command.
$ sudo update-alternatives --config rustc
There is 1 choice for the alternative rustc (providing /usr/bin/rustc).

  Selection    Path                              Priority   Status
  0            /usr/lib/rust/rust-0.9/bin/rustc   90        auto mode
* 1            /usr/lib/rust/rust-0.9/bin/rustc   90        manual mode

Press enter to keep the current choice[*], or type selection number: 1

Test the sample hello program. Type this code below and save as
fn main() {

Compile and run it.
$ rustc 
$ ls
$ ./hello 

No comments:

Post a Comment