Open26

M1 Mac買ったので行ったセットアップを書いていく

ik-fibik-fib

M1チップのMacbook Airを買ったのでセットアップでやったことを備忘録的に書いていきます。

買った端末情報 (メモリを8->16GBに変更)

13インチMacBook Air - スペースグレイ

Hardware:
8コアCPU、8コアGPU、16コアNeural Engineを搭載したApple M1チップ
16GBユニファイドメモリ
512GB SSDストレージ
Touch ID
Thunderbolt / USB 4ポート x 2
感圧タッチトラックパッド
True Tone搭載Retinaディスプレイ
バックライトMagic Keyboard - 日本語(JIS)
アクセサリキット

他の方の有効そうな情報まとめ

ik-fibik-fib

Githubにあるdotfilesをcloneする

私の基本的な設定ファイルはGithubで公開しているのでまずはそれをclone→setupしていきます

https://github.com/ik11235/Dotfile

ターミナルからgit コマンドを呼び出したタイミングでXcode Command Line Tools のインストールが要求されるので、表示されたダイアログに従ってインストール

git clone https://github.com/ik11235/Dotfile.git ~/ghq/github.com/ik11235/Dotfile
~/ghq/github.com/ik11235/Dotfile/init.sh

この自作のinit.shではbrewのインストールも自動化してますが、M1には未対応だったので、そこはskip

ik-fibik-fib

homebrewのインストール

M1 Macでのhomebrewは 公式のドキュメント/opt/homebrew にインストールすることが推奨されています(Intel版との衝突を避けて共存できるようにするためらしい)。

なので、以下のようにして /opt/homebrew にインストールします。

sudo mkdir /opt/homebrew
sudo chown -R $(whoami) /opt/homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /opt/homebrew

homebrewへpathを通す

私のdotfileで使っている.zshrc では、既存のhomebrewへのPATHはすでに通していますが、今回は/opt/homebrew に追加したので、新たにPATHを通す必要があります。

.zshrc の適切な箇所に以下を追加して、PATHを追加します。

## M1 brew
export PATH="/opt/homebrew/bin:$PATH"

homebrew インストール完了の確認

PATHが通し終わったら、正常にbrewコマンドが実行されるか確認します。

特別理由はないのですが、私はdoctorコマンドで確認しました。

% brew doctor
==> Tapping homebrew/core
Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 93, done.
remote: Counting objects: 100% (93/93), done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 852816 (delta 58), reused 48 (delta 27), pack-reused 852723
Receiving objects: 100% (852816/852816), 337.79 MiB | 1.82 MiB/s, done.
Resolving deltas: 100% (575681/575681), done.
Tapped 2 commands and 5372 formulae (5,673 files, 370.7MB).
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 are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

M1対応がまだ仮だからか、サポートはまだしてませんと警告が出ましたが、インストール自体は完了しており、brewコマンドも動きました。

(個人的なdiff) zshrcにあるアプリケーション依存のコードをコメントアウトしておく

私の.zshrcの中にはdirenvのinit等特定のアプリケーションがあることが前提の部分があり、その部分でエラーになっていました。

その部分はこの後のアプリケーションのインストールで改善するはずなので、一旦コメントアウトしておきます。

(できるだけそういったコードは事前チェックをいれてエラーにならないようにしてるつもりでしたが、漏れてた)

diff --git a/DOT_LINK_TARGET/zsh.d/zshrc_global b/DOT_LINK_TARGET/zsh.d/zshrc_global
index 52c5568..71a437c 100644
--- a/DOT_LINK_TARGET/zsh.d/zshrc_global
+++ b/DOT_LINK_TARGET/zsh.d/zshrc_global
@@ -76,7 +76,7 @@ precmd () {
 RPROMPT="%1(v|%F{green}%1v%f|)[%d]"

 # direnv
-eval "$(direnv hook zsh)"
+#eval "$(direnv hook zsh)"

 export EDITOR="nano"

diff --git a/DOT_LINK_TARGET/zsh.d/zshrc_mac b/DOT_LINK_TARGET/zsh.d/zshrc_mac
index 22d056d..a0869a9 100644
--- a/DOT_LINK_TARGET/zsh.d/zshrc_mac
+++ b/DOT_LINK_TARGET/zsh.d/zshrc_mac
@@ -6,7 +6,7 @@ readonly local SCRIPT_DIR=$(
 source $SCRIPT_DIR/zshrc_mac_private

 # anyenv
-eval "$(anyenv init - --no-rehash)"
+#eval "$(anyenv init - --no-rehash)"

 ## gcloudでpython@3.8を使うように(3.9未対応問題対策)
 export CLOUDSDK_PYTHON="/usr/local/opt/python@3.8/bin/python3"
@@ -24,6 +24,8 @@ fi
 # brew
 export PATH="/usr/local/bin:$PATH"
 export PATH="/usr/local/sbin:$PATH"
+## M1 brew
+export PATH="/opt/homebrew/bin:$PATH"

 #coreutils path
 # export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
@@ -56,4 +58,4 @@ if [ -d "$HOME/Library/Android/sdk/platform-tools" ]; then
   export PATH="$HOME/Library/Android/sdk/platform-tools:$PATH"
 fi

-exec fish
+#exec fish
ik-fibik-fib

homebrew経由でアプリケーションをインストール

今まで私がhomebrewでインストールしていたアプリケーションはdumpを利用して、Brewfileにまとめています。

さらに、 最初のセットアップでdotfile.gitにおいてあるBrewfile~/.Brewfile からシンボリックリンクで参照されているので、以下のコマンドで一括インストール可能です。

brew bundle --global

ただ、やはりバイナリがなくソースからbuildしているのが多いようで(インストール中にプロセス確認したところ対象にhomebrew起因のmakeやclangが走っていた)、インストール時間がかなりかかっています。

インストールに失敗したアプリケーション一覧

Brewfile に含まれて、インストールに失敗したアプリケーションを以下に記載します。

インストールログ全体はgistに置いています。

  • osxfuse(rosetta2を要求)
  • direnv(ビルド中に要求してるgoのビルドで失敗)
  • ext4fuse(依存しているosxfuseのインストールに失敗しているため)
  • ffmpeg(ビルド中に要求してるopenjdkのインストールで失敗)
  • fzf(ビルド中に要求してるgoのビルドで失敗)
  • ghq(ビルド中に要求してるgoのビルドで失敗)
  • go(ビルド失敗)
  • graphviz(ビルド中にsvnを要求)
  • hub(ビルド中に要求してるgoのビルドで失敗)
  • imagemagick(ビルド中に要求してるdocbook-xsl--nsのインストールで失敗<network依存?>)
  • mas(インストールにXcode.app 10.2を要求)
  • openjdk(ダウンロードファイルのSHA256チェックでエラー)
  • peco(ビルド中に要求してるgoのビルドで失敗)
  • redpen(ダウンロードファイルのSHA256チェックでエラー)
  • sbt(ビルド中に要求してるopenjdkのインストールで失敗)
  • scala(ダウンロードファイルのSHA256チェックでエラー)
  • scrcpy(ビルド中に要求してるopenjdkのインストールで失敗)
  • shellcheck(ビルド失敗 / 依存しているghc@8.8側の問題?)
  • sshfs(依存しているosxfuseのインストールに失敗しているため)
  • telnet(インストールにXcode.appを要求)
  • watchman(ダウンロードのネットワークエラー?)
  • google-cloud-sdk(ビルド失敗)
  • google-japanese-ime(rosetta2を要求)
  • melonbooksviewer(rosetta2を要求)
  • station(Not Found?)

インストールには成功したが起動にrosetta2を要求されたアプリケーション

主にcaskで入れたアプリケーションの起動を試しましたが、以下のアプリケーションが起動時にrosetta2を要求されました。

  • android-file-transfer
  • emacs
  • google-chrome-canary
  • jetbrains-toolbox
  • keepassxc
  • kindle
  • sequel-pro-nightly
  • skitch
  • slack-beta
  • steam
  • vlc
ik-fibik-fib

Goのインストール

Go自体は最新のmasterコードでM1 Macに対応しています。
そのため、別マシンで最新のGoのコードをダウンロード、クロスコンパイルすることでgoのバイナリを入れることは可能です。

上記のQiitaを参考にgoの最新ビルドを作成します。

M1ではない別のマシンで、以下のコマンドを実行します。

ghq get git@github.com:golang/go.git
cd $(ghq root)/github.com/golang/go
GOARCH=arm64 GOOS=darwin ./bootstrap.bash

これで、go-darwin-arm64-bootstrap.tbz が作成されるので、それをM1 Macに転送します。

M1 Macで go-darwin-arm64-bootstrap.tbz を展開します。

後は、 展開したフォルダ/bin にPATHを通せば、goが利用可能です。

homebrewでのインストールにビルドしたgoを使う

上節でビルドしたgoのバイナリをhomebrewのビルドに使えるようにします

homebrewのビルドでは エラーメッセージを見る限り、 /opt/homebrew/opt/ 以下にあるものが使われるようなので、ここに展開したディレクトリをリンクさせます。

ln -s ${go-darwin-arm64-bootstrapを展開したPATH}/ /opt/homebrew/opt/go

その上で、homebrewのインストール時に依存関係のインストールを無視する --ignore-dependencies を追加して、インストールに失敗したパッケージの再インストールを以下のコマンドを実行します。

brew install --ignore-dependencies peco
brew install --ignore-dependencies hub
brew install --ignore-dependencies ghq
brew install --ignore-dependencies fzf
brew install --ignore-dependencies direnv

これで上記5つのインストールが正常にできました。

ik-fibik-fib

OpenJDKのインストール

M1ネイティブ対応しているOpenJDKをインストールします。

Java Download | Java 8, Java 11, Java 13 - Linux, Windows & macOS から zulu11.43.1015-ca-jdk11.0.9.1-macos_aarch64.zip をダウンロード⇨解凍します。

解凍したディレクトリにある zulu-11.jdkフォルダを /Library/Java/JavaVirtualMachinesフォルダに配置します。
(自分の場合、なぜかcpコマンドでうまくcopyできなかったので、finderでzulu-11.jdk/Library/Java/JavaVirtualMachines 以下にコピーアンドペーストしました。)

動作確認

% java --version
openjdk 11.0.9.1 2020-11-04 LTS
OpenJDK Runtime Environment Zulu11.43+1015-CA (build 11.0.9.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.43+1015-CA (build 11.0.9.1+1-LTS, mixed mode)

openjdkを要求されたアプリケーションのインストール

sbt

sbt自体をbrew installでインストールできるようにするには以下でできた。

ln -s ${ダウンロードしたzulu11を展開したディレクトリ} /opt/homebrew/opt/openjdk
brew install --ignore-dependencies sbt

ただし、sbt実行時にエラーになる。
jdkバージョンの問題かと思い、zulu16-eaで試したが変わらず。

sbt自体のGithub projectを見ると、1.4.5でM1対応されるようだがbrewではいったバージョンは1.4.4

一旦保留

ffmpeg

依存関係が多いので、以下のコマンドでopenjdkが依存しているパッケージを探し出す

brew deps --tree  --include-build ffmpeg

探した結果、libblurayとlibblurayが依存しているantで使っているらしい

なので、上記のリンクをした状態で、以下のコマンドでインストール

brew install --ignore-dependencies ant
brew install libpng
brew install freetype
brew install fontconfig
brew install --ignore-dependencies libbluray
brew install ffmpeg

最後にxcodeを要求されてエラーになった。

Xcode要求されたアプリ用に別途Xcodeはインストール済だったので、ライセンス承諾 & 再インストール

sudo xcodebuild -license
brew install ffmpeg

今度はrustを要求されて、そこでビルドエラー(依存のrav1eがrustに依存してる)

==> Installing ffmpeg dependency: rust
==> ./configure --prefix=/opt/homebrew/Cellar/rust/1.47.0 --release-channel=stable
==> make
Last 15 lines from /Users/user/Library/Logs/Homebrew/rust/02.make:

spurious failure, trying again
curl: (22) The requested URL returned error: 404

spurious failure, trying again
curl: (22) The requested URL returned error: 404

spurious failure, trying again
curl: (22) The requested URL returned error: 404

spurious failure, trying again
curl: (22) The requested URL returned error: 404
failed to run: curl -s -y 30 -Y 10 --connect-timeout 30 --retry 3 -Sf -o /private/tmp/tmpo0aqjx42.sha256 https://static.rust-lang.org/dist/2020-08-27/rust-std-1.46.0-aarch64-apple-darwin.tar.xz.sha256
Build completed unsuccessfully in 0:00:01
make: *** [all] Error 1

Do not report this issue to Homebrew/brew or Homebrew/core!

These open issues may also help:
rust: add rust-src https://github.com/Homebrew/homebrew-core/pull/66315
Rust 1.48 revision bumps https://github.com/Homebrew/homebrew-core/pull/66285
rust-1.47 contains mismatched tools https://github.com/Homebrew/homebrew-core/issues/63202

Error: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

rustインストール

rustのnightly buildはM1対応しているので、rustupからインストールします

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

この後ダイアログで各種設定を聞かれるので、nightlyを選択してインストールします

info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /Users/user/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /Users/user/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /Users/user/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /Users/user/.profile
  /Users/user/.zshenv

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: aarch64-apple-darwin
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>2

I'm going to ask you the value of each of these installation options.
You may simply press the Enter key to leave unchanged.

Default host triple?


Default toolchain? (stable/beta/nightly/none)
nightly

Profile (which tools and data to install)? (minimal/default/complete)
default

Modify PATH variable? (y/n)
y


Current installation options:


   default host triple: aarch64-apple-darwin
     default toolchain: nightly
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: setting default host triple to aarch64-apple-darwin
info: syncing channel updates for 'nightly-aarch64-apple-darwin'
info: latest update on 2020-12-10, rust version 1.50.0-nightly (f0f68778f 2020-12-09)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
 18.2 MiB /  18.2 MiB (100 %)   8.6 MiB/s in  2s ETA:  0s
info: downloading component 'rustc'
 42.7 MiB /  42.7 MiB (100 %)   9.7 MiB/s in  4s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: using up to 500.0 MiB of RAM to unpack components
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
 42.7 MiB /  42.7 MiB (100 %)  20.8 MiB/s in  2s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'nightly-aarch64-apple-darwin'

  nightly-aarch64-apple-darwin installed - rustc 1.50.0-nightly (f0f68778f 2020-12-09)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell, run:
source $HOME/.cargo/env

今までと同じようにシンボリックリンクをはる

ln -s $HOME/.cargo/bin/ /opt/homebrew/opt/rust
brew install libgit2
brew install --ignore-dependencies cargo-c

brew 経由でcargo-cをいれるのはエラーになったので、インストールしたcargoからインストール

~/.cargo/bin/cargo install cargo-c --features=vendored-openssl
ln -s $HOME/.cargo/bin/ /opt/homebrew/opt/cargo-c
brew install --ignore-dependencies rav1e

これもエラー

依存関係解消が複雑になっていたので一旦保留(他終わってから考える)

ik-fibik-fib

Xcode要求されたパッケージ

masとtelnetがXcodeを要求されたが、App StoreでXcodeをインストール後以下のコマンドで問題なくインストールできた。

brew install mas
brew install telnet
ik-fibik-fib

ネットワークエラーでインストールに失敗したパッケージ

おそらくエラー内容からネットワークエラーだと思われた2つ、watchman, ImageMagickはやはりネットワークエラーだったようで、再度インストールすると正常にインストールできた。

brew install watchman
brew install imagemagick
ik-fibik-fib

openjdk リトライ

homebrew のissue, PRを眺めていると、openjdkのM1対応のPRがあったのでこれを試してみる。(注: レビュー通ってないPR)

上記で作成したシンボリックリンクを事前に削除

rm /opt/homebrew/opt/openjdk

以下のコマンドでPRをpatchとして適用⇨openjdk install

cd /opt/homebrew/Library/Taps/homebrew/homebrew-core
curl  -L -O https://github.com/Homebrew/homebrew-core/pull/65670.patch
patch -p1 < 65670.patch
brew install openjdk
$ brew install openjdk
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

==> Downloading https://download.java.net/java/early_access/jdk16/26/GPL/openjdk-16-ea+26_osx-x64_bin.tar.gz
######################################################################## 100.0%
==> Downloading https://github.com/openjdk/jdk-sandbox/archive/a56ddad05cf1808342aeff1b1cd2b0568a6cdc3a.tar.gz
==> Downloading from https://codeload.github.com/openjdk/jdk-sandbox/tar.gz/a56ddad05cf1808342aeff1b1cd2b0568a6cdc3a
# #  #  #                                              -=O=-
==> ./configure --without-version-pre --without-version-opt --with-version-build=14 --with-toolchain-path=/usr/bin --with
==> make images
Error: Failed applying an ad-hoc signature to /opt/homebrew/Cellar/openjdk/16/libexec/openjdk.jdk/Contents/MacOS/libjli.dylib
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

openjdk is keg-only, which means it was not symlinked into /opt/homebrew,
because it shadows the macOS `java` wrapper.

If you need to have openjdk first in your PATH run:
  echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk you may need to set:
  export CPPFLAGS="-I/opt/homebrew/opt/openjdk/include"

==> Summary
🍺  /opt/homebrew/Cellar/openjdk/16: 612 files, 305.4MB, built in 13 minutes 57 seconds
Removing: /Users/user/Library/Caches/Homebrew/openjdk--patch--5320e5e8db5f94432925d7c240f41c12b10ff9a0afc2f7a8ab0728a114c43cdb.patch... (1.5KB)
Removing: /Users/user/Library/Caches/Homebrew/openjdk--patch--4e4448a5bf68843c21bf96f510ea270aa795c5fac41fd9088f716822788d0f57.patch... (1.5KB)
Removing: /Users/user/Library/Caches/Homebrew/openjdk--15.0.1.tar.bz2... (1.6MB)
Removing: /Users/user/Library/Caches/Homebrew/openjdk--boot-jdk--14.0.2_osx.tar.gz... (184.4MB)

署名周りでエラーが出たけどとりあえずインストールは完了

rust リトライ

install時に--HEAD をつけることでgitのHEADからビルドできることを知ったのでそれを試す。
⇨ninjaインストール済みだが、無いと怒られた

brew install rust --HEAD -v

log: https://gist.github.com/ik11235/5bd2e671651300df856604532a71afbc

logに乗っているPATHでninjaが見れるように無理矢理パスを通す

ln -s /opt/homebrew/bin/ninja /opt/homebrew/opt/cmake/bin/ninja

再度インストールをすると無事成功。

brew install rust --HEAD -v

openjdk, rustが要求されたアプリケーションの再インストール

scrcpy

依存関係でrav1eを要求されたがビルドエラー & HEADオプションもrav1eにはなかった

$ brew install rav1e
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

==> Downloading https://media.xiph.org/video/derf/y4m/bus_qcif_7.5fps.y4m
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/84dee343cc5619f633a22fc51045e2ae977ead573b95e40f02aa7b9dea7908ea--bus_qcif_7.5fps.y4m
==> Downloading https://github.com/xiph/rav1e/archive/v0.3.4.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/da1a53a23422df842948b3cf6c6c80e8315ea269d9eb7b132623319223118c2d--rav1e-0.3.4.tar.gz
==> cargo install
Last 15 lines from /Users/user/Library/Logs/Homebrew/rav1e/01.cargo:
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=aarch64-apple-darwin" "-I" "." "-I" "/private/tmp/rav1e-20201212-56763-pnidp1/rav1e-0.3.4/target/release/build/rav1e-0e068353943a2bb8/out" "-Wall" "-Wextra" "-o" "/private/tmp/rav1e-20201212-56763-pnidp1/rav1e-0.3.4/target/release/build/rav1e-0e068353943a2bb8/out/src/arm/64/itx.o" "-c" "src/arm/64/itx.S"
  cargo:warning=error: unknown target triple 'unknown-apple-macosx11.0.0', please use -triple or -arch
  exit code: 1

  --- stderr


  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=aarch64-apple-darwin" "-I" "." "-I" "/private/tmp/rav1e-20201212-56763-pnidp1/rav1e-0.3.4/target/release/build/rav1e-0e068353943a2bb8/out" "-Wall" "-Wextra" "-o" "/private/tmp/rav1e-20201212-56763-pnidp1/rav1e-0.3.4/target/release/build/rav1e-0e068353943a2bb8/out/src/arm/64/mc.o" "-c" "src/arm/64/mc.S" with args "clang" did not execute successfully (status code exit code: 1).


warning: build failed, waiting for other jobs to finish...
error: failed to compile `rav1e v0.3.4 (/private/tmp/rav1e-20201212-56763-pnidp1/rav1e-0.3.4)`, intermediate artifacts can be found at `/private/tmp/rav1e-20201212-56763-pnidp1/rav1e-0.3.4/target`

Caused by:
  build failed

Do not report this issue to Homebrew/brew or Homebrew/core!


Error: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

rav1e リポジトリを確認した限り、M1対応はされてそう

なので、homebrewのFormulaを書き換えて最新ビルドを対象に

diff --git a/Formula/rav1e.rb b/Formula/rav1e.rb
index 45e0f88a6e..fba31cc69b 100644
--- a/Formula/rav1e.rb
+++ b/Formula/rav1e.rb
@@ -1,8 +1,8 @@
 class Rav1e < Formula
   desc "Fastest and safest AV1 video encoder"
   homepage "https://github.com/xiph/rav1e"
-  url "https://github.com/xiph/rav1e/archive/v0.3.4.tar.gz"
-  sha256 "797699359d594c929636ddd54474c99fe0577b545a21384514f864d68f67b98f"
+  url "https://github.com/xiph/rav1e/archive/p20201208.tar.gz"
+  sha256 "e700d38ecba6d63a50216bd9b1e5de4717b0eb0490011f68fe5bdd33d43b1902"
   license "BSD-2-Clause"

   livecheck do

その後 brew install rav1e で無事インストール完了

$ brew install rav1e
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

==> Downloading https://media.xiph.org/video/derf/y4m/bus_qcif_7.5fps.y4m
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/84dee343cc5619f633a22fc51045e2ae977ead573b95e40f02aa7b9dea7908ea--bus_qcif_7.5fps.y4m
==> Downloading https://github.com/xiph/rav1e/archive/p20201208.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/f2c830575af378362d3a36d57d77a3447632b73c4a580f413ac5d3a2d7192fd3--rav1e-p20201208.tar.gz
==> cargo install
==> cargo cinstall --prefix
🍺  /opt/homebrew/Cellar/rav1e/20201208: 13 files, 60.6MB, built in 1 minute 46 seconds
Removing: /Users/user/Library/Caches/Homebrew/rav1e--0.3.4.tar.gz... (783.7KB)

今度は、rubberbandのビルド失敗で止まる

==> Installing scrcpy dependency: rubberband
==> make -f Makefile.osx
Last 15 lines from /Users/user/Library/Logs/Homebrew/rubberband/01.make:
error: unknown FP unit 'sse'
error: unknown FP unit 'sse'
make: *** [src/StretcherProcess.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [src/StretchCalculator.o] Error 1
make: *** [src/rubberband-c.o] Error 1
error: unknown FP unit 'sse'
make: *** [src/RubberBandStretcher.o] Error 1
make: *** [src/dsp/AudioCurveCalculator.o] Error 1
error: unknown FP unit 'sse'
make: *** [src/audiocurves/CompoundAudioCurve.o] Error 1
error: unknown FP unit 'sse'
make: *** [src/audiocurves/SpectralDifferenceAudioCurve.o] Error 1
error: unknown FP unit 'sse'
make: *** [src/base/Profiler.o] Error 1

Do not report this issue to Homebrew/brew or Homebrew/core!

These open issues may also help:
rubberband: enable build on Apple Silicon https://github.com/Homebrew/homebrew-core/pull/66019

Error: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

PRがすでにあるのでそれを利用する

cd /opt/homebrew/Library/Taps/homebrew/homebrew-core
curl  -L -O https://github.com/Homebrew/homebrew-core/pull/66019.patch
patch -p1 < 66019.patch
brew install rubberband

rubberbandは無事インストール完了

その後、scrcpyも再インストールで無事インストール完了

brew install scrcpy

ffmpeg

scrcpyの依存関係で上記の対応中にインストール済み

scala

上記のopenjdkの変更 & インストール後、brew install でインストールできた。

brew install scala

redpen

上記のopenjdkの変更 & インストール後、brew install でインストールできた。

brew install redpen
ik-fibik-fib

sbt リトライ

Formula をgitリポジトリから最新ビルドをとってきてビルドするように修正してみる。

diff --git a/Formula/sbt.rb b/Formula/sbt.rb
index 06bf45209f..76c24a96d3 100644
--- a/Formula/sbt.rb
+++ b/Formula/sbt.rb
@@ -1,9 +1,9 @@
 class Sbt < Formula
   desc "Build tool for Scala projects"
   homepage "https://www.scala-sbt.org/"
-  url "https://github.com/sbt/sbt/releases/download/v1.4.4/sbt-1.4.4.tgz"
-  mirror "https://sbt-downloads.cdnedge.bluemix.net/releases/v1.4.4/sbt-1.4.4.tgz"
-  sha256 "2efae0876119af7bfce8b3621b43b08c51381352916ac9de6156b1251ec26d45"
+  url "https://github.com/sbt/sbt.git"
+  version "develop"
+  sha256 ""
   license "Apache-2.0"

   bottle :unneeded

試したが、デフォルトブランチがmasterでないため、どうにも失敗する様子

$ brew install sbt
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

==> Cloning https://github.com/sbt/sbt.git
Cloning into '/Users/user/Library/Caches/Homebrew/sbt--git'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream origin
Error: Failed to download resource "sbt"
Failure while executing; `git clone --depth 1 --branch master -c advice.detachedHead=false https://github.com/sbt/sbt.git /Users/user/Library/Caches/Homebrew/sbt--git` exited with 128. Here's the output:
Cloning into '/Users/user/Library/Caches/Homebrew/sbt--git'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream origin


$ git clone --depth 1 --branch develop -c advice.detachedHead=false https://github.com/sbt/sbt.git /Users/user/Library/Caches/Homebrew/sbt--git
Cloning into '/Users/user/Library/Caches/Homebrew/sbt--git'...
remote: Enumerating objects: 4440, done.
remote: Counting objects: 100% (4440/4440), done.
remote: Compressing objects: 100% (2743/2743), done.
remote: Total 4440 (delta 340), reused 3274 (delta 220), pack-reused 0
Receiving objects: 100% (4440/4440), 3.05 MiB | 2.65 MiB/s, done.
Resolving deltas: 100% (340/340), done.

$ brew install sbt
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

==> Cloning https://github.com/sbt/sbt.git
Updating /Users/user/Library/Caches/Homebrew/sbt--git
fatal: couldn't find remote ref refs/heads/master
Error: Failed to download resource "sbt"
Failure while executing; `git fetch origin` exited with 128. Here's the output:
fatal: couldn't find remote ref refs/heads/master

さらに下記の変更を加えることでcloneはできたが、ソースからbuildするFormulaでは無いのでエラーに

diff --git a/Formula/sbt.rb b/Formula/sbt.rb
index 06bf45209f..dc9d9f1b94 100644
--- a/Formula/sbt.rb
+++ b/Formula/sbt.rb
@@ -1,9 +1,9 @@
 class Sbt < Formula
   desc "Build tool for Scala projects"
   homepage "https://www.scala-sbt.org/"
-  url "https://github.com/sbt/sbt/releases/download/v1.4.4/sbt-1.4.4.tgz"
-  mirror "https://sbt-downloads.cdnedge.bluemix.net/releases/v1.4.4/sbt-1.4.4.tgz"
-  sha256 "2efae0876119af7bfce8b3621b43b08c51381352916ac9de6156b1251ec26d45"
+  url "https://github.com/sbt/sbt.git", :branch => "develop"
+  version "develop"
+  sha256 ""
   license "Apache-2.0"
$ brew reinstall sbt
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

==> Cloning https://github.com/sbt/sbt.git
Updating /Users/user/Library/Caches/Homebrew/sbt--git
==> Checking out branch develop
Already on 'develop'
Your branch is up to date with 'origin/develop'.
HEAD is now at acc94fd Merge pull request #6199 from adpi2/sbt-dotty
==> Reinstalling sbt
Error: An exception occurred within a child process:
  Errno::ENOENT: No such file or directory @ rb_sysopen - bin/sbt
ik-fibik-fib

graphviz リトライ

ビルド中にsvnを要求されたので入れる

brew install svn

その後、brew install でインストールで無事成功

brew install graphviz
ik-fibik-fib

google-cloud-sdk リトライ

再確認すると依存する python@3.8でビルドエラーになっていた

==> ./configure --prefix=/opt/homebrew/Cellar/python@3.8/3.8.6_2 --enable-ipv6 --datarootdir=/opt/homebrew/Cellar/python@3.8/3.8.6_2/share --datadir=/op
==> make
Last 15 lines from /Users/user/Library/Logs/Homebrew/python@3.8/02.make:
    self.run_command(cmd_name)
  File "/private/tmp/python@3.8-20201212-34047-gj885m/Python-3.8.6/Lib/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/private/tmp/python@3.8-20201212-34047-gj885m/Python-3.8.6/Lib/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/tmp/python@3.8-20201212-34047-gj885m/Python-3.8.6/Lib/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "./setup.py", line 361, in build_extensions
    self.detect_modules()
  File "./setup.py", line 1736, in detect_modules
    self.detect_readline_curses()
  File "./setup.py", line 971, in detect_readline_curses
    (tuple(int(n) for n in dep_target.split('.')[0:2])
AttributeError: 'int' object has no attribute 'split'
make: *** [sharedmods] Error 1

Do not report this issue to Homebrew/brew or Homebrew/core!

These open issues may also help:
python@3.8: make test run on ARM https://github.com/Homebrew/homebrew-core/pull/64872

Error: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

PRがあるので、それを利用してpython@3.8をインストール

cd /opt/homebrew/Library/Taps/homebrew/homebrew-core
curl  -L -O https://github.com/Homebrew/homebrew-core/pull/64872.patch
patch -p1 < 64872.patch
brew install python@3.8

これだけだとエラーになった

==> ./configure --prefix=/opt/homebrew/Cellar/python@3.8/3.8.6_2 --enable-ipv6 --datarootdir=/opt/homebrew/Cellar/python@3.8/3.8.6_2/share --datadir=/op
==> make
Last 15 lines from /Users/user/Library/Logs/Homebrew/python@3.8/02.make:
    self.run_command(cmd_name)
  File "/private/tmp/python@3.8-20201212-43325-ss1ef6/Python-3.8.6/Lib/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/private/tmp/python@3.8-20201212-43325-ss1ef6/Python-3.8.6/Lib/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/tmp/python@3.8-20201212-43325-ss1ef6/Python-3.8.6/Lib/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "./setup.py", line 361, in build_extensions
    self.detect_modules()
  File "./setup.py", line 1736, in detect_modules
    self.detect_readline_curses()
  File "./setup.py", line 971, in detect_readline_curses
    (tuple(int(n) for n in dep_target.split('.')[0:2])
AttributeError: 'int' object has no attribute 'split'
make: *** [sharedmods] Error 1

Do not report this issue to Homebrew/brew or Homebrew/core!

These open issues may also help:
python@3.8: make test run on ARM https://github.com/Homebrew/homebrew-core/pull/64872

Error: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

以下のPR, issueを参考に以下の変更を加える。

diff --git a/Formula/python@3.8.rb b/Formula/python@3.8.rb
index 9f4da5bfc6..1f563eaf28 100644
--- a/Formula/python@3.8.rb
+++ b/Formula/python@3.8.rb
@@ -107,7 +107,7 @@ class PythonAT38 < Formula
       cflags << "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
     end
     # Avoid linking to libgcc https://mail.python.org/pipermail/python-dev/2012-February/116205.html
-    args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}"
+    args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version.to_f}"

     # We want our readline! This is just to outsmart the detection code,
     # superenv makes cc always find includes/libs!

この上でbrew install で成功

brew install python@3.8

再度、google-cloud-sdkのインストールを試す。

$ brew install google-cloud-sdk
==> Caveats
google-cloud-sdk is installed at /opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk. Add your profile:

  for bash users
    export CLOUDSDK_PYTHON="/opt/homebrew/opt/python@3.8/libexec/bin/python"
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc"

  for zsh users
    export CLOUDSDK_PYTHON="/opt/homebrew/opt/python@3.8/libexec/bin/python"
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"

  for fish users
    set -g -x "CLOUDSDK_PYTHON" "/opt/homebrew/opt/python@3.8/libexec/bin/python"
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.fish.inc"

==> Downloading https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
Warning: No checksum defined for cask 'google-cloud-sdk', skipping verification.
All Formula dependencies satisfied.
==> Installing Cask google-cloud-sdk
Beginning update. This process may take several minutes.
ERROR: (gcloud.components.update) The following components are unknown [kuberun, anthoscli].
==> Purging files for version latest of Cask google-cloud-sdk
Error: Failure while executing; `/usr/bin/env CLOUDSDK_PYTHON=/opt/homebrew/opt/python@3.8/libexec/bin/python /opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/install.sh --usage-reporting false --bash-completion false --path-update false --rc-path false --quiet` exited with 1. Here's the output:
Welcome to the Google Cloud SDK!
Beginning update. This process may take several minutes.
ERROR: (gcloud.components.update) The following components are unknown [kuberun, anthoscli].

This will install all the core command line tools necessary for working with
the Google Cloud Platform.

これでもエラーになった。調べたがM1対応のgoogle-cloud-sdkはまだなさそうだったので一旦諦める

ik-fibik-fib

一旦、大体のアプリケーションはインストールできたのでビルド用にインストールした依存パッケージを削除する(依存してないもののみ)

brew remove ant
brew remove ant rust
brew remove ant subversion
ik-fibik-fib

依存パッケージの整理

手動で入れたパッケージはこのままだとbrew dumpしたときに一覧に表示されるので、一旦uninstall して再度やり直してみる。

brew remove scrcpy ffmpeg
brew remove rav1e
brew remove --ignore-dependencies  libpng freetype fontconfig libbluray rubberband
brew install ffmpeg
brew remove meson
brew remove ninja
brew uninstall --ignore-dependencies libgit2
brew reinstall cargo-c

https://yulii.github.io/brew-cleanup-installed-formulae-20200509.html を参考に依存していないパッケージを検索

brew list | xargs -P`expr $(sysctl -n hw.ncpu) - 1` -I{} sh -c 'brew uses --installed {} | wc -l | xargs printf "%20s is used by %2d formulae.\n" {}' | grep '0 formula'
bash-3.2$ brew remove apr-util
Uninstalling /opt/homebrew/Cellar/apr-util/1.6.1_3... (54 files, 898.4KB)
bash-3.2$ brew remove ant
Uninstalling /opt/homebrew/Cellar/ant/1.10.9... (1,668 files, 41.8MB)
bash-3.2$ brew remove autoconf-archive
Uninstalling /opt/homebrew/Cellar/autoconf-archive/2019.01.06... (586 files, 3.4MB)
bash-3.2$ brew remove automake
Uninstalling /opt/homebrew/Cellar/automake/1.16.3... (131 files, 3.1MB)
bash-3.2$ brew remove bison
Uninstalling /opt/homebrew/Cellar/bison/3.7.4... (94 files, 3.3MB)
bash-3.2$ brew remove cargo-c
Uninstalling /opt/homebrew/Cellar/cargo-c/0.6.18_1... (10 files, 49MB)
bash-3.2$ brew remove carthage
Uninstalling /opt/homebrew/Cellar/carthage/0.36.0... (8 files, 7.4MB)
bash-3.2$ brew remove cmake
Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake
Uninstalling /opt/homebrew/Cellar/cmake/3.19.1... (6,367 files, 62.3MB)
bash-3.2$ brew remove intltool
Uninstalling /opt/homebrew/Cellar/intltool/0.51.0... (20 files, 186.7KB)
bash-3.2$ brew remove itstool
Uninstalling /opt/homebrew/Cellar/itstool/2.0.6_2... (17 files, 138.4KB)
bash-3.2$ brew remove libatomic_ops
Uninstalling /opt/homebrew/Cellar/libatomic_ops/7.6.10... (82 files, 718.7KB)
bash-3.2$ brew remove meson
Uninstalling /opt/homebrew/Cellar/meson/0.56.0... (169 files, 2.7MB)
bash-3.2$ brew remove nasm
Uninstalling /opt/homebrew/Cellar/nasm/2.15.05... (29 files, 3.2MB)
bash-3.2$ brew remove scons
Uninstalling /opt/homebrew/Cellar/scons/4.0.1_1... (2,643 files, 29.6MB)
bash-3.2$ brew remove swig
Uninstalling /opt/homebrew/Cellar/swig/4.0.2... (727 files, 5.5MB)
bash-3.2$ brew remove yasm
Uninstalling /opt/homebrew/Cellar/yasm/1.3.0_2... (46 files, 3.3MB)
ik-fibik-fib

インストールできていないパッケージ

  • ext4fuse, osxfuse, sshfs: 最近使ってなかったので一旦保留
  • shellcheck: 必要になったらintel版を入れる
  • google-cloud-sdk: 必要になったらintel版を入れる
ik-fibik-fib

rosetta2経由で入ったアプリケーションのM1版がないか探す

https://zenn.dev/ik11235/scraps/17d44ec45ea8f7#comment-643fa5b0912409 であげた brewで入ったがrosetta2経由になったアプリケーションのM1版がないか探す

android-file-transfer

https://www.android.com/filetransfer/ から最新バージョンをDLしてみたが、Intel版だった
(そもそもandroid-file-transferって最近更新されてない気がする)

emacs

今まで、brew cask install emacs でインストールしていました。

https://emacsformacosx.com の最新版を確認しましたが、やっぱりIntel版でした。
(M1ビルド使いたいなら自分でbuildするか、brew側の使うのが良さそう?)

google-chrome-canary

https://www.google.com/intl/ja/chrome/canary/ からダウンロードを開くと、Intel, ARMの選択肢がでて
ARM版を選ぶこともできました。(ARMを選ぶことで、ユニバーサル版がDLできました。)

jetbrains-toolbox

https://www.jetbrains.com/ja-jp/toolbox-app/ から最新版をダウンロードしましたが、Intel版でした。

Jetbrain製品のARM対応は下記のページで追えるようです。

https://youtrack.jetbrains.com/issue/JBR-2526

IntelliJ IDEA Ultimate/Community に関しては、上記issueからテスト版のARM版をダウンロードできます。

keepassxc

Github プロジェクトを見に行きましたが、Qtの対応が進むまでは進まなさそうです。

https://github.com/keepassxreboot/keepassxc/issues/4934

kindle

https://www.amazon.co.jp/dp/B011UEIO4S/ から最新版をDLしましたが、Intel版でした

sequel-pro-nightly

https://github.com/sequelpro/sequelpro を見に行きましたが、issue等にも記載がなく、そもそもここ数ヶ月masterリポジトリに更新がなかったです。

skitch

https://evernote.com/intl/jp/products/skitch から最新版をDLしましたが、Intel版でした

App storeにあるほうも確認しましたが、こちらもIntel版でした。
https://apps.apple.com/jp/app/skitch-撮る-描き込む-共有する/id425955336?mt=12

slack-beta

https://slack.com/intl/ja-jp/downloads/mac に ARM版があり、そちらからインストール可能です。

steam

https://store.steampowered.com/about/ から最新版をDLしましたが、Intel版でした。

vlc

https://www.videolan.org/ から最新版をDLしましたが、Intel版でした。

開発フォーラムをみると、対応予定はあるようですが、時期は未定のようです。

https://forum.videolan.org/viewtopic.php?f=12&t=155550

ik-fibik-fib

バッテリー残量の%をメニューバーに表示させる

Big Surでの変更でこれまでの表示手順と変わっている。
(M1特有ではなくBig Surでの変更)

「システム環境設定」 →「Dockとメニューバー」→「バッテリー」を開く。
「割合(%)を表示」にチェックを入れると表示されるようになる。

ik-fibik-fib

brew以外で入れたアプリケーションのM1対応状況

sync

ファイル同期アプリ
https://www.sync.com/

最新版をダウンロードしたが、Intel版だった

docker

Developer Preview版がM1対応したとのことなので、Developer Preview Programに申請しました。
現在、Community Slackのプライベートチャンネル招待待ち。
(privateなSlackがあるのと勘違いして、Slack入ってない状態で、招待リクエストした → 気づいてCommunity Slack登録後に再送してるので時間かかるかも)

Invitation来たので、Docker-AppleSilicon-Preview5 をインストールしました。
まだ、getting started コンテナを試しに起動させただけですが、現状では特に問題はありませんでした。

HoRNDIS

AndroidスマホのUSBテザリングをMacで使用できるようにするためのアプリケーション

https://joshuawise.com/horndis

M1対応というよりも、Big Surにそもそも対応していない。(インストール中にエラーになった)

githubプロジェクトを確認すると、issueはあったが解決はしてなさそう & そもそも最近メンテされてなさそう…

https://github.com/jwise/HoRNDIS/issues/132

ik-fibik-fib

Big Sur 11.1 にアップデートすると色々ビルドできなくなった

上記のインストール後、Big Sur 11.1にアップデートして再ビルドしようとするとrustはビルドできなくなっていた。

error: aborting due to previous error

error: could not compile `std`

To learn more, run the command again with --verbose.
command did not execute successfully: "/private/tmp/rust-20201217-21532-1on84xv/build/x86_64-apple-darwin/stage0/bin/cargo" "build" "--target" "aarch64-apple-darwin" "-Zbinary-dep-depinfo" "-j" "8" "--release" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/private/tmp/rust-20201217-21532-1on84xv/library/test/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit code: 101
failed to run: /private/tmp/rust-20201217-21532-1on84xv/build/bootstrap/debug/bootstrap build --stage 2
Build completed unsuccessfully in 0:45:24
make: *** [all] Error 1

色々調べたが、11.1になってmac側のシステムヘッダーが移動したらしい?
https://github.com/Homebrew/homebrew-core/issues/67075

これが原因かははっきり調べられてないが、その可能性が高そう

(あと、brewでインストールする時にほとんどのパッケージで --build-from-source を求められたが、これはまだ11.1のbottleがないから? / とはいえ11.0の時も同じだろうし、brewのバージョンupの影響?)

ik-fibik-fib

BackgroundMusic

Macのボリュームをアプリごとに切り替えられるアプリ

https://github.com/kyleneideck/BackgroundMusic
参考: https://qiita.com/xeno01/items/cd7db9ed6101d40cc3bc

caskで入るらしいので入れようとしたが、うまく動かなかった
github見にいくとBig Surはまだ公式には未対応らしい

https://github.com/kyleneideck/BackgroundMusic#download

ただ、アルファ版のスナップショットは使えるらしいのでそっちをDLしてインストール、正常に使えた。

ik-fibik-fib

rust 再再インストール

https://zenn.dev/ik11235/scraps/17d44ec45ea8f7#comment-6f5b03b07e1fa0 で書いたように、Rustが--HEAD でもインストールできなくなった

rustの最新版はM1対応対応してるはずなので、色々試してるうちにhomebrewのrust Formula を以下のように修正するとビルドできた。
(M1対応してるので、Rosetta通さなくてもいけるのではと思ってやったらできた)

diff --git a/Formula/rust.rb b/Formula/rust.rb
index 64d42a594e..fe79fb5c27 100644
--- a/Formula/rust.rb
+++ b/Formula/rust.rb
@@ -80,11 +80,11 @@ class Rust < Formula
     end
     # Cross-compile arm64 with x86_64 bootstrap compiler.
     if Hardware::CPU.arch == :arm64
-      args << "--build=x86_64-apple-darwin"
+      args << "--build=aarch64-apple-darwin"
       args << "--host=aarch64-apple-darwin"
       args << "--target=aarch64-apple-darwin"
       system "./configure", *args
-      system "arch", "-x86_64", "make"
+      system "make"
     else
       system "./configure", *args
       system "make"

ただ、今度はcargo-cのインストールで失敗(ライブラリのバージョンがないっぽい? <まだちゃんと調べてない>)

2020-12-21 01:03:41 +0900

cargo
install
--locked
--root
/opt/homebrew/Cellar/cargo-c/0.6.18_1
--path
.

  Installing cargo-c v0.6.18+cargo-0.49 (/private/tmp/cargo-c-20201221-10321-wb46hz/cargo-c-0.6.18)
    Updating crates.io index
ik-fibik-fib

cargo-cの再インストール

色々試したが、crates.io のcloneで失敗しているようだった
(原因探すために最新のソースをcloneした上で以下を試した)

https://qiita.com/ryo-yamaoka/items/c9d7c9127540e9eadfbb#解決法2-コケた場合にosのgitコマンドへフォールバックさせる を参考にcargoでシステムのgitを使うように

  • ~/.cargo/config
[net]
git-fetch-with-cli = true

その上で、以下を実行するとインストールできた

git clone https://github.com/lu-zero/cargo-c
cd cargo-c
 rm -fr "{$HOME}/.cargo/registry/"
cargo install --locked --root /opt/homebrew/Cellar/cargo-c/0.7.0 --path .

rav1e 再インストール

brewでインストールしようとすると↑と同じようにエラーになった

brew install --build-from-source rav1e
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

==> Downloading https://media.xiph.org/video/derf/y4m/bus_qcif_7.5fps.y4m
######################################################################## 100.0%
==> Downloading https://github.com/xiph/rav1e/archive/v0.3.4.tar.gz
==> Downloading from https://codeload.github.com/xiph/rav1e/tar.gz/v0.3.4
######################################################################## 100.0%
==> cargo install
Last 15 lines from /Users/user/Library/Logs/Homebrew/rav1e/01.cargo:
/opt/homebrew/Cellar/rav1e/0.3.4
--path
.

  Installing rav1e v0.3.4 (/private/tmp/rav1e-20201222-47164-zzyokc/rav1e-0.3.4)
    Updating crates.io index
warning: spurious network error (2 tries remaining): failed to lock file '/Users/user/Library/Caches/Homebrew/cargo_cache/registry/index/github.com-1ecc6299db9ec823/.git/refs/remotes/origin/master.lock' for writing: ; class=Os (2)
warning: spurious network error (1 tries remaining): failed to lock file '/Users/user/Library/Caches/Homebrew/cargo_cache/registry/index/github.com-1ecc6299db9ec823/.git/refs/remotes/origin/master.lock' for writing: ; class=Os (2)
error: failed to get `aom-sys` as a dependency of package `rav1e v0.3.4 (/private/tmp/rav1e-20201222-47164-zzyokc/rav1e-0.3.4)`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to lock file '/Users/user/Library/Caches/Homebrew/cargo_cache/registry/index/github.com-1ecc6299db9ec823/.git/refs/remotes/origin/master.lock' for writing: ; class=Os (2)

Do not report this issue to Homebrew/brew or Homebrew/core!


Error: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

そのため、手動インストールを試す

cargo install --locked --root /opt/homebrew/Cellar/rav1e/0.3.4 --path .   

しかし失敗

エラーを見る限り、arm64でビルドできなさそうなので、諦めてrosseta経由(x64)でインストール

$ arch -arch x86_64  bash
$ arch
i386
$ uname -m
x86_64
$ cargo install --locked --root /opt/homebrew/Cellar/rav1e/0.3.4 --path .   

しかし同様のエラー

rustやcargoがarmで入っているのでダメそう?

ik-fibik-fib

x64版のbrewも入れておく

使うアプリケーションが入らないのは困るので、x86_64版のbrewも入れておく
参考: https://zenn.dev/ress/articles/069baf1c305523dfca3d

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

x64版を使うのは最低限にしておきたいので、一旦x86_64版の方を使う方を特別な名前でエイリアス化(fishを使っているので↑の記事のエイリアスを参考に自己流にアレンジ)

旧バージョン(switchの存在を後から知ったのでそれで描き直しした)
--- a/.config/fish/config.fish
+++ b/.config/fish/config.fish
@@ -41,3 +41,20 @@ for tmp_path in (string split : $PATH)
 end

 alias brew="env PATH=$NOT_ANYENV_PATH (which brew)"
+
+# M1関係の設定
+if test (uname -s) = "Darwin" && type arch > /dev/null
+    alias x64_brew="arch -arch x86_64 /usr/local/bin/brew"
+    alias x64='exec arch -arch x86_64 "$SHELL"'
+    alias a64='exec arch -arch arm64e "$SHELL"'
+    function switch-arch
+        if test (uname -m) = "arm64"
+          set arch x86_64
+        else if test (uname -m) = "x86_64"
+          set arch arm64e
+        end
+
+        exec arch -arch $arch "$SHELL"
+    end
+end
## M1関係の設定
if test (uname -s) = "Darwin" && type arch > /dev/null
    alias x64_brew="arch -arch x86_64 /usr/local/bin/brew"
    alias x64='exec arch -arch x86_64 "$SHELL"'
    alias a64='exec arch -arch arm64e "$SHELL"'
    function switch-arch
        switch (uname -m)
          case arm64
            set arch x86_64
          case x86_64
            set arch arm64e
          case '*'
            echo "undefined architecture."
            return 1
        end

        exec arch -arch $arch "$SHELL"
    end
end
ik-fibik-fib

scrcpy周りやり直し

M1 brewで入れたscrcpyが動かなくなったので、x64 brewで入れ直した

しかし、x64 brewも動かなくなった
起動後すぐにSIGKILLが走ったよう<ログとるの忘れた>で、原因がよくわからなかったが1からビルドしようとした時にffmpeg入れてるにもかかわらず、libavformatがないと怒られた⇨しかもm1側のPATHだったのでそれが原因と仮定した。

ninja: error: '/opt/homebrew/Cellar/ffmpeg/4.3.1_4/lib/libavformat.dylib', needed by 'app/scrcpy', missing and no known rule to make it

そのため、余分なPATHを実行時に通さないように↓のようにしてみたら起動した。(/opt/homebrew/bin/を通しているのは、adbのPATHを通す必要があるため)

env PATH="/opt/homebrew/bin/" /usr/local/bin/scrcpy

しかし、1度起動した後、scrcpyをなんの設定も無しで呼び出すと、それも起動した。
そのため↑の設定が功を奏したのではなく、その間にやっていた何かが影響した可能性もあるが、再現できなくなったので、一旦保留

ik-fibik-fib

go 1.16 beta1を試す

https://zenn.dev/ik11235/scraps/17d44ec45ea8f7#comment-5664b4e2697116 で<当時の>Goの最新HEADを入れていますが、正式にM1対応した1.16beta1がリリースされたのでそちらも試してみる。

https://groups.google.com/g/golang-announce/c/2-Rj3P5uRLs?pli=1 を参考に

インストール

${go-darwin-arm64-bootstrapを展開したPATH}/bin/go get golang.org/dl/go1.16beta1
${GOPATH}/bin/go1.16beta1 install

PATH周り設定

以下をzshrc等に追加してgo1.16beta1を使うように

export GOROOT=$HOME/sdk/go1.16beta1
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

brewのリンクも差し替え

rm /opt/homebrew/opt/go
ln -s  ~/sdk/go1.16beta1/ /opt/homebrew/opt/go