1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

miseをためす①よく使うツールをmise管理にする。 dotfilesが捗る

Last updated at Posted at 2025-07-12

はじめに

この記事を読んでmiseを自分も使ってみたいなと思ったので使ってみることにした。

miseを使うとCLIでの操作が捗るのでメモ書き的を記事にした。

今回はmiseの概要とmiseを使ったバージョン管理の概要を説明する。

miseはどんな人に特におすすめか

  • 仮想環境やサーバなどをよく使う人
  • 業務と自宅PCが異なる人
  • (PCの買い替えを検討している人)

このような方はおそらくGitHubに自分用dotfilesを作って設定を共通化していると思うが、miseを使うとより捗ると思う。

例: 自分のdotfiles


miseとは

miseの記事第一回なのでmiseの概要にも触れておく。

What is it?
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.1

asdfとdirenvとmakeを合体させたツールらしい。
つまり、CLI最強のツールってわけだ。

補足、asdf、direnv、makeについて

asdf

run timeのバージョンマネージャー

asdf is a tool version manager. All tool version definitions are contained within one file (.tool-versions) which you can check in to your project's Git repository to share with your team, ensuring everyone is using the exact same versions of tools.2

ツールの管理ができるだけでなく、ディレクトリごとに設定した.tool-versionsに記載のバージョンを読み取ってバージョンを切り替えてくれるのが嬉しいイメージ。

# デフォルトは python 3.10.0
$ asdf global python 3.10.0

$ python --version
Python 3.10.0

# プロジェクトディレクトリに .tool-versions を作成
$ mkdir myproj && cd myproj
$ echo "python 3.12.1" > .tool-versions

# ここに入ると、自動で 3.12.1 に切り替わる
$ python --version
Python 3.12.1

# 親ディレクトリに戻るとまた 3.10.0 に戻る
$ cd ..
$ python --version
Python 3.10.0

direnv

direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory3.

ディレクトリごとに.envrcを設定しておくことでカレントディレクトリを切り替えると環境変数の切り替えができるらしい。

make

make

The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them.4

makeはみんな知っていると思うので省略。


miseをinstall

curl https://mise.run | sh

~/.zshrcに以下を追加する。

# mise
if [ -s ${HOME}/.local/bin/mise ]; then
  eval "$(${HOME}/.local/bin/mise activate zsh)"
fi

miseでパッケージ管理を行う

ツールの追加方法

  • mise use <ツール名>: 基本これで良さそう
    • ツールがinstall済みでないなら入れる。
    • .config/mise/mise.tomlにツールを追加
    • バージョンを指定することでバージョンの切り替えができる
mise use jq
mise use gh
# 一覧表示
mise list
Tool    Version  Source                               Requested 
gh      2.75.0   ~/dotfiles/.config/mise/config.toml  latest
jq      1.8.1    ~/dotfiles/.config/mise/config.toml  latest 
mise use node@24
node -v
v24.4.0
# バージョンを切り替える
mise use node@22
node -v
v22.17.0
mise list | grep node
Tool    Version  Source                      Requested 
node    22.17.0 
node    24.4.0   ~/.config/mise/config.toml  latest

mise installも存在するが、あまりつかうことはなさそう

mise install will install but not activate tools—meaning it will download/build/compile the tool into ~/.local/share/mise/installs but you won't be able to use it without "setting" the version in a .mise-toml or .tool-versions file.

  • installのみを行い、~/.local/share/mise/installs/配下に保存する
  • Active状態でないのでPATHは通っていない
  • mise-tomlもしくは.tool-versions fileがあればmiseが使用するバージョンを認識できるためPATHが通る。
  • mise list: installされているものの一覧が見れる。アクティブなツールにはソースファイルが表示される。
# node 24.4.0がアクティブ
mise list | grep node
node    22.17.0
node    24.4.0   ~/archive/test/.tool-versions  24.4.0

dotfilesでよく使うツールをmise管理にする

個人的にいいなと思っているのは、mise installnpm installのように~/.config/mise/mise.tomlに記載のあるツールを一括インストールできる点。

dotfilesでmiseの設定ファイルである~/.conig/mise/mise.tomlを管理しておけば主要なツールのバージョンも含めて管理ができるため、環境の再現が容易である。

mise install

そのため、自分はシンボリックリンクを貼って、miseの設定ファイルをdotfilesで管理している。
以下はシンボリックリンク作成スクリプト。

mise_conf=~/.config/mise/config.toml
mise_src=~/dotfiles/.config/mise/config.toml

if [ ! -e "$mise_conf" ]; then
  mkdir -p "$(dirname "$mise_conf")"
  echo "=====CREATE SYMBOLIC LINKS $mise_src --> $mise_conf====="
  ln -s "$mise_src" "$mise_conf"
fi

versionをディレクトリ単位で切り替えてみる

.tools-versionsファイルを作成して置くだけで切り替わる。asdfと同じようなことができた。

.tools-versions
node 24.4.0
node -v
v22.17.0

# .tool-versionsでnode24系を指定したディレクトリに移動する
cd node24
cat .tool-versions
node 24.4.0
node -v
v24.4.0

ちなみに、ローカルに落としていないバージョンを.tool-versionsに記載すると自動インストールはされず、バージョンは直前に使っていたものになる。

cat .tool-versions 
node 23.4.0

node -v
v24.4.0 # 直前に使っていたバージョン
mise list         
Tool    Version           Source                         Requested          
node    22.17.0          
node    23.4.0 (missing)  ~/archive/test/.tool-versions  23.4.0
node    24.4.0

miseですべてのツールの管理ができるか

miseはいくつかの既存のバージョン管理ツールを使用してツールのインストールを行っているらしい。

mise registryコマンドを使うと調べられる

mise registry                                            1
Tool                          Backends                                       
1password                     aqua:1password/cli...
1password-cli                 aqua:1password/cli...
aapt2                         asdf:mise-plugins/mise-aapt2
act                           aqua:nektos/act ubi:nektos/act...
action-validator              aqua:mpalmer/action-validator...
actionlint                    aqua:rhysd/actionlint ubi:rhysd/actionlint...
adr-tools                     aqua:npryce/adr-tools...
ag                            asdf:mise-plugins/mise-ag
age                           aqua:FiloSottile/age asdf:threkk/asdf-age
age-plugin-yubikey            ubi:str4d/age-plugin-yubikey...
agebox                        ubi:slok/agebox asdf:slok/asdf-agebox
# バックエンドで使用しているツールで出力を絞る例
mise registry | grep aqua
mise registry | grep ubi
mise registry | grep pipx
mise registry | grep npm
mise registry | grep vfox
mise registry | grep asdf
mise registry | grep go
mise registry | grep cargo
mise registry | grep dotnet

逆にいうとここに入っていないものはaptなどでインストールしたほうがよさそう。


次回

miseのタスクランナーを試す。


Reference

  1. https://github.com/jdx/mise

  2. https://asdf-vm.com/guide/introduction.html

  3. https://github.com/direnv/direnv

  4. https://www.gnu.org/software/make/manual/make.html

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?