hene

hene.dev

Rust の勉強をはじめたい

Rust の勉強をはじめたい

Rust の勉強をはじめたいということで、インストールしてみました。

インストール

ref: はじめる

Mac を使っているので、下記実行してインストール。

$ curl https://sh.rustup.rs -sSf | 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.

It will add the cargo, rustc, rustup and other commands to
Cargo's bin directory, located at:

  /Users/username/.cargo/bin

This can be modified with the CARGO_HOME environment variable.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /Users/username/.rustup

This can be modified with the RUSTUP_HOME environment variable.

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

  /Users/username/.profile
/Users/username/.zprofile

  /Users/username/.bash_profile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-apple-darwin
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2019-09-26, rust version 1.38.0 (625451e37 2019-09-23)
info: downloading component 'cargo'
  3.7 MiB /   3.7 MiB (100 %)   1.3 MiB/s in  2s ETA:  0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 11.7 MiB /  11.7 MiB (100 %) 835.2 KiB/s in 12s ETA:  0s
info: downloading component 'rust-std'
170.9 MiB / 170.9 MiB (100 %) 672.0 KiB/s in  3m 11s ETA:  0s
info: downloading component 'rustc'
 60.4 MiB /  60.4 MiB (100 %)   1.2 MiB/s in  1m 22s ETA:  0s
info: downloading component 'rustfmt'
  1.9 MiB /   1.9 MiB (100 %)   1.3 MiB/s in  1s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 11.7 MiB /  11.7 MiB (100 %)   2.1 MiB/s in  4s ETA:  0s
info: installing component 'rust-std'
170.9 MiB / 170.9 MiB (100 %)  20.1 MiB/s in  9s ETA:  0s
info: installing component 'rustc'
 60.4 MiB /  60.4 MiB (100 %)   9.5 MiB/s in  6s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable'

  stable installed - rustc 1.38.0 (625451e37 2019-09-23)

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

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

確認

バージョンを確認して、インストールされているか確認してみます。

$ rustc --version
zsh: command not found: rustc

パスが通ってなかったので、通します。

$ source $HOME/.cargo/env

インストールされていました。

$ rustc --version
rustc 1.38.0 (625451e37 2019-09-23)

今後

これから、 Rust の勉強をはじめていきます。

参考

関連記事