Open6
asdf から mise へ移行したときのメモ

以前、anyenv から asdf に移行した。特段困ってはいないが類似ツールの mise (rtx) が早いとのことで移行してみることに

前提条件
$ sw_vers
ProductName: macOS
ProductVersion: 14.1.2
BuildVersion: 23B92
homebrew で asdf をインストールしている状態。シェルは zsh を使っている。

asdf のアンインストール
$ brew uninstall asdf
インストール時に追加した以下記載を削除
~/.zshrc
. /opt/homebrew/opt/asdf/libexec/asdf.sh
シェルを再起動しつつ、
$ exec $SHELL -l
アンインストールされていることを確認
$ which asdf
asdf not found
設定ファイルを削除
$ rm -f ~/.asdfrc
ホームに .asdf
ディレクトリがあるのでこれも削除しておく
$ rm -rf ~/.asdf
これで概ね良さそう。

mise のインストール
homebrew 対応してる。
$ brew install mise
$ echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
最下部に追加されるが、fig 使ってる場合はこの位置関係にしておいた方が良さそう
~/.zshrc
eval "$(~/.local/bin/mise activate zsh)"
# Fig post block. Keep at the bottom of this file.
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"
おや...
$ source ~/.zshrc
/Users/t3yamoto/.zshrc:82: no such file or directory: /Users/t3yamoto/.local/bin/mise
こっちが正しいっぽい?
$ echo 'eval "$(mise activate zsh)"' >> "${ZDOTDIR-$HOME}/.zshrc"
こうなる
~/.zshrc
eval "$(mise activate zsh)"
# Fig post block. Keep at the bottom of this file.
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"
OK
$ source ~/.zshrc

使ってみる
任意のディレクトリで、以下を実行すると Node.js 20 の最新版をローカルで使うようになる。
asdf と違って、plugin は不要
$ mise use node@20
$ node -v
v20.11.0
カレントディレクトリに設定ファイルが生成される
.mise.toml
[tools]
node = "20"
-g
オプションでグローバルで使うようにする。
$ mise use -g node@20
既存プロジェクトに .node-version
や .tool-versions
がある場合、mise install
すればOK
移行してから気がついたが、fig はまだ対応していない... やるか
Direnv の代替にもなるらしいが、また後で

mise plugins ls-remote
で mise を使ってインストール可能なツール一覧を出力