Linux Mint で mise を使う

OS のインストールが済んだら次はツール、というかプログラミング言語のインストールだ。よく使う Python や Ruby なんかをインストールする。

で、今までは pyenv とか rbenv を使ってたんだけど、最近見つけた mise (ミース)を使ってみようと思った。

mise は Rust 製のツールなので、まずは Rust をインストールする。公式サイトの手順に従えばいい。rustup という Rust のツールチェインを管理するツールをまずインストールする。

takatoh@apostrophe:~$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  
info: downloading installer  
  
Welcome to Rust!  
  
This will download and install the official compiler for the Rust  
programming language, and its package manager, Cargo.  
  
Rustup metadata and toolchains will be installed into the Rustup  
home directory, located at:  
  
  /home/takatoh/.rustup  
  
This can be modified with the RUSTUP_HOME environment variable.  
  
The Cargo home directory is located at:  
  
  /home/takatoh/.cargo  
  
This can be modified with the CARGO_HOME environment variable.  
  
The cargo, rustc, rustup and other commands will be added to  
Cargo's bin directory, located at:  
  
  /home/takatoh/.cargo/bin  
  
This path will then be added to your PATH environment variable by  
modifying the profile files located at:  
  
  /home/takatoh/.profile  
  /home/takatoh/.bashrc  
  
You can uninstall at any time with rustup self uninstall and  
these changes will be reverted.  
  
Current installation options:  
  
  
   default host triple: x86_64-unknown-linux-gnu  
     default toolchain: stable (default)  
               profile: default  
  modify PATH variable: yes  
  
1) Proceed with standard installation (default - just press enter)  
2) Customize installation  
3) Cancel installation  
>  
  
info: profile set to 'default'  
info: default host triple is x86_64-unknown-linux-gnu  
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'  
info: latest update on 2024-09-05, rust version 1.81.0 (eeb90cda1 2024-09-04)  
info: downloading component 'cargo'  
info: downloading component 'clippy'  
info: downloading component 'rust-docs'  
info: downloading component 'rust-std'  
info: downloading component 'rustc'  
info: downloading component 'rustfmt'  
info: installing component 'cargo'  
info: installing component 'clippy'  
info: installing component 'rust-docs'  
 15.9 MiB /  15.9 MiB (100 %)  10.1 MiB/s in  1s ETA:  0s  
info: installing component 'rust-std'  
 26.8 MiB /  26.8 MiB (100 %)  13.5 MiB/s in  2s ETA:  0s  
info: installing component 'rustc'  
 66.9 MiB /  66.9 MiB (100 %)  14.7 MiB/s in  4s ETA:  0s  
info: installing component 'rustfmt'  
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'  
  
  stable-x86_64-unknown-linux-gnu installed - rustc 1.81.0 (eeb90cda1 2024-09-04)  
  
  
Rust is installed now. Great!  
  
To get started you may need to restart your current shell.  
This would reload your PATH environment variable to include  
Cargo's bin directory ($HOME/.cargo/bin).  
  
To configure your current shell, you need to source  
the corresponding env file under $HOME/.cargo.  
  
This is usually done by running one of the following (note the leading DOT):  
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh  
source "$HOME/.cargo/env.fish"  # For fish

Rust に関するツールはすべて ~/.cargo/bin にインストールされる。一旦シェルを終了して起動し直すと(あるいは新しいシェルを起動すると)、cargo コマンドが使えるようになる。

takatoh@apostrophe:~$ cargo --version  
cargo 1.81.0 (2dbb1af80 2024-08-20)

rustup show コマンドでツールチェインを確認できる。

takatoh@apostrophe:~$ rustup show  
Default host: x86_64-unknown-linux-gnu  
rustup home:  /home/takatoh/.rustup  
  
stable-x86_64-unknown-linux-gnu (default)  
rustc 1.81.0 (eeb90cda1 2024-09-04)

mise のインストールには、mise の公式ドキュメントに従ってインストール用のシェルスクリプトを使う。

takatoh@apostrophe:~$ curl https://mise.run | sh  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current  
                                 Dload  Upload   Total   Spent    Left  Speed  
100  6300  100  6300    0     0  50786      0 --:--:-- --:--:-- --:--:-- 50806  
mise: installing mise...  
######################################################################## 100.0%  
mise: installed successfully to /home/takatoh/.local/bin/mise  
mise: run the following to activate mise in your shell:  
echo "eval \"\$(/home/takatoh/.local/bin/mise activate bash)\"" >> ~/.bashrc  
  
mise: this must be run in order to use mise in the terminal  
mise: run `mise doctor` to verify this is setup correctly

これでインストールできた。

takatoh@apostrophe:~$ ~/.local/bin/mise --version  
2024.9.5 linux-x64 (1f0f03e 2024-09-17)

インストールはできたが、アクティベートする必要がある。そのためのコードを .bashrc ファイルに書き込む。

takatoh@apostrophe:~$ echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc

それから環境変数 PATH の設定……なのだけど、アクティベートすると設定しくれるらしい。もう一度シェルを起動し直す。

takatoh@apostrophe:~$ mise --version  
2024.9.5 linux-x64 (1f0f03e 2024-09-17)

上の通り、フルパスを指定しなくても mise コマンドが使える。

さて、ここまで来たらプログラミング言語のインストールができる。ドキュメントに従って mise use コマンドで Node.js をインストールしてみる。

takatoh@apostrophe:~$ mise use node@20  
mise node@20.17.0 ✓ installed                                                   mise ~/.mise.toml tools: node@20.17.0  
takatoh@apostrophe:~$ node --version  
v20.17.0

うまく行った!

つぎは Python。

takatoh@apostrophe:~$ mise use python@3.11  
mise hint use multiple versions simultaneously with mise use python@3.12 python@3.11  
mise hint disable this hint with mise settings set disable_hints python_multi or all with mise settings set disable_hints "*"  
mise hint installing precompiled python from indygreg/python-build-standalone  
if you experience issues with this python (e.g.: running poetry), switch to python-build by running mise settings set python_compile 1  
mise hint disable this hint with mise settings set disable_hints python_precompiled or all with mise settings set disable_hints "*"  
mise python@3.11.10 ✓ installed                                                 mise ~/.mise.toml tools: python@3.11.10  
takatoh@apostrophe:~$ python --version  
Python 3.11.10

Ruby はどうか。

takatoh@apostrophe:~$ mise use ruby@3.2  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current  
                                 Dload  Upload   Total   Spent    Left  Speed  
100 14.6M  100 14.6M    0     0  75.4M      0 --:--:-- --:--:-- --:--:-- 75.6M  
BUILD FAILED (Linuxmint 22 on x86_64 using ruby-build 20240917)  
You can inspect the build directory at /tmp/ruby-build.20240918205818.20859.tDse9P  
See the full build log at /tmp/ruby-build.20240918205818.20859.log  
mise ~/.cache/mise/ruby/ruby-build/bin/ruby-build failed  
==> Downloading openssl-3.0.15.tar.gz...  
-> curl -q -fL -o openssl-3.0.15.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/23c666d0edf20f14249b3d8f0368acaee9ab585b09e1de82107c66e1f3ec9533  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current  
                                 Dload  Upload   Total   Spent    Left  Speed  
100 14.6M  100 14.6M    0     0  75.4M      0 --:--:-- --:--:-- --:--:-- 75.6M  
==> Installing openssl-3.0.15...  
-> ./config "--prefix=$HOME/.local/share/mise/installs/ruby/3.2.5/openssl" "--openssldir=$HOME/.local/share/mise/installs/ruby/3.2.5/openssl/ssl" zlib-dynamic no-ssl3 shared  
-> make -j 6  
  
BUILD FAILED (Linuxmint 22 on x86_64 using ruby-build 20240917)  
  
You can inspect the build directory at /tmp/ruby-build.20240918205818.20859.tDse9P  
See the full build log at /tmp/ruby-build.20240918205818.20859.log  
mise ~/.cache/mise/ruby/ruby-build/bin/ruby-build exited with non-zero status: exit code 1  
mise Run with --verbose or MISE_VERBOSE=1 for more information

あれ、なんか失敗したぞ?

でも ruby コマンドは使える。どういうこと?

takatoh@apostrophe:~$ ruby --version  
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux-gnu]

というわけで、今日はここまで。

[追記]

rubymise でインストールされたものじゃなく、もとから入ってるものだった。

takatoh@apostrophe:~$ which ruby  
/usr/bin/ruby

これに対して、mise でインストールされた pythonnode は ~/.local/share/mise/installs/ 以下にある。

takatoh@apostrophe:~$ which python  
/home/takatoh/.local/share/mise/installs/python/3.11/bin/python  
takatoh@apostrophe:~$ which node  
/home/takatoh/.local/share/mise/installs/node/20/bin/node