問題
M1 macでHeroku CLIをインストールしようとすると
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
とエラーが出る。
おそらくhomebrewを、localディレクトリではなくてoptディレクトリにインストールするように言われている。
解決
まずはoptディレクトリの中を確認してみる。
$ ls /opt
homebrew
どうやら、optディレクトリにはhomebrewはインストールされていたので、パスが通っていないことが原因だと考えられる。
パスを通すために、~/.zshrcファイルに以下のコードを追加する。
~/.zshrc
export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH
最後に
$ brew tap heroku/brew && brew install heroku
を入力してインストールできました!
参考記事
もし、optディレクトリにhomebrewがインストールされていなかった場合は下記を参考にしてみてください!
https://www.teamxeppet.com/macbook-m1-homebrew-install/
最後に
初心者ながら、自分がわかる範囲で記事を書かせていただきました。
間違っているところがあれば、ご指摘いただきたいです。
皆さんの参考になれば、嬉しいです。