はじめに
hkob の雑記録の 173 回目は Ruby のインストールを rbenv から mise に移行しました。以下はその経緯です。
今年の 4 年のゼミナールで手始めに Rails の学習をしました。そこでは、Rails ガイドを使って学習しました。その時は最初の「Rails をはじめよう」について、私も一緒に Rails 8 を学びました。Rails 8 のガイドもかなり変わっていて、私も勉強になりました。ところで、学生の一人から、このガイドでは Ruby のインストールに rbenv でなくて mise を使っていますと言われました。調べてみると、これまでは rbenv でインストールしていたものが、Mise バージョンマネージャをインストールすると書かれています。学生曰く、rbenv だとシェルスクリプトの起動に時間がかかっていたのが、mise に切り替えたら非常に高速になって快適になるとのことでした。早速試してみたので、記録に残しておきます。
mise のインストール
Rails ガイドではシェルスクリプトでインストールしていますが、homebrew にすでに用意されているようなので、brew でインストールしました。
brew install mise
以下のコマンドで正しくインストールされたかを確認します。
mise doctor version: 2025.6.5 macos-arm64 (2025-06-16) activated: yes shims_on_path: no build_info: Target: aarch64-apple-darwin Features: DEFAULT, NATIVE_TLS, SELF_UPDATE Built: Mon, 16 Jun 2025 22:24:21 +0000 Rust Version: rustc 1.87.0 (17067e9ac 2025-05-09) (Homebrew) Profile: release shell: /usr/local/bin/fish fish, version 4.0.2 dirs: cache: ~/Library/Caches/mise config: ~/.config/mise data: ~/.local/share/mise shims: ~/.local/share/mise/shims state: ~/.local/state/mise config_files: ignored_config_files: (none) backends: aqua asdf cargo core dotnet gem go npm pipx spm ubi vfox plugins: toolset: path: ~/bin /opt/homebrew/opt/postgresql@16/bin /opt/homebrew/bin /opt/homebrew/sbin /Library/TeX/texbin /usr/local/bin /usr/local/sbin ~/.cargo/bin /opt/homebrew/opt/mise/bin /opt/homebrew/opt/postgresql@16/bin /usr/local/bin /System/Cryptexes/App/usr/bin /usr/bin /bin /usr/sbin /sbin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin /opt/X11/bin /Library/Apple/usr/bin /Library/TeX/texbin /Applications/Wireshark.app/Contents/MacOS /Applications/iTerm.app/Contents/Resources/utilities env_vars: MISE_SHELL=fish settings: No problems found
まだ PATH アクティベーションが設定されていないので、そのコマンドを設定します。私は fish を使っているので、対応しているか確認します。mise activate とすると、ちゃんと fish のコマンドが作成されています。問題なさそうです。これを確認した上で、.config/fish/config.fish にこれを読み込む仕組みを追加します。
mise activate
set -gx MISE_SHELL fish
set -gx __MISE_ORIG_PATH $PATH
function mise
if test (count $argv) -eq 0
command /opt/homebrew/opt/mise/bin/mise
return
end
set command $argv[1]
set -e argv[1]
if contains -- --help $argv
command /opt/homebrew/opt/mise/bin/mise "$command" $argv
return $status
end
switch "$command"
case deactivate shell sh
# if help is requested, don't eval
if contains -- -h $argv
command /opt/homebrew/opt/mise/bin/mise "$command" $argv
else if contains -- --help $argv
command /opt/homebrew/opt/mise/bin/mise "$command" $argv
else
source (command /opt/homebrew/opt/mise/bin/mise "$command" $argv |psub)
end
case '*'
command /opt/homebrew/opt/mise/bin/mise "$command" $argv
end
end
function __mise_env_eval --on-event fish_prompt --description 'Update mise environment when changing directories';
/opt/homebrew/opt/mise/bin/mise hook-env -s fish | source;
if test "$mise_fish_mode" != "disable_arrow";
function __mise_cd_hook --on-variable PWD --description 'Update mise environment when changing directories';
if test "$mise_fish_mode" = "eval_after_arrow";
set -g __mise_env_again 0;
else;
/opt/homebrew/opt/mise/bin/mise hook-env -s fish | source;
end;
end;
end;
end;
function __mise_env_eval_2 --on-event fish_preexec --description 'Update mise environment when changing directories';
if set -q __mise_env_again;
set -e __mise_env_again;
/opt/homebrew/opt/mise/bin/mise hook-env -s fish | source;
echo;
end;
functions --erase __mise_cd_hook;
end;
__mise_env_eval
if functions -q fish_command_not_found; and not functions -q __mise_fish_command_not_found
functions -e __mise_fish_command_not_found
functions -c fish_command_not_found __mise_fish_command_not_found
end
function fish_command_not_found
if string match -qrv -- '^(?:mise$|mise-)' $argv[1] &&
/opt/homebrew/opt/mise/bin/mise hook-not-found -s fish -- $argv[1]
/opt/homebrew/opt/mise/bin/mise hook-env -s fish | source
else if functions -q __mise_fish_command_not_found
__mise_fish_command_not_found $argv
else
__fish_default_command_not_found_handler $argv
end
end
コマンドは以下のようになります。
echo '/opt/homebrew/bin/mise activate fish | source' >> ~/.config/fish/config.fish
ruby 3.4.4 のインストール
mise use -g でグローバルにインストールができるようです。タブを使うとインストールできるものが絞れるようです。ここでは最新版の 3.4.4 を入れてみます。
mise use -g ruby@3.4 ruby@3.4.0 ruby@3.4.0-preview2 ruby@3.4.1 ruby@3.4.3 ruby@3.4-dev ruby@3.4.0-preview1 ruby@3.4.0-rc1 ruby@3.4.2 ruby@3.4.4
インストールしました。
mise use -g ruby@3.4.4
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22.1M 100 22.1M 0 0 26.0M 0 --:--:-- --:--:-- --:--:-- 26.0M
mise ruby@3.4.4 ✓ installed
mise ~/.config/mise/config.toml tools: ruby@3.4.4
ruby を確認すると .local/share/mise/installs/ruby/3.4.4/bin/ruby にインストールされました。
which ruby /Users/hkob/.local/share/mise/installs/ruby/3.4.4/bin/ruby
バージョンを確認すると 3.4.4 が正しくインストールされたようです。
ruby -v ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [arm64-darwin24]
おわりに
.config/fish/config.fish は mackup で同期しているので、1台を mise に変更したので、全てのマシンを mise に変更する必要があり、こちらの記事を記載しました。NotionRubyMapping の記事がさらに遅れてすみません。