🦀

Rustをhomebrewでインストールする

2023/11/23に公開

公式ドキュメントにもインストール方法を記載されているが、homebrewでインストールしたい
https://www.rust-lang.org/ja/learn/get-started

前提

Homebrewはセットアップ済みであること
https://brew.sh/

Rust環境構築

1. rustupをインストール

Rustを使うためには、rustupという管理ツールが必要

$ brew install rustup-init

https://formulae.brew.sh/formula/rustup-init#default

2. インストールができたら、初期化

$ rustup-init

途中でインストールについて聞かれるので、1を入力する

$ rustup-init
...
...
   default host triple: aarch64-apple-darwin
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

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

3. 確認

以下コマンドが実行できればインストール成功

$ cargo --version
$ rustc

hellow worldしてみる

cargo newでHello, world!プロフジェクトが作成できる

$ cargo new hello-rust
$ cd hello-rust
$ cd hello-rust

   Compiling hello-rust v0.1.0 (/Users/minako/develop/hello-rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/hello-rust`
Hello, world!

できた🦀❤️

Discussion