notebook

都内でWEB系エンジニアやってます。

miseを導入した

長らく開発時の環境、特に言語のバージョンの切り替えにanyenvを使っていた

が、利用するツールとかのバージョンもやはり管理したいよなーということでmiseに乗り換えた(乗り換え前はAnsibleで管理していた)

他の選択肢としてasdfも出ていたが後発でよさそうと評判のmiseにした

インストール

Getting Started | mise-en-place

GitHub Releasesからバイナリ落とすだけでOK

シェルスクリプトをcurl+shでインストールする方法もある

❯ curl -L https://github.com/jdx/mise/releases/download/v2024.1.0/mise-v2024.1.0-linux-x64 > mise  
❯ sudo mv mise /usr/local/bin  
❯ sudo chmod +x /usr/local/bin/mise  
❯ mise --version  
correct: mise -> nice ? [n,y,a,e] n  
2024.1.0 linux-x64 (0d0d930 2024-01-02)

グローバルの設定

~/.config/mise/config.toml

に色々書く

各種使うツールを記述してmise iするとすべてインストールしてくれるよう

試しに

[tools]
node = '20.18.0'

で実行

❯ mise i  
mise node@20.18.0 ✓ installed

使えた

楽すぎる

ツールのインストール

mise install gcloud  
######################################################################## 100.0%  
Your current Google Cloud CLI version is: 499.0.0  
The latest available version is: 499.0.0  
To install or remove components at your current SDK version [499.0.0], run:  
$ gcloud components install COMPONENT_ID  
$ gcloud components remove COMPONENT_ID  
To update your SDK installation to the latest version [499.0.0], run:  
$ gcloud components update  
==> Source [/home/sawafuji/.local/share/mise/installs/gcloud/499.0.0/completion.zsh.inc] in your profile to enable shell command completion for gcloud.  
==> Source [/home/sawafuji/.local/share/mise/installs/gcloud/499.0.0/path.zsh.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.  
mise: could not initialize logger: attempted to set a logger after the logging system was already initialized  
mise gcloud@499.0.0 ℹ️ Check by Default SDK Components at /home/sawafuji/.default-cloud-sdk-components ⠒ 13  
mise gcloud@499.0.0 ✓ ℹ️ Check by Default SDK Components at /home/sawafuji/.default-cloud-sdk-components  
mise gcloud@499.0.0 ✓ installed

よく使うgcloudコマンドもさくっと

mise install awscli  
⚠️ awscli is a community-developed plugin: https://github.com/MetricMike/asdf-awscli  
Would you like to install awscli? Yes  
mise plugin:awscli ✓ https://github.com/MetricMike/asdf-awscli.git#c26bbb4  
mise awscli@2.18.18 ✓ installed

思ったより楽すぎる…

ツールの数が増えてきたときなど、-jオプションでインストール処理の並列実行数も指定できる

$(cat /proc/cpuinfo | grep processor | wc -l)でプロセッサ数を取ってくれば効率よくインストール処理を進められる

利用可能なプラグイン一覧

mise/registry.toml at main · jdx/mise

miseは設定可能なツールのリストをこのファイルで管理している

対応状況もこのファイルを見に行けば分かる

ただ、mise自体の更新頻度が高く、バージョンが上がって使えるようになったみたいなパターンも存在するので自分が使っているバージョンとの差分は都度確認した方が良い

outdated

mise outdated | mise-en-place

この最新バージョンがなにで、今はこれでっていうの自前でやろうとするとツールごとに微妙に規則が異なっていて面倒だった…

こういうのも出してくれる、すごい

バージョンマネージャー側が吸収してくれるので使いやすい

❯ mise list  
Plugin Version Config Source Requested  
awscli 2.18.18 (outdated) ~/.config/mise/config.toml latest  
bat 0.24.0 ~/.config/mise/config.toml 0.24.0  
delta 0.18.2 ~/.config/mise/config.toml 0.18.2  
deno 2.0.3 ~/.config/mise/config.toml latest  
gcloud 499.0.0 ~/.config/mise/config.toml latest  
jq 1.7.1 ~/.config/mise/config.toml 1.7.1  
node 20.18.0 ~/.config/mise/config.toml 20.18.0  
terraform 1.7.1 ~/.config/mise/config.toml 1.7.1

outdatedだけ出力するコマンド

❯ mise outdated  
Tool Requested Current Latest  
awscli latest 2.18.18 2.19.0

更新する際は下記でOK

mise upgrade

JSONでも出力可能なので何かシェルで操作したいときなどにも利用できる

というかRenovateがmise.tomlに対応しているのでバージョンの更新はRenovateに任せるだけで良い

利用ツールの更新以外で何かしたいとかそういうケースがあればつかえる

$ mise outdated --json
{"python": {"requested": "3.11", "current": "3.11.0", "latest": "3.11.1"}, ...}

ただ、これはあくまでRequestedと差分があるかをチェックするものっぽい

最新バージョンとの比較

--bumpオプションで最新バージョンとの差異が確認できる

[dotfiles]$ mise outdated --bump
name       requested  current  latest source
node       18.17.0    18.17.0  23.1.0 ~/dotfiles/.node-version
awscli     2.18.18    2.18.18  2.19.1 ~/.config/mise/config.toml
terraform  1.7.1      1.7.1    1.9.8  ~/.config/mise/config.toml

更新

$ mise upgrade --bump
mise awscli@2.19.1 ✓ installed
mise node@23.1.0 ✓ installed
mise terraform@1.9.8 ✓ installed
.....
.....
.....

configの更新

mise config set | mise-en-place

mise config setで更新できそう

ただこれを使う場合各種設定は.mise.config.tomlを読むということになるので、.tool-versionや各種言語用の.ruby-version,.node-versionなどのバージョンファイルでのバージョン管理が行えなくなるので慎重に決めたいところ

おわり

とりあえず一通りの使い方把握のため試してみた

所感として

  • 早い、シェルの起動時など、以前と比べて体感だが反応がかなり早くなった
  • 管理が楽
    • tomlファイルに書くだけでOKなので楽
    • かなりの数のツールに対応している
      • 裏側でasdfやubiなどのツールを使って各platformの互換性をたもっているよう
    • Renovateが対応している
      • とりあえずDotfilesにmise.config.tomlを入れてRenovate走らせておけば各ツールや言語のバージョン更新をトリガーにPRが作られるので気付きやすい

とりあえず、自分は今までAnsibleでやっていた開発で使うツールの管理はmiseに移した