본문 바로가기
Programming/Rust

러스트(Rust) 설치하기

by 드로니뚜벅이 2022. 12. 6.

Rust를 설치하는 방법은 rustup를 다운로드해서 설치하거나 운영체제별 패키지 매니저를 통해 설치하는 방법 혹은 소스를 다운로드 받아 설치하는 방법이 있습니다.

rust-lang.org에서는 첫번째 방법을 추천하고 있습니다.

Rustup 설치하기

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
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/ttagiya/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  /home/ttagiya/.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/ttagiya/.cargo/bin

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

  /home/ttagiya/.profile
  /home/ttagiya/.bashrc
  /home/ttagiya/.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 2023-12-07, rust version 1.74.1 (a28077b28 2023-12-04)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
 56.2 MiB /  56.2 MiB (100 %)  31.0 MiB/s in  1s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 18.8 MiB /  18.8 MiB (100 %)  12.2 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
 30.0 MiB /  30.0 MiB (100 %)  15.6 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 56.2 MiB /  56.2 MiB (100 %)  17.9 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.74.1 (a28077b28 2023-12-04)


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).

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

$

이 컨맨드는 스크립트를 다운로드하고 rustup 도구의 설치를 시작하는데, 이 도구는 가장 최신의 러스트 안정화 버전을 설치해 줍니다.

설치 후 러스트를 사용하시기 위해서는 설치한 현재 쉘(shell)을 종료하고 다시 시작하셔야 합니다.

정상적으로 설치가 되었는지 확인해 보면 아래와 같이 최신 버전이 설치되었네요.

$ rustc --version
rustc 1.74.1 (a28077b28 2023-12-04)

$

 

러스트 언어로 프로그래밍하기 위해서는 링커가 필요합니다. 리눅스에 GCC가 설치되어 있지 않다면 아래 명령어로 관련 패키지를 설치해 줍니다.

$ sudo apt update
$ sudo apt install build-essential

 

Rust 문서 보기

$ rustup doc

 

Rust 업데이트하기

$ rustup update

 

Rust 제거하기

$ rustup self uninstall


Thanks for hacking in Rust!

This will uninstall all Rust toolchains and data, and remove
$HOME/.cargo/bin from your PATH environment variable.

Continue? (y/N) y

info: removing rustup home
info: removing cargo home
info: removing rustup binaries
info: rustup is uninstalled

$

 

'Programming > Rust' 카테고리의 다른 글

러스트(Rust) 관련 기사 (ZDNET Korea)  (0) 2022.12.04
Visual Studio Code - Rust Plugin(Extensions)  (0) 2022.11.05
The Rust Programming Language  (0) 2022.11.01