Macを買った

ここから好みのやつだけやった

Chromeをインストールした

Homebrewを入れた、xcodeのcommand-line-tools必要かと思ったけど、brewのコマンドの方で担保してくれていた
コマンド入力
% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Password入力
==> Checking for `sudo` access (which may request your password)...
Password:
出力確認
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> The following new directories will be created:
/opt/homebrew/bin
/opt/homebrew/etc
/opt/homebrew/include
/opt/homebrew/lib
/opt/homebrew/sbin
/opt/homebrew/share
/opt/homebrew/var
/opt/homebrew/opt
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/var/homebrew
/opt/homebrew/var/homebrew/linked
/opt/homebrew/Cellar
/opt/homebrew/Caskroom
/opt/homebrew/Frameworks
Xcode入れるよ〜と言われるのでEnterで同意する
==> The Xcode Command Line Tools will be installed.
Press RETURN/ENTER to continue or any other key to abort:
Xcode無事にインストール
Downloading Command Line Tools for Xcode
Downloaded Command Line Tools for Xcode
Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
Done.
...
Homebrew無事にインストール
==> Downloading and installing Homebrew...
...
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
==> Installation successful!
...
パスを通してねと言われる
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/ユーザーネーム/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
言われた通りパスを通す
% (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/ユーザーネーム/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
パスが通っていることを確認
% cat /Users/ユーザーネーム/.zprofile
シェルを再起動
% exec $SHELL -l
Homebrewのversion確認、リリースノートを見て最新版かどうか確認する
% brew -v
一応xcode-selectもversion確認、xcode-select version 2397.
みたいな感じで返ってくるけど何と照らし合わせると最新と言えるか不明
% xcode-select -v

git を入れる
$ git --version
で確認すると
git version 2.39.2 (Apple Git-143)
という感じで返ってくるはずだが、これはプリインストールされているものになるのでHomebrewでの管理に切り替えたい
$ brew install git
こんな感じで返ってくる
...
zsh completions and functions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/git/2.44.0: 1,649 files, 50.8MB
==> Running `brew cleanup git`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> git
The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
Subversion interoperability (git-svn) is now in the `git-svn` formula.
zsh completions and functions have been installed to:
/opt/homebrew/share/zsh/site-functions
シェルを再起動する
% exec $SHELL -l
% git --version
で
git version 2.44.0
という感じで最新のgitがインストールできていて、末尾に(Apple Git-1 43)
とかがついてなきゃOK
最新かどうかはダウンロードページとかから見ればOK

キーの反応を爆速にできるらしい?
% defaults write -g InitialKeyRepeat -int 10
% defaults write -g KeyRepeat -int 1

Raycastをbrew経由でいれる
% brew install --cask raycast
==> Downloading https://formulae.brew.sh/api/cask.jws.json
==> Downloading https://releases.raycast.com/releases/1.69.0/download?build=universal
==> Downloading from https://d3jdrrl94b667u.cloudfront.net/Raycast_v1.69.0_abfa3ad4e7edf8929d201f5eb3b533bd2d639972_universal.dmg?response-content-disposition=attachment%3B%20filename%3DRaycast.dmg&Expires=1709979654&Signature=PDQAVC8kEwAfD15yMjCL10BfHio-GD5zQMGBhwNHHd7Ij
######################################################################################################################################################################################################################################################### 100.0%
==> Installing Cask raycast
==> Moving App 'Raycast.app' to '/Applications/Raycast.app'
🍺 raycast was successfully installed!

warpをbrew経由で入れる
% brew install --cask warp
...
==> Installing Cask warp
==> Moving App 'Warp.app' to '/Applications/Warp.app'
🍺 warp was successfully installed!

VSCodeを入れる
codeコマンドで開ける起動できるようにする

asdfを入れる
homebrewでも可能だが、公式がgitコマンドを使うことを押しているのでそっちでやる
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
.zshrc
に追記
. "$HOME/.asdf/asdf.sh"
一度warpを再起動
インストール確認、公式ページの最新版と一致していることを確認する
asdf --version

Rubyインストール
asdfでrubyのプラグインをインストール
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
brewでlibyamlをインストール
brew install libyaml
インストール可能なrubyのリストを確認
asdf list-all ruby
Rubyをインストールする
asdf install ruby 3.3.0
==> Downloading openssl-3.1.4.tar.gz...
-> curl -q -fL -o openssl-3.1.4.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14.8M 100 14.8M 0 0 18.1M 0 --:--:-- --:--:-- --:--:-- 18.1M
==> Installing openssl-3.1.4...
-> ./config "--prefix=$HOME/.asdf/installs/ruby/3.3.0/openssl" "--openssldir=$HOME/.asdf/installs/ruby/3.3.0/openssl/ssl" zlib-dynamic no-ssl3 shared
-> make -j 12
-> make install_sw install_ssldirs
==> Installed openssl-3.1.4 to /Users/shinoku/.asdf/installs/ruby/3.3.0
==> Downloading ruby-3.3.0.tar.gz...
-> curl -q -fL -o ruby-3.3.0.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.0M 100 21.0M 0 0 30.6M 0 --:--:-- --:--:-- --:--:-- 30.6M
==> Installing ruby-3.3.0...
ruby-build: using libyaml from homebrew
-> ./configure "--prefix=$HOME/.asdf/installs/ruby/3.3.0" "--with-openssl-dir=$HOME/.asdf/installs/ruby/3.3.0/openssl" --enable-shared --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-ext=openssl,psych,+
-> make -j 12
-> make install
==> Installed ruby-3.3.0 to /Users/ユーザー名/.asdf/installs/ruby/3.3.0
asdf: Warn: You have configured asdf to preserve downloaded files (with always_keep_download=yes or --keep-download). But
asdf: Warn: the current plugin (ruby) does not support that. Downloaded files will not be preserved.
インストール確認
ruby -v
# ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]
変わっていないのでパスを確認
which ruby
# /usr/bin/ruby
.zshrcに追記
export PATH="$HOME/.asdf/shims:$PATH"
パスを確認
which ruby
# /usr/bin/ruby
もう1回version確認
ruby -v
なんか怒られた
No version is set for command ruby
Consider adding one of the following versions in your config file at
ruby 3.3.0
.tool-versionsを作成して下記を追記
ruby 3.3.0
最後のversion確認!
ruby -v
できた!
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22]

postgresqlをbrew経由でローカルで使えるようにする
brew install postgresql@15
インストール確認
psql --version
パスが通っていないので~/.zshrc
に追記
export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"
~/.zshrc
を読み込み
source .zshrc
インストール確認
psql --version
psql (PostgreSQL) 15.6 (Homebrew)

PostgreSqlの起動・停止
起動
brew services start postgresql@15
停止
brew services stop postgresql@15

githubに必要な諸々の設定
デフォルトブランチをmainにする
git config --global init.defaultBranch main
アカウント設定
git config --global user.name XXXXXXX
git config --global user.email XXXXXX@gmail.com
github用のSSH鍵作成
ssh-keygen -t ed25519 -N "" -f ~/.ssh/github
~/.ssh/config
に記載
Host github.com
IdentityFile ~/.ssh/github
User git

Rails(API)を作成してgithubにpushする
ディレクトリ作成 & 移動
mkdir m2pro-setting
cd m2pro-setting/
bundle initする( + グローバルにインストールしたくない)
bundle config --local path vendor/bundle
bundle init
git initする( + vender/bundle配下はgit管理したくない)
git init
echo "vendor/bundle/" > .gitignore
一旦この状態でcommitしておく
git add .
git commit -m "bundle init"
GemfileのRailsのコメントアウトを外す
# frozen_string_literal: true
source "https://rubygems.org"
gem "rails"
一回installsする
bundle install
一旦この状態でcommitしておく
git add .
git commit -m "bundle install"
rails newする
bundle exec rails new . --api -d postgresql --skip-test
.gitignoreとGemfileのconflictは一旦overwriteを受け入れる
conflict .gitignore
Overwrite /Users/shinoku/work/m2pro-setting/.gitignore? (enter "h" for help) [Ynaqdhm] Y
conflict Gemfile
Overwrite /Users/shinoku/work/m2pro-setting/Gemfile? (enter "h" for help) [Ynaqdhm] Y
.gitignoreの一番下の行にもう一度追記する
vendor/bundle/
DB作成
bundle exec rails db:create
---
Created database 'm2pro_setting_development'
Created database 'm2pro_setting_test'
サーバー起動
bundle exec rails s
---
=> Booting Puma
=> Rails 7.1.3.2 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.3.0-p0) ("The Eagle of Durango")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 79227
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop
http://localhost:3000/ でRailsのスタートページを確認する
gitにpushする
git add .
git commit -m "rails new"
git remote add origin git@github.com:ユーザー名/m2pro-setting.git
git push origin main
無事にpush可能だった
https://github.com/DaisukeShinoku/m2pro-setting

nodejsも入れる
Rubyと同様にasdfのプラグインを利用する
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
インストール可能なnodejsを確認する
asdf list-all nodejs
nodejsの公式ページからLTS版を確認したところ20.11.1だったのでそちらをインストールする
asdf install nodejs 20.11.1
tool-versionsにnodejsも追記する
ruby 3.3.0
nodejs 20.11.1
バージョン確認
node -v
---
v20.11.1
パス確認
which node
---
/Users/shinoku/.asdf/shims/node