Summary
TimeMachineでx86版からARM版に移行したときにハマった点をメモ。アクティビティモニターを右クリックしてアーキテクチャを表示しておくと良い。
ARM版 Homebrewのインストール
ARM版 Homebrewは /opt/homebrew にインストールするのが推奨されている。$ cd /opt
$ sudo mkdir homebrew
$ sudo chown $(whoami):admin homebrew
$ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
$ /opt/homebrew/bin/brew update
ハマったところ1: uname
uname でアーキテクチャを確認できていなかったHomebrewでx86版のcoreutilsをインストールしていたため。
$ uname -m
x86_64
$ which uname
/usr/local/opt/coreutils/libexec/gnubin/uname
$ /usr/bin/uname -m
arm64
ハマったところ2: x86版のRuby gems
/Library/Ruby/Gems/2.6.0/gems に x86版のRuby lib/*.bundle ファイルが残ってたため, it is not a compatible arch TimeMachine で移行するときにありがちっぽい。
$ /opt/homebrew/bin/brew
Traceback (most recent call last):
22: from /opt/homebrew/Library/Homebrew/brew.rb:31:in `<main>'
21: from /opt/homebrew/Library/Homebrew/brew.rb:31:in `require_relative'
20: from /opt/homebrew/Library/Homebrew/global.rb:23:in `<top (required)>'
19: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
18: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
17: from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.0/lib/active_support/core_ext/numeric/time.rb:3:in `<top (required)>'
16: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
15: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
14: from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.0/lib/active_support/duration.rb:3:in `<top (required)>'
13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
11: from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.0/lib/active_support/core_ext/array/conversions.rb:3:in `<top (required)>'
10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
8: from /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.0/lib/active_support/xml_mini.rb:3:in `<top (required)>'
7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/time.rb:3:in `<top (required)>'
4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2: from /Library/Ruby/Gems/2.6.0/gems/date-3.0.0/lib/date.rb:4:in `<top (required)>'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/date-3.0.0/lib/date_core.bundle, 0x0009): could not use '/Library/Ruby/Gems/2.6.0/gems/date-3.0.0/lib/date_core.bundle' because it is not a compatible arch - /Library/Ruby/Gems/2.6.0/gems/date-3.0.0/lib/date_core.bundle (LoadError)
x86版のRuby gemsを退避
$ cd /Library/Ruby/Gems/2.6.0
$ sudo mv gems gems-bak
$ /opt/homebrew/bin/brew list
zshenvでpathを通しておく
if [[ "$OSTYPE" == "darwin"* ]] && [[ "$CPUTYPE" == "arm64" ]]; then
path=(
/opt/homebrew/bin(N-/)
/opt/homebrew/opt/coreutils/libexec/gnubin(N-/)
/opt/homebrew/opt/binutils/libexec/gnubin(N-/)
/opt/homebrew/opt/findutils/libexec/gnubin(N-/)
/opt/homebrew/opt/diffutils/libexec/gnubin(N-/)
/opt/homebrew/opt/grep/libexec/gnubin(N-/)
/opt/homebrew/opt/gnu-tar/libexec/gnubin(N-/)
/opt/homebrew/opt/gnu-sed/libexec/gnubin(N-/)
/opt/homebrew/opt/gawk/libexec/gnubin(N-/)
/opt/homebrew/opt/openssl@1.1/bin(N-/)
$path
)
fi
if [[ "$OSTYPE" == "darwin"* ]] && [[ "$CPUTYPE" == "arm64" ]]; then
manpath=(
/opt/homebrew/share/man(N-/)
/opt/homebrew/opt/coreutils/libexec/gnuman(N-/)
/opt/homebrew/opt/binutils/libexec/gnuman(N-/)
/opt/homebrew/opt/findutils/libexec/gnuman(N-/)
/opt/homebrew/opt/diffutils/libexec/gnuman(N-/)
/opt/homebrew/opt/grep/libexec/gnuman(N-/)
/opt/homebrew/opt/gnu-tar/libexec/gnuman(N-/)
/opt/homebrew/opt/gnu-sed/libexec/gnuman(N-/)
/opt/homebrew/opt/gawk/libexec/gnuman(N-/)
/opt/homebrew/opt/openssl@1.1/man(N-/)
$manpath
)
fi
ARM版のパッケージをインストールし、archを確認
$ /opt/homebrwe/bin/brew install zsh
$ lipo -archs /opt/homebrew/bin/zsh
arm64
Reference
Homebrew Documentationhttps://docs.brew.sh/Installation