もくじ
MacBookを買い替えたので新たにインストールします。
公式サイト
コマンド
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Passwordを聞かれるので端末のパスワードを入力してReturnを押します。
すると待ってればインストールされます。
↓このへんが少し長かった・・!5−10分ほど。待ちます。
Downloaded Command Line Tools for Xcode Installing Command Line Tools for Xcode
上記の後もまだ続きます。
エラー
fatal: cannot force update the branch 'master' checked out at '/opt/homebrew'
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:XXXXX
########################################################################################### 100.0%
==> Pouring portable-ruby-3.1.4.arm64_big_sur.bottle.tar.gz
Warning: /opt/homebrew/bin is not in your PATH.
  Instructions on how to configure your shell for Homebrew
  can be found in the 'Next steps' section below.
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/{ユーザ名}/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh
おや。エラーが。
Installation successful
(略)
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/{ユーザ名}/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
これを見る限り、インストールは成功したようですがパスが通ってないようですね。
$ brew -v zsh: command not found: brew
バージョン確認も想定通り失敗します。(パスが通ってないから)
パスを通す
$ (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/{ユーザ名}/.zprofile
↑これ先頭の(カッコも含めて実行してください。
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/{ユーザ名}/.zprofile
zsh: parse error near `)'
含まないと、構文エラーになります( ̄∇ ̄)
実行してもうんともすんとも言いませんが、メッセージの通りに次も実行します。
$ eval "$(/opt/homebrew/bin/brew shellenv)"
また音沙汰はありませんが、これで完了しています。
確認
$ brew -v Homebrew 4.2.7
バージョンを確認できたのでインストールとパス通し、完了です!
正常にインストールできました。