0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

M1 MacBook Air に Homebrew をインストール

Last updated at Posted at 2021-03-02

概要

M1 MacBook Air を購入して約 1 週間。
LINE や Chorme など、普段使いとしては(すごーく丁寧に使いながら、)良い感じになってきた所、後輩に「Docker とか入れてないんですか?」と煽られた為、開発環境の構築。
最終的には AWS とか連携して iPadOS アプリを何か作りたい。

時間制限も無いのでドキュメントもしっかり読んで(当たり前)行きたいです。
Google 翻訳 様、DeepL 様は多めに使っています。

参考 URL :

[Homebrew - macOS(またはLinux)用パッケージマネージャー]

さらに詳しいドキュメント
[docs.brew.sh]

[Homebrew Documentation]

Installation

[ - Installation]

実行コマンド

% mkdir /opt/homebrew
mkdir: /opt/homebrew: Permission denied

いきなり躓きました。

[M1 Mac買ったので行ったセットアップを書いていく]
[M1 macにhomebrewをいれる - インストール方法]

を参考にさせて頂きました。

% sudo mkdir /opt/homebrew
Password:
% sudo chown -R $(whoami) /opt/homebrew
% curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /opt/homebrew
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128  100   128    0     0     90      0  0:00:01  0:00:01 --:--:--    90
100 2307k  100 2307k    0     0   567k      0  0:00:04  0:00:04 --:--:-- 1086k

[ファイルの所有者を現在のユーザーに変更する]

なるほどなるほど。

% touch ~/.zshrc
% echo 'export PATH=$PATH:/opt/homebrew/bin' >> ~/.zshrc
% source ~/.zshrc
% which brew
/opt/homebrew/bin/brew
% brew --version
Homebrew >=2.5.0 (shallow or no git repository)
Homebrew/homebrew-core N/A
% brew doctor
==> Tapping homebrew/core
Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 58, done.
remote: Counting objects: 100% (58/58), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 918952 (delta 32), reused 37 (delta 20), pack-reused 918894
Receiving objects: 100% (918952/918952), 365.36 MiB | 1.34 MiB/s, done.
Resolving deltas: 100% (626945/626945), done.
Tapped 2 commands and 5487 formulae (5,803 files, 401.0MB).
Your system is ready to brew.
% 
% brew doctor
Your system is ready to brew.

うん、綺麗な感じです。

Homebrew 自体をアップデートしようと思うけど、実行するとバージョンがどうなるか確認したいのですが、わかりません。

検索途中で、

[Homebrew使い方まとめ]

とか拝見。
でも、cask とか指定方法が変わったものがある事は記憶しています。
この辺りはおいおい。

とりあえず、ドーン。

% brew update
Initialized empty Git repository in /opt/homebrew/.git/
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 175875 (delta 6), reused 0 (delta 0), pack-reused 175856
Receiving objects: 100% (175875/175875), 45.78 MiB | 947.00 KiB/s, done.
Resolving deltas: 100% (130528/130528), done.
From https://github.com/Homebrew/brew
 * [new branch]      dependabot/bundler/Library/Homebrew/codecov-0.5.0 -> origin/dependabot/bundler/Library/Homebrew/codecov-0.5.0
 * [new branch]      dependabot/bundler/Library/Homebrew/rubocop-1.11.0 -> origin/dependabot/bundler/Library/Homebrew/rubocop-1.11.0
 * [new branch]      dependabot/bundler/Library/Homebrew/rubocop-performance-1.10.1 -> origin/dependabot/bundler/Library/Homebrew/rubocop-performance-1.10.1
 * [new branch]      dependabot/bundler/Library/Homebrew/sorbet-0.5.6287 -> origin/dependabot/bundler/Library/Homebrew/sorbet-0.5.6287
 * [new branch]      master     -> origin/master
 * [new tag]         0.1        -> 0.1
 * [new tag]         0.2        -> 0.2
 * [new tag]         0.3        -> 0.3
 * [new tag]         0.4        -> 0.4
 * [new tag]         0.5        -> 0.5
 * [new tag]         0.6        -> 0.6
 * [new tag]         0.7        -> 0.7
 * [new tag]         0.7.1      -> 0.7.1
 * [new tag]         0.8        -> 0.8
 * [new tag]         0.8.1      -> 0.8.1
 * [new tag]         0.9        -> 0.9
 * [new tag]         0.9.1      -> 0.9.1
 * [new tag]         0.9.2      -> 0.9.2
 * [new tag]         0.9.3      -> 0.9.3
 * [new tag]         0.9.4      -> 0.9.4
 * [new tag]         0.9.5      -> 0.9.5
 * [new tag]         0.9.8      -> 0.9.8
 * [new tag]         0.9.9      -> 0.9.9
 * [new tag]         1.0.0      -> 1.0.0
 * [new tag]         1.0.1      -> 1.0.1
 * [new tag]         1.0.2      -> 1.0.2
 * [new tag]         1.0.3      -> 1.0.3
 * [new tag]         1.0.4      -> 1.0.4
 * [new tag]         1.0.5      -> 1.0.5
 * [new tag]         1.0.6      -> 1.0.6
 * [new tag]         1.0.7      -> 1.0.7
 * [new tag]         1.0.8      -> 1.0.8
 * [new tag]         1.0.9      -> 1.0.9
 * [new tag]         1.1.0      -> 1.1.0
 * [new tag]         1.1.1      -> 1.1.1
 * [new tag]         1.1.10     -> 1.1.10
 * [new tag]         1.1.11     -> 1.1.11
 * [new tag]         1.1.12     -> 1.1.12
 * [new tag]         1.1.13     -> 1.1.13
 * [new tag]         1.1.2      -> 1.1.2
 * [new tag]         1.1.3      -> 1.1.3
 * [new tag]         1.1.4      -> 1.1.4
 * [new tag]         1.1.5      -> 1.1.5
 * [new tag]         1.1.6      -> 1.1.6
 * [new tag]         1.1.7      -> 1.1.7
 * [new tag]         1.1.8      -> 1.1.8
 * [new tag]         1.1.9      -> 1.1.9
 * [new tag]         1.2.0      -> 1.2.0
 * [new tag]         1.2.1      -> 1.2.1
 * [new tag]         1.2.2      -> 1.2.2
 * [new tag]         1.2.3      -> 1.2.3
 * [new tag]         1.2.4      -> 1.2.4
 * [new tag]         1.2.5      -> 1.2.5
 * [new tag]         1.2.6      -> 1.2.6
 * [new tag]         1.3.0      -> 1.3.0
 * [new tag]         1.3.1      -> 1.3.1
 * [new tag]         1.3.2      -> 1.3.2
 * [new tag]         1.3.3      -> 1.3.3
 * [new tag]         1.3.4      -> 1.3.4
 * [new tag]         1.3.5      -> 1.3.5
 * [new tag]         1.3.6      -> 1.3.6
 * [new tag]         1.3.7      -> 1.3.7
 * [new tag]         1.3.8      -> 1.3.8
 * [new tag]         1.3.9      -> 1.3.9
 * [new tag]         1.4.0      -> 1.4.0
 * [new tag]         1.4.1      -> 1.4.1
 * [new tag]         1.4.2      -> 1.4.2
 * [new tag]         1.4.3      -> 1.4.3
 * [new tag]         1.5.0      -> 1.5.0
 * [new tag]         1.5.1      -> 1.5.1
 * [new tag]         1.5.10     -> 1.5.10
 * [new tag]         1.5.11     -> 1.5.11
 * [new tag]         1.5.12     -> 1.5.12
 * [new tag]         1.5.13     -> 1.5.13
 * [new tag]         1.5.14     -> 1.5.14
 * [new tag]         1.5.2      -> 1.5.2
 * [new tag]         1.5.3      -> 1.5.3
 * [new tag]         1.5.4      -> 1.5.4
 * [new tag]         1.5.5      -> 1.5.5
 * [new tag]         1.5.6      -> 1.5.6
 * [new tag]         1.5.7      -> 1.5.7
 * [new tag]         1.5.8      -> 1.5.8
 * [new tag]         1.5.9      -> 1.5.9
 * [new tag]         1.6.0      -> 1.6.0
 * [new tag]         1.6.1      -> 1.6.1
 * [new tag]         1.6.10     -> 1.6.10
 * [new tag]         1.6.11     -> 1.6.11
 * [new tag]         1.6.12     -> 1.6.12
 * [new tag]         1.6.13     -> 1.6.13
 * [new tag]         1.6.14     -> 1.6.14
 * [new tag]         1.6.15     -> 1.6.15
 * [new tag]         1.6.16     -> 1.6.16
 * [new tag]         1.6.17     -> 1.6.17
 * [new tag]         1.6.2      -> 1.6.2
 * [new tag]         1.6.3      -> 1.6.3
 * [new tag]         1.6.4      -> 1.6.4
 * [new tag]         1.6.5      -> 1.6.5
 * [new tag]         1.6.6      -> 1.6.6
 * [new tag]         1.6.7      -> 1.6.7
 * [new tag]         1.6.8      -> 1.6.8
 * [new tag]         1.6.9      -> 1.6.9
 * [new tag]         1.7.0      -> 1.7.0
 * [new tag]         1.7.1      -> 1.7.1
 * [new tag]         1.7.2      -> 1.7.2
 * [new tag]         1.7.3      -> 1.7.3
 * [new tag]         1.7.4      -> 1.7.4
 * [new tag]         1.7.5      -> 1.7.5
 * [new tag]         1.7.6      -> 1.7.6
 * [new tag]         1.7.7      -> 1.7.7
 * [new tag]         1.8.0      -> 1.8.0
 * [new tag]         1.8.1      -> 1.8.1
 * [new tag]         1.8.2      -> 1.8.2
 * [new tag]         1.8.3      -> 1.8.3
 * [new tag]         1.8.4      -> 1.8.4
 * [new tag]         1.8.5      -> 1.8.5
 * [new tag]         1.8.6      -> 1.8.6
 * [new tag]         1.9.0      -> 1.9.0
 * [new tag]         1.9.1      -> 1.9.1
 * [new tag]         1.9.2      -> 1.9.2
 * [new tag]         1.9.3      -> 1.9.3
 * [new tag]         2.0.0      -> 2.0.0
 * [new tag]         2.0.1      -> 2.0.1
 * [new tag]         2.0.2      -> 2.0.2
 * [new tag]         2.0.3      -> 2.0.3
 * [new tag]         2.0.4      -> 2.0.4
 * [new tag]         2.0.5      -> 2.0.5
 * [new tag]         2.0.6      -> 2.0.6
 * [new tag]         2.1.0      -> 2.1.0
 * [new tag]         2.1.1      -> 2.1.1
 * [new tag]         2.1.10     -> 2.1.10
 * [new tag]         2.1.11     -> 2.1.11
 * [new tag]         2.1.12     -> 2.1.12
 * [new tag]         2.1.13     -> 2.1.13
 * [new tag]         2.1.14     -> 2.1.14
 * [new tag]         2.1.15     -> 2.1.15
 * [new tag]         2.1.16     -> 2.1.16
 * [new tag]         2.1.2      -> 2.1.2
 * [new tag]         2.1.3      -> 2.1.3
 * [new tag]         2.1.4      -> 2.1.4
 * [new tag]         2.1.5      -> 2.1.5
 * [new tag]         2.1.6      -> 2.1.6
 * [new tag]         2.1.7      -> 2.1.7
 * [new tag]         2.1.8      -> 2.1.8
 * [new tag]         2.1.9      -> 2.1.9
 * [new tag]         2.2.0      -> 2.2.0
 * [new tag]         2.2.1      -> 2.2.1
 * [new tag]         2.2.10     -> 2.2.10
 * [new tag]         2.2.11     -> 2.2.11
 * [new tag]         2.2.12     -> 2.2.12
 * [new tag]         2.2.13     -> 2.2.13
 * [new tag]         2.2.14     -> 2.2.14
 * [new tag]         2.2.15     -> 2.2.15
 * [new tag]         2.2.16     -> 2.2.16
 * [new tag]         2.2.17     -> 2.2.17
 * [new tag]         2.2.2      -> 2.2.2
 * [new tag]         2.2.3      -> 2.2.3
 * [new tag]         2.2.4      -> 2.2.4
 * [new tag]         2.2.5      -> 2.2.5
 * [new tag]         2.2.6      -> 2.2.6
 * [new tag]         2.2.7      -> 2.2.7
 * [new tag]         2.2.8      -> 2.2.8
 * [new tag]         2.2.9      -> 2.2.9
 * [new tag]         2.3.0      -> 2.3.0
 * [new tag]         2.4.0      -> 2.4.0
 * [new tag]         2.4.1      -> 2.4.1
 * [new tag]         2.4.10     -> 2.4.10
 * [new tag]         2.4.11     -> 2.4.11
 * [new tag]         2.4.12     -> 2.4.12
 * [new tag]         2.4.13     -> 2.4.13
 * [new tag]         2.4.14     -> 2.4.14
 * [new tag]         2.4.15     -> 2.4.15
 * [new tag]         2.4.16     -> 2.4.16
 * [new tag]         2.4.2      -> 2.4.2
 * [new tag]         2.4.3      -> 2.4.3
 * [new tag]         2.4.4      -> 2.4.4
 * [new tag]         2.4.5      -> 2.4.5
 * [new tag]         2.4.6      -> 2.4.6
 * [new tag]         2.4.7      -> 2.4.7
 * [new tag]         2.4.8      -> 2.4.8
 * [new tag]         2.4.9      -> 2.4.9
 * [new tag]         2.5.0      -> 2.5.0
 * [new tag]         2.5.1      -> 2.5.1
 * [new tag]         2.5.10     -> 2.5.10
 * [new tag]         2.5.11     -> 2.5.11
 * [new tag]         2.5.12     -> 2.5.12
 * [new tag]         2.5.2      -> 2.5.2
 * [new tag]         2.5.3      -> 2.5.3
 * [new tag]         2.5.4      -> 2.5.4
 * [new tag]         2.5.5      -> 2.5.5
 * [new tag]         2.5.6      -> 2.5.6
 * [new tag]         2.5.7      -> 2.5.7
 * [new tag]         2.5.8      -> 2.5.8
 * [new tag]         2.5.9      -> 2.5.9
 * [new tag]         2.6.0      -> 2.6.0
 * [new tag]         2.6.1      -> 2.6.1
 * [new tag]         2.6.2      -> 2.6.2
 * [new tag]         2.7.0      -> 2.7.0
 * [new tag]         2.7.1      -> 2.7.1
 * [new tag]         2.7.2      -> 2.7.2
 * [new tag]         2.7.3      -> 2.7.3
 * [new tag]         2.7.4      -> 2.7.4
 * [new tag]         2.7.5      -> 2.7.5
 * [new tag]         2.7.6      -> 2.7.6
 * [new tag]         2.7.7      -> 2.7.7
 * [new tag]         3.0.0      -> 3.0.0
 * [new tag]         3.0.1      -> 3.0.1
 * [new tag]         3.0.2      -> 3.0.2
 * [new tag]         3.0.3      -> 3.0.3
 * [new tag]         3.0.4      -> 3.0.4
HEAD is now at ee52b1917 Merge pull request #10763 from Homebrew/revert-10595-ruby-shims
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
Updated 1 tap (homebrew/core).
==> Updated Formulae
e2fsprogs

ぐわっ!(長い。)

% which brew
/opt/homebrew/bin/brew
% brew --version
Homebrew 3.0.4
Homebrew/homebrew-core (git revision c47834; last commit 2021-03-02)

うん、期待通りです。

% brew doctor   
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You have uncommitted modifications to Homebrew/brew.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  cd /opt/homebrew && git stash && git clean -d -f

Uncommitted files:
  ?? Library/Homebrew/shims/mac/super/gem
  ?? Library/Homebrew/shims/mac/super/rake
  ?? Library/Homebrew/shims/mac/super/ruby
  ?? Library/Homebrew/shims/utils.sh

警告が出ています。

[【git stash】コミットはせずに変更を退避したいとき]
[git clean]

ふむふむ。

粛々と実行します。

% cd /opt/homebrew
% pwd
/opt/homebrew
% git stash
No local changes to save
% git clean -d -f
Removing Library/Homebrew/shims/mac/super/gem
Removing Library/Homebrew/shims/mac/super/rake
Removing Library/Homebrew/shims/mac/super/ruby
Removing Library/Homebrew/shims/utils.sh
% brew doctor     
Your system is ready to brew.
% which brew
/opt/homebrew/bin/brew
% brew --version
Homebrew 3.0.4
Homebrew/homebrew-core (git revision c47834; last commit 2021-03-02)

よし!

[M1 MacへのHomebrewの導入]

今更ですが、「ARMアーキテクチャ環境」でターミナルを開いている事を確認します。

% uname -m
arm64

最後に arm 版の jq コマンドがインストールされるか確認します。

% brew install jq
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/oniguruma-6.9.6.arm64_big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/dc2264a1fd09eb555ff2591d212af8e9cb5071ca529104dd17746af6306
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/jq-1.6.arm64_big_sur.bottle.1.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/674b3ae41c399f1e8e44c271b0e6909babff9fcd2e04a2127d25e2407ea
######################################################################## 100.0%
==> Installing dependencies for jq: oniguruma
==> Installing jq dependency: oniguruma
==> Pouring oniguruma-6.9.6.arm64_big_sur.bottle.tar.gz
🍺  /opt/homebrew/Cellar/oniguruma/6.9.6: 16 files, 1.4MB
==> Installing jq
==> Pouring jq-1.6.arm64_big_sur.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/jq/1.6: 18 files, 1.2MB
% 
% file /opt/homebrew/bin/jq
/opt/homebrew/bin/jq: Mach-O 64-bit executable arm64
% 
% echo '{"mac":[{"id":1,"name":"intel"},{"id":2,"name":"arm"}]}' | jq .
{
  "mac": [
    {
      "id": 1,
      "name": "intel"
    },
    {
      "id": 2,
      "name": "arm"
    }
  ]
}

[【 file 】コマンド――ファイル形式を確認する]

理解しました。期待通りです。

念の為、再確認します。

% brew update
Updated 1 tap (homebrew/core).
==> New Formulae
pyside@2
==> Updated Formulae
audacious                     icemon                        opencsg                       qsoas
carla                         inspectrum                    pc6001vx                      qt
cgal                          jack                          poppler                       qtads
codequery                     kde-extra-cmake-modules       pushpin                       qtkeychain
color-code                    kde-karchive                  pyqt                          quazip
djview4                       kde-kdoctools                 pyside                        qwt
dspdfviewer                   kde-ki18n                     qbs                           qwtpolar
fceux                         kde-threadweaver              qca                           qxmpp
gammaray                      libgr                         qcachegrind                   treefrog
gdcm                          mgba                          qcli                          vtk@8.2
gnuplot                       mlt                           qjson                         xpdf
gnuradio                      mruby                         qmmp                          zurl
gpsbabel                      octave                        qscintilla2
==> Renamed Formulae
qt5 -> qt@5
% 
% brew update
Already up-to-date.
% brew doctor   
Your system is ready to brew.
% which brew    
/opt/homebrew/bin/brew
% brew --version
Homebrew 3.0.4
Homebrew/homebrew-core (git revision 26105; last commit 2021-03-02)

お付き合いありがとうございました。

以上

0
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?