0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

🚀 Homebrewのインストール

Last updated at Posted at 2025-01-26

Homebrewってなに?

Homebrew(ホームブリュー)は、Mac専用のパッケージマネージャーです🍺

簡単に言うとアプリやツールをめっちゃ簡単にインストールできる便利ツール🎉

🛠️ インストール手順

👩🏻‍💻 コマンドの実行

上記のページに公開されている以下のインストールコマンドをコピーしてターミナルに貼り付けます

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
🔍 コマンドの解説

/bin/bash -c

Bashを指定してシェルを実行。 -c は、「指定した文字列をコマンドとして実行する」というオプション。

curl -fsSL

curl は、指定されたURLからデータをダウンロードするコマンド。
オプションの意味はこちら。
• -f(fail):HTTPエラー(例: 404 Not Found)のときにエラーを出します。
• -s(silent):進捗バーやエラーメッセージを表示しません。
• -S(show error):エラーが発生した場合、その内容を表示します。
• -L(location):リダイレクトがあった場合に追従します。

https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh

HomebrewのインストールスクリプトのURL。

$()

ダウンロードしたスクリプトを実行する

🔑 パスワードを入力

以下のメッセージが出力されたら、パスワードを入力してEnterを押してください

==> Checking for `sudo` access (which may request your password)...
Password:
⏎ エンターを押す

以下のメッセージが出てきたエンターを押す

Press RETURN/ENTER to continue or any other key to abort:

🎉 インストールの完了

以下のようなログが出力されたら成功です

==> Installation successful!

.....

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

🛠️ PATHの設定

ログの最後で案内されていたPATHの設定を行います。

📝 空行を追加
echo >> /Users/username/.zprofile

~/.zprofile がなければ作成してファイルの存在を保証し、末尾に空行を追加することでHomebrewの設定内容をその他の設定と切り離し、整理された状態を保つことが目的です。

🔧 環境変数の設定をファイルに追加
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/username/.zprofile

eval "$(/opt/homebrew/bin/brew shellenv)" という設定を ~/.zprofile ファイルに追記します。

Homebrewを使用する際に必要なパス(PATH)や環境変数が毎回自動的に適用されるようになります。

🚀 設定を即時反映
eval "$(/opt/homebrew/bin/brew shellenv)"

先ほど設定した内容が現在のターミナルセッションに即時反映されます、すぐに使用できる状態になります。

✅ インストールの確認

インストールが完了したら、以下のコマンドで正しくインストールされたか確認できます🎉

brew --version

Homebrew 4.4.17 のようにバージョン番号が表示されれば、インストール成功です✨

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?