Rio Blog

世界のどこかでゆるく生きるITエンジニアのブログ

Macbook Pro M2にHomebrewとEmacsをインストールする

タイトルの通り、M2 VenturaにHomebrewとEmacsを入れてみた記録です。結論から言うと、オーソドックスな手順でインストールできたので、M2だから何か特別な設定などが必要になるということはありません。(*2023年11月末時点での情報です。)

環境

HomebrewとEmacsとは

初学者のために一応解説です。

Homebrew

macOS, Linuxのためのパッケージ管理ツールの一つです。開発において、何かしらのパッケージをインストールするために利用します。今回はEmacsというテキストエディタをインストールしたいので、まずはHomebrewを入れて、そのHomebrewを使ってEmacsを入れるという手順が必要なんですね。

Emacs

テキストエディタの一つです。開発していると、Wordやメモ帳、VSCodeではなく、Emacsを使いたい場面、使わざるを得ない場面というのがあります。Emacsではなく、Vimというテキストエディタも人気で、まあどちらを使うかは好みの問題です。

Homebrewのインストール

Homebrew — The Missing Package Manager for macOS (or Linux)

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

公式ページにコマンドが掲載されています。こいつをコピーして、ターミナルを開き、貼り付けてエンターキーを叩きます。途中でパスワードを聞かれるので、Macでご自身のアカウントにログインする際のパスワードを入力してください。

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!

とあるのでインストールは完了していますが、

Warning: /opt/homebrew/bin is not in your PATH. 

とあるのでパスが通っていないようですね。パスが通っていないということは、そこにあるプログラムがコマンドとして設定されていないということです。このままでは使えないので、Next steps: に書かれているコマンドを実行しましょう。

(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/*****/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"

こいつをそのままコピペして実行です。
(/*****/の部分はご自身のユーザー名になっているはずです。)

最後に確認です。

% brew -v
Homebrew 4.1.22

バージョンが表示されたので、無事にインストールできて、パスも通っていますね。

Emacsのインストール

Homebrewを使って、Emacsをインストールします。

% brew install emacs

これだけでOKです。

% emacs --version
GNU Emacs 29.1
Copyright (C) 2023 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

確認するとちゃんとバージョン情報が表示されました。

これでM2でEmacsを使えます。