Open10
miseを試してみる

miseについて
Like asdf (or nvm or pyenv but for any language) it manages dev tools like node, python, cmake, terraform, and hundreds more.
Like direnv it manages environment variables for different project directories.
Like make it manages tasks used to build and test projects.

miseのインストール
curl https://mise.run | sh
XDG_DATA_HOME
にglobal configが生える (e.g. ~/.config/mise/config.toml
)
- グローバルにインストールしたパッケージの情報とかはここみれば良さそう
- https://mise.jdx.dev/configuration.html#global-config-config-mise-config-toml

miseのセットアップ
mise activate
をシェル起動時に仕込んでおく
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc # bash
echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc # zsh
echo '~/.local/bin/mise activate fish | source' >> ~/.config/fish/config.fish # fish

シェル補完
mise completion bash > ~/.local/share/bash-completion/completions/mise # bash
mise completion zsh > /usr/local/share/zsh/site-functions/_mise # zsh
mise completion fish > ~/.config/fish/completions/mise.fish # fish
追加でUsageというツールが必要らしい。miseでインストールできる
mise plugin install usage
mise use -g usage
シェル補完でインストールしたいパッケージのバージョンを確認できたりする
> mise use node@
node@0.1.14 node@0.8.23 node@4.7.3 node@9.4.0 node@13.9.0 node@18.9.1
node@0.1.15 node@0.8.24 node@4.8.0 node@9.5.0 node@13.10.0 node@18.10.0
node@0.1.16 node@0.8.25 node@4.8.1 node@9.6.0 node@13.10.1 node@18.11.0

mise.toml
mise.toml
, mise/config.toml
, mise.local.toml
(バージョン管理から外す) などでプロジェクトごとの設定を作れる
[env]
NODE_ENV = 'production'
[tools]
terraform = '1.0.0'
erlang = '24.0'
[tasks.build]
run = 'echo "running build tasks"'

パッケージのインストール
mise.toml
からインストール
mise install
インストール可能なパッケージを検索
mise registry
インストール可能なバージョンを検索
mise ls-remote <パッケージ>
パッケージのインストール
mise use <パッケージ>
パッケージのアンインストール
mise unuse <パッケージ>

グローバルにインストール
~/.config/mise/config.toml
にグローバルインストールしたパッケージが記載される
mise use -g <パッケージ>

ツールを一時的に実行
mise x <パッケージ>
mise x <パッケージ> -- <arg> # ツールにコマンドライン引数を渡して実行
例
mise x python -- python

タスクを登録
Makefileみたいなことをmise.toml
で設定できる
[tasks.clean]
depends = ['cleancache']
run = "cargo clean" # runs as a shell command
[tasks.build]
description = 'Build the CLI'
run = "cargo build"
alias = 'b' # `mise run b`
[tasks.test]
description = 'Run automated tests'
# multiple commands are run in series
run = [
'cargo test',
'./scripts/test-e2e.sh',
]
dir = "{{cwd}}" # run in user's cwd, default is the project's base directory
[tasks.lint]
description = 'Lint with clippy'
env = { RUST_BACKTRACE = '1' } # env vars for the script
# you can specify a multiline script instead of individual commands
run = """
#!/usr/bin/env bash
cargo clippy
"""
[tasks.ci] # only dependencies to be run
description = 'Run CI tasks'
depends = ['build', 'lint', 'test']
タスクの実行
mise run build

Hook
特定のイベントで自動実行するコマンドを登録できる
[hooks]
preinstall = "echo 'I am about to install tools'"
postinstall = "echo 'I just installed tools'"