LoginSignup
11
13

More than 3 years have passed since last update.

Ubuntu 20.04 LTS に Rustを新規インストール

Last updated at Posted at 2020-08-09

Ubuntu 20.04 LTS に Rustをインストール

クリーンインストールしたUbuntu20.04 LTSに Rustコンパイラをインストールする。
Ubuntuは最小インストールで入れたので、普通にやっても色々足りなかったので備忘録。

Rustを持ってくるのに必要。普通は普通に入っている。

$ sudo apt install curl

Rusu の build に必要。普通は普通に入っている。

$ sudo apt-get install gcc

Rustのインストール

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

PATHを反映させる。一回ログアウトしても良い。再起動でもいい。*1

$ source ~/.profile

バージョンの確認

$ rustup -V
rustup 1.22.1 (b01adbbc3 2020-07-08)

Hello World してみる

$ mkdir rust_test
$ cd rust_test
$ cargo new hello_rust
  Created binary (application) `hello_rust` package
$ cd hello_rust
$ cargo build
   Compiling hello_rust v0.1.0 (/home/ayu/rust_test/hello_rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
$ target/debug/hello_rust
Hello, world!
$

大丈夫なようです。

*1)Rustの環境変数だけを反映させるなら

$ source $HOME/.cargo/env

の方がいいようですが、かえって面倒くさいので、特に問題なさそうなら.profile一括反映の方が楽かも。

11
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
13