3
0

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 を使って Elixir の Mix コマンドを自動で実行する

Posted at

はじめに

以前、asdf-elixirdefault-mix-commands 機能を使って、Elixir インストール直後に mix コマンドを自動実行する方法を書きました。

最近は asdf の代わりに mise を使うことが多いのですが、mise コアの Elixir サポートには default-mix-commands がありません(2025-11 時点)。

本記事では、asdf 互換プラグインを利用して、mise でも同じ体験を取り戻す方法をメモしておきます。

結論

結論は次の二つです。

  1. mise の Elixir コアツールの代わりに、mise-elixir プラグインを使う
  2. $HOME/.default-mix-commands に、自動で実行したい mix コマンドを列挙する

手順

1. mise-elixir プラグインを入れる

まずは mise に Elixir プラグインを追加します。

mise plugin install elixir https://github.com/mise-plugins/mise-elixir.git

これで mise コアの Elixir 実装ではなく、mise-elixir プラグイン経由で Elixir が管理されるようになります。

2. .default-mix-commands を用意する

ホームディレクトリに .default-mix-commands ファイルを作り、Elixir インストール直後に自動で実行してほしい mix コマンドを 1 行ずつ書きます。

$HOME/.default-mix-commands
local.hex
local.rebar
archive.install hex phx_new
archive.install hex nerves_bootstrap

mise install elixir ... で新しいバージョンを入れるたびに、このファイルに書かれたコマンドが順番に実行されます。

各コマンドには自動的に --force が付き、対話なしで処理が進みます。

Phoenix や Nerves をよく触る場合は、上記のような設定にしておくと、環境構築のたびに同じ mix を叩かずに済みます。

おわりに

mise 単体でも Elixir のバージョン管理は十分快適ですが、default-mix-commands があると「Elixir を入れたらすぐ使える」という状態を作れて、さらに楽になります。

  • asdf から mise に移行したけれど、default-mix-commands がなくて不便に感じていた方
  • Phoenix や Nerves のプロジェクトを頻繁に立ち上げる方

といった方には、mise-elixir プラグインを試してみる価値があると思います。

3
0
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?