🍺
MacでHomebrewをインストールする方法 - 初心者向け完全ガイド
MacでHomebrewをインストールする方法 - 初心者向け完全ガイド
Homebrewの公式サイトからダウンロードして、Macにパッケージ管理環境を構築する手順を解説します。
完成イメージ
以下のような画面が表示されれば、Homebrewのインストールは完了です:
username@MacBook-Pro ~ % brew --version
Homebrew 4.2.15
Homebrew/homebrew-core (git revision 1234567890; last commit 2024-01-15)
Homebrew/homebrew-cask (git revision abcdef1234; last commit 2024-01-15)
必要なもの
- macOSがインストールされたMac
- インターネット接続
- ターミナルアプリ(標準でインストール済み)
- ウェブブラウザ(Safari、Chrome、Firefoxなど)
Step 1: Homebrew公式サイトにアクセス
まず、Homebrewの公式サイトにアクセスします。
- ウェブブラウザを開きます
- アドレスバーに
https://brew.sh/ja/
と入力してEnterキーを押します
▲ Homebrew公式サイトのトップページ
Step 2: インストールコマンドをコピー
サイトのトップページに表示されているインストールコマンドをコピーします。
-
サイト中央に表示されている以下のコマンドを見つけます:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
コマンドを選択して右クリックし、「コピー」を選択するか、
Cmd + C
でコピーします
▲ インストールコマンドのコピー
Step 3: ターミナルを開く
Finderからターミナルアプリを開きます。
- Finderを開きます
- 左側のサイドバーから「アプリケーション」をクリックします
- 「ユーティリティ」フォルダを開きます
- 「ターミナル」をダブルクリックして開きます
▲ ターミナルアプリの場所
Step 4: インストールコマンドを実行
コピーしたコマンドをターミナルに貼り付けて実行します。
- ターミナルが開いたら、右クリックして「ペースト」を選択するか、
Cmd + V
でコピーしたコマンドを貼り付けます - Enterキーを押してコマンドを実行します
実行すると以下のような画面が表示されます:
username@MacBook-Pro ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew/share/fish/vendor_completions/fish/brew.fish
==> The following new directories will be created:
/opt/homebrew/bin
/opt/homebrew/etc
/opt/homebrew/include
/opt/homebrew/lib
/opt/homebrew/sbin
/opt/homebrew/share
/opt/homebrew/var
/opt/homebrew/opt
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/etc/bash_completion.d
/opt/homebrew/share/fish
/opt/homebrew/share/fish/vendor_completions
/opt/homebrew/share/fish/vendor_completions/fish
==> The Xcode Command Line Tools will be installed.
Press RETURN/ENTER to continue or any other key to abort:
Step 5: パスワードを入力
インストール中に管理者パスワードの入力を求められます。
- パスワードの入力を求められたら、Macのログインパスワードを入力します
- パスワードは画面に表示されませんが、正常に入力されています
- 入力が完了したらEnterキーを押します
パスワード入力時の画面例:
==> /usr/bin/sudo /usr/sbin/chown -R username:staff /opt/homebrew
Password:
Step 6: インストール完了を確認
インストールが完了したら、Homebrewが正常に動作することを確認します。
-
インストールが完了したら、以下のコマンドを入力してEnterキーを押します:
brew --version
-
Homebrewのバージョンが表示されれば、インストールは成功です
バージョン確認の画面例:
username@MacBook-Pro ~ % brew --version
Homebrew 4.2.15
Homebrew/homebrew-core (git revision 1234567890; last commit 2024-01-15)
Homebrew/homebrew-cask (git revision abcdef1234; last commit 2024-01-15)
完成
これでHomebrewのインストールが完了しました!
インストール完了時の画面例:
==> 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 (or will be during this `brew` run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation: https://docs.brew.sh
username@MacBook-Pro ~ %
基本的な使い方
パッケージのインストール
brew install [パッケージ名]
パッケージの検索
brew search [キーワード]
インストール済みパッケージの確認
brew list
よくあるトラブルと対処法
1. 権限エラーが発生する場合
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/sbin
2. パスが通っていない場合
以下のコマンドでパスを追加します:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
3. インストールが途中で止まる場合
ネットワーク接続を確認し、再度インストールコマンドを実行してください。
4. サイトにアクセスできない場合
- インターネット接続を確認してください
- 別のブラウザで試してみてください
- ファイアウォールの設定を確認してください
まとめ
Homebrewの公式サイトからダウンロードしてMacにインストールする手順:
- 公式サイト(https://brew.sh/ja/)にアクセス
- インストールコマンドをコピー
- ターミナルを開く
- コピーしたコマンドを実行
- パスワードを入力
- インストール完了を確認
所要時間:約5分で完成します。
Homebrewがインストールされれば、様々な開発ツールやアプリケーションを簡単にインストールできるようになります。ぜひ活用してみてください!
Discussion