コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Mac】Homebrew インストール直後に「command not found: brew」と表示される場合

はじめに

公式サイトに書かれているとおりに

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

上記のコマンドを実行して Homebrew インストールした後に

brew -v

Homebrew が使えるかどうか上記のコマンドで確認したところ

command not found: brew

上記のメッセージが出力されて使用できなかった

開発環境

  • MacBook Pro(16インチ、2021)
  • macOS Monterey バージョン 12.5.1
  • Homebrew 3.6.2

対応方法

Homebrew インストール完了時の出力を見ると

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.

「PATH が通っていないから Next steps を参考にしてね」という警告が出ていた

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/baba-s/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh

Next steps を見ると以下の 2 行のコマンドを実行するように書かれていた

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/baba-s/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

上記の 2 行のコマンドを実行した後に

brew -v

Homebrew が使えるかどうか上記のコマンドで確認したら

Homebrew 3.6.2

ちゃんとコマンドが認識されるようになった