Rust on macOS BIgSur

はじめに_

Rustのインストール_

Rust: はじめにに従い、インストールする。ターミナル上で以下を実行する。

% 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:

  /Users/gotoh/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /Users/gotoh/.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:

  /Users/gotoh/.cargo/bin

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

  /Users/gotoh/.profile
  /Users/gotoh/.bash_profile
  /Users/gotoh/.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-apple-darwin
     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-apple-darwin
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2021-05-10, rust version 1.52.1 (9bc8c42bb 2021-05-09)
info: downloading component 'cargo'
  4.3 MiB /   4.3 MiB (100 %)   2.8 MiB/s in  1s ETA:  0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 15.3 MiB /  15.3 MiB (100 %)   3.0 MiB/s in  5s ETA:  0s
info: downloading component 'rust-std'
 23.0 MiB /  23.0 MiB (100 %)   3.1 MiB/s in  7s ETA:  0s
info: downloading component 'rustc'
 58.6 MiB /  58.6 MiB (100 %)   4.5 MiB/s in 19s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 15.3 MiB /  15.3 MiB (100 %)   3.1 MiB/s in  4s ETA:  0s
info: installing component 'rust-std'
 23.0 MiB /  23.0 MiB (100 %)   8.9 MiB/s in  8s ETA:  0s
info: installing component 'rustc'
 58.6 MiB /  58.6 MiB (100 %)  11.3 MiB/s in  5s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-apple-darwin'

  stable-x86_64-apple-darwin installed - rustc 1.52.1 (9bc8c42bb 2021-05-09)


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

指示通りパスを反映させる。

% source $HOME/.cargo/env

% which rustc
/Users/gotoh/.cargo/bin/rustc

% rustc --version
rustc 1.52.1 (9bc8c42bb 2021-05-09)

動作確認_

% mkdir -p ~/Sandbox/Rust
% cd ~/Sandbox/Rust
% cargo new --bin prj_evid
     Created binary (application) `prj_evid` package
% cd prj_evid/

% ls -1F
Cargo.toml
src/

VSCodeのインストール_

macOS用をインストールし、以下の拡張機能をインストールする。

  • Rust
  • CodeLLDB