miseがPythonのアップグレードに失敗する

2024年12月30日
4 分

mise で Python (3.12系)の最新版 3.12.8 にアップグレードしようとしたところ、失敗した。

takatoh@apostrophe:~$ mise update python@3.12  
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 failed to extract tar: ~/.local/share/mise/downloads/python/3.12.8/cpython-3.12.8+20241219-x86_64-unknown-linux-gnu-pgo+lto-full.tar.zst to ~/.local/share/mise/downloads/python/3.12.8  
mise failed to iterate over archive  
mise invalid gzip header  
mise Run with --verbose or MISE_VERBOSE=1 for more information

Ruby や Go、Node.js は問題なくできたのに。

ちなみに、mise update python@3.12 する前のバージョン状態はこう。

takatoh@apostrophe:~$ mise ls  
Tool    Version            Config Source Requested  
go      1.22.10            ~/.mise.toml  1.22       
node    20.17.0                                     
node    22.12.0            ~/.mise.toml  22         
python  3.11.10                                     
python  3.12.6 (outdated)  ~/.mise.toml  3.12       
ruby    3.2.5                                       
ruby    3.2.6              ~/.mise.toml  3.2

Python 3.12.6 が outdated になってる。これはより新しい 3.12.8 がリリースされてるからだろう。Python はすでに3.13系がリリースされてるし、Ruby や Go ももっと新しいバージョンがあるけど、ここでは脇に置く。

さて、エラーメッセージを見ると、cpython-3.12.8+20241219-x86_64-unknown-linux-gnu-pgo+lto-full.tar.zst というファイルをダウンロードしていることがわかる。でもってこれを gzip で解凍しようとして失敗している。

.zst という拡張子は ZStandard という圧縮形式だ。はじめはこのコマンドかライブラリがインストールされていないのかと考えたけど、 apt install zstdapt install libzstd1 を実行しても、すでに最新版がインストールされているという結果になった。

ということは mise の問題か?

mise には doctor というサブコマンドがあって、問題があれば報告してくれる。mise help の出力から抜粋するとつぎのとおりだ。

takatoh@apostrophe:~$ mise help  
mise is a tool for managing runtime versions. https://github.com/jdx/mise  
(中略)  
  doctor       Check mise installation for possible problems [aliases: dr]  
(後略)

実行してみるとつぎのようになった。

takatoh@apostrophe:~$ mise doctor  
version: 2024.9.5 linux-x64 (1f0f03e 2024-09-17)  
activated: yes  
shims_on_path: no  
  
build_info:   
  Target: x86_64-unknown-linux-gnu  
  Features: DEFAULT, NATIVE_TLS, OPENSSL  
  Built: Tue, 17 Sep 2024 13:42:22 +0000  
  Rust Version: rustc 1.81.0 (eeb90cda1 2024-09-04)  
  Profile: release  
  
shell:   
  /bin/bash  
  GNU bash, バージョン 5.2.21(1)-release (x86_64-pc-linux-gnu)  
  Copyright (C) 2022 Free Software Foundation, Inc.  
  ライセンス GPLv3+: GNU GPL バージョン 3 またはそれ以降 <http://gnu.org/licenses/gpl.html>  
  
  This is free software; you are free to change and redistribute it.  
  There is NO WARRANTY, to the extent permitted by law.  
  
dirs:   
  data: ~/.local/share/mise  
  config: ~/.config/mise  
  cache: ~/.cache/mise  
  state: ~/.local/state/mise  
  shims: ~/.local/share/mise/shims  
  
config_files:   
  ~/.config/mise/config.toml  
  ~/.mise.toml  
  
backends:   
  cargo  
  core  
  go  
  npm  
  pipx  
  spm  
  ubi  
  vfox  
  
plugins:   
  
  
toolset:   
  node@22.12.0     
  go@1.22.10       
  ruby@3.2.6       
  python@3.12.6    
  
env_vars:   
  MISE_SHELL=bash  
  
settings:   
  activate_aggressive = false  
  all_compile = false  
  always_keep_download = false  
  always_keep_install = false  
  asdf = true  
  asdf_compat = false  
  cargo_binstall = true  
  color = true  
  disable_default_shorthands = false  
  disable_hints = []  
  disable_tools = []  
  experimental = false  
  go_default_packages_file = "~/.default-go-packages"  
  go_download_mirror = "https://dl.google.com/go"  
  go_repo = "https://github.com/golang/go"  
  go_set_gopath = false  
  go_set_goroot = true  
  go_skip_checksum = false  
  http_timeout = 30  
  jobs = 4  
  legacy_version_file = true  
  legacy_version_file_disable_tools = []  
  libgit2 = true  
  node_compile = false  
  not_found_auto_install = true  
  paranoid = false  
  pipx_uvx = false  
  plugin_autoupdate_last_check_duration = "7d"  
  python_default_packages_file = "~/.default-python-packages"  
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"  
  raw = false  
  trusted_config_paths = []  
  quiet = false  
  use_versions_host = true  
  verbose = false  
  vfox = false  
  yes = false  
  ci = false  
  debug = false  
  trace = false  
  log_level = "info"  
  python_venv_auto_create = false  
  
  [status]  
  missing_tools = "if_other_versions_installed"  
  show_env = false  
  show_tools = false  
  
No warnings found  
1 problem found:  
  
1. new mise version 2024.12.21 available, currently on 2024.9.5

直接の答えではないけど、mise の新しいバージョンがあることがわかった。ならこれで解決するかも。mise 自体をアップグレードするには mise self-update を使う。

takatoh@apostrophe:~$ mise self-update  
Checking target-arch... mise-v2024.12.21-linux-x64.tar.gz  
Checking current version... v2024.9.5  
Checking latest released version... v2024.12.21  
New release found! v2024.9.5 --> v2024.12.21  
New release is compatible  
  
mise release status:  
  * Current exe: "/home/takatoh/.local/bin/mise"  
  * New exe release: "mise-v2024.12.21-linux-x64.tar.gz"  
  * New exe download url: "https://api.github.com/repos/jdx/mise/releases/assets/216247428"  
  
The new release will be downloaded/extracted and the existing binary will be replaced.  
Do you want to continue? [Y/n] y  
Downloading...  
[00:00:00] [========================================] 12.94 MiB/12.94 MiB (0s) DoneVerifying downloaded file...  
Extracting archive... Done  
Replacing binary file... Done  
Updated mise to 2024.12.21  
mise config files in ~ are not trusted. Trust them? Yes

さて、これで mise doctor では問題が報告されなくなった。

では Python のアップグレードはどうか。

takatoh@apostrophe:~$ mise upgrade python@3.12  
mise hint use multiple versions simultaneously with mise use python@3.12 python@3.11  
mise hint installing precompiled python from astral-sh/python-build-standalone  
if you experience issues with this python (e.g.: running poetry), switch to python-build by running mise settings python.compile=1  
mise python@3.12.8 ✓ installed                                                  mise uninstall python@3.12.6 ✓ remove ~/.local/share/mise/installs/python/3.12.6

無事アップグレードできたようだ。各バージョンはつぎの通り。

takatoh@apostrophe:~$ mise ls  
Tool    Version  Source        Requested   
go      1.22.10  ~/.mise.toml  1.22  
node    20.17.0   
node    22.12.0  ~/.mise.toml  22  
python  3.11.10   
python  3.12.8   ~/.mise.toml  3.12  
ruby    3.2.5     
ruby    3.2.6    ~/.mise.toml  3.2

mise upgrade だと outdated だったバージョンは削除されるんだな。

おまけ

先日リリースされたばかりの Ruby 3.4 をインストールしてみる。

takatoh@apostrophe:~$ mise install ruby@3.4  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current  
                                 Dload  Upload   Total   Spent    Left  Speed  
100 22.0M  100 22.0M    0     0  73.1M      0 --:--:-- --:--:-- --:--:-- 73.3M  
mise ruby@3.4.1 ✓ installed

3.4.0 じゃなくて 3.4.1 がインストールされた。もうパッチが出たの?と思って公式サイトを見ると、「このリリースではバージョン表記を修正しています。」とだけ書いてある。別に大したことじゃなさそう。