Closed35

Apple Siliconでの環境構築メモ

N04hN04h

brewいれる
https://brew.sh

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

Next stepで指示される操作をする

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

ちぇっく

brew -v
N04hN04h

gitをbrewからinstallしたものを使う

brew install git

標準でMacに入っているgitは使わないようにさせる

echo 'export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"' >> /Users/n04h/.zprofile
git --version

git version 2.30.1 (Apple Git-130)的な感じで表示されなくなればOK

N04hN04h

Dockerインストール
ちゃんとApple Chipってのがあった(Siliconでは?)
https://www.docker.com/get-started

そしてまだRosettaを使わないと対応してない箇所があるんだとか(結局使うのね...)

現状以下コマンドは使わなくてもよくなったはず

softwareupdate --install-rosetta
N04hN04h

fishをbrew経由で入れる
https://fishshell.com/

brew install fish

ちぇっく

fish -v

場所確認

which fish

/etc/shells/opt/homebrew/bin/fishを追記してデフォルトシェル変更

echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/fish

ターミナル再起動

zshに設定していたやつをfishにもおこなう

echo 'eval (/opt/homebrew/bin/brew shellenv)' >> ~/.config/fish/config.fish
echo 'set PATH "/opt/homebrew/bin:/usr/local/bin:$PATH"' >> ~/.config/fish/config.fish
N04hN04h

asdfいれる
https://asdf-vm.com

brew install asdf

ぱすとおす

echo -e "\nsource "(brew --prefix asdf)"/libexec/asdf.fish" >> ~/.config/fish/config.fish

nodejsいれてみる

asdf plugin add nodejs

installしようとしたらgpg必要っていうので入れて再度

brew install gpg
asdf install nodejs 16.13.0
asdf global nodejs 16.13.0

node -v
npm -v

できた

N04hN04h

Starshipのインストール

brew install starship
echo -e "\nstarship init fish | source" >> ~/.config/fish/config.fish
N04hN04h

GitHub CLI で GitHub にログイン

brew install gh
gh auth login

GPG設定

brew install gpg pinentry-mac
N04hN04h

Javaの環境構築

asdf plugin add java
asdf lista all java | grep 17
asdf install java openjdk-17.0.1
asdf global java openjdk-17.0.1
N04hN04h

yarnいれる

asdf plugin-add yarn
asdf list-all yarn
asdf install yarn 1.22.17
asdf global yarn 1.22.17
N04hN04h

コマンドパレット(Command + Shift + P)でpathと入れてVSCodeのシェルコマンドのパスを通す

N04hN04h

GitHubにSSHできるようにする

ssh-keygen -t ed25519 -C "youremail@example.com" // GitHubのemailを設定

// Enter file in which to save the key ... は githubを設定

vi ~/.ssh/config // 以下設定
~/.ssh/config
Host github github.com
  HostName github.com
  IdentityFile ~/.ssh/github
  User git
ssh git@github.com

以下出力されれば問題ないかな?

PTY allocation request failed on channel 0
Hi n04h! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
N04hN04h

Google Cloud SDK を Homebrew を使って入れる

brew install google-cloud-sdk
N04hN04h

Flutter

Apple Silicon 用のSDKをダウンロードして以下

cd ~
mkdir development
cd development
unzip ~/Downloads/flutter_macos_arm64_3.3.10-stable.zip

# fish使ってるので以下
set -U fish_user_paths $fish_user_paths $HOME/development/flutter/bin

# 使えるかチェック
flutter --version

# どくたー
flutter doctor

以下ダメ出しされた

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch

Android toolchain については以下記事で対応できた
https://qiita.com/rikupo/items/5999a67cd6b4806830ea

あとはライセンスに同意

flutter doctor --android-licenses

Xcode は記載されているコマンドを実行したらなおた

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Flutter SDK のバージョン管理をする asdf の plugin を入れる

asdf plugin-add flutter
asdf list all flutter
asdf install flutter 3.7.0-stable
asdf local flutter 3.7.0-stable

Dartもやるべきなのかな?とりあえず保留

N04hN04h

https://github.com/jdx/mise
asdfのRust版が出たらしいので移行してみる
asdfでできたプラグインのエコシステムをそのままつかえるとのこと

とりあえず今使っているやつのリスト確認

asdf list

fishのconfigからasdfを削除しておく

~/.config/fish/config.fish
source /opt/homebrew/opt/asdf/libexec/asdf.fish

Homebrewでインストール

brew install mise

fishのconfigに以下追記

~/.config/fish/config.fish
mise activate fish | source
mise hook-env -s fish | source  # プラグインのパスを追加する
mise complete -s fish | source

これでシェルをリロードしてみると、globalに設定していたやつないよと警告が出たので、
以下実行してみる

mise i # install の alias

これでとりあえずglobalなやつはインストールできた

さよならasdf👋

brew uninstall asdf

追記

rubyの最新版がなかったが、プラグインを更新することで解決

mise plugins update ruby
N04hN04h

ruby入れる時

To eliminate this warning, please install libyaml and reinstall your ruby.

とエラーになったので

brew install libyaml

実行して再インストールしたらできた

N04hN04h

AWS CLI v2 を brewで入れる

brew install awscli

Session ManagerのPluginもbrewで

brew install --cask session-manager-plugin
N04hN04h
❯ orb version
Version: 0.12.0 (120000)
Commit: 6e3826111e0aedbe7f5b3b8a1a12c969ba087ccd (v0.12.0)

❯ docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                    KUBERNETES ENDPOINT   ORCHESTRATOR
default             moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
desktop-linux *     moby                Docker Desktop                            unix:///Users/<username>/.docker/run/docker.sock

contextふえてない
helpみたらorbとそのまま打てるコマンドがあるみたいなので実行したらウィンドウ開いて
Dockerの選択肢を押したらダッシュボード出てきた

かわってた

❯ docker context ls
NAME            DESCRIPTION                               DOCKER ENDPOINT                                      ERROR
default         Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
desktop-linux   Docker Desktop                            unix:///Users/<username>/.docker/run/docker.sock
orbstack *      OrbStack                                  unix:///Users/<username>/.orbstack/run/docker.sock
このスクラップは2021/11/12にクローズされました