jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
10.14k stars 293 forks source link

`upgrade --bump ubi:rust-analyzer/rust-analyzer` removes old but doesn't install new #2704

Closed liskin closed 3 weeks ago

liskin commented 1 month ago

Describe the bug The new upgrade --bump functionality behaves strangely on ubi:rust-analyzer/rust-analyzer — it offers the upgrade when run with --interactive, but doesn't bump the version in the config file, and only removes the old version without installing the new one.

To Reproduce

$ mise use -g --pin ubi:rust-analyzer/rust-analyzer@2024-09-16
mise ubi:rust-analyzer/rust-analyzer@2024-09-16 ✓ installed
mise ~/.config/mise/config.toml tools: ubi:rust-analyzer/rust-analyzer@2024-09-16
$ mise upgrade --bump ubi:rust-analyzer/rust-analyzer
mise Uninstalling rust-analyzer/rust-analyzer@2024-09-16 ✓ removing ~/.cache/mise/ubi-rust-analyzer-rust-analyzer/2024-09-16
$ mise ls
Tool                             Version               Config Source              Requested
ubi:rust-analyzer/rust-analyzer  2024-09-16 (missing)  ~/.config/mise/config.toml 2024-09-16
$ mise upgrade --bump --interactive
mise upgrade
Select tools to upgrade
 > • rust-analyzer/rust-analyzer 2024-09-16 -> 2024-09-30 (~/.config/mise/config.toml)
↑/↓/k/j up/down • x/space toggle • a toggle all • / filter • enter confirm

Expected behavior I expected the pinned version in ~/.config/mise/config.toml to be bumped (as it is for all other tools) and the new version to be installed (likewise).

mise doctor output

version: 2024.10.0 linux-x64 (de95bc9 2024-10-03)
activated: no
shims_on_path: yes

build_info:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Thu, 3 Oct 2024 18:34:02 +0000
  Rust Version: rustc 1.81.0 (eeb90cda1 2024-09-04)
  Profile: release

shell:
  /bin/bash
  GNU bash, version 5.2.32(1)-release (x86_64-pc-linux-gnu)
  Copyright (C) 2022 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <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

backends:
  cargo
  core
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:
  usage  https://github.com/jdx/mise-usage.git#fe3888a

toolset:
  cargo:JojiiOfficial/LiveBudsCli@ref:4a2d75f5bede545738110dccbac033954b1d6087
  cargo:ast-grep@0.27.3
  cargo:cargo-audit@0.20.1
  cargo:cargo-cache@0.8.3
  cargo:cargo-edit@0.13.0
  cargo:cargo-watch@8.5.3
  cargo:ripgrep_all@0.10.6
  cargo:tokio-console@0.1.12
  cargo:watchexec-cli@2.1.2
  npm:prettier@3.3.3
  npm:typescript-language-server@4.3.3
  pipx:gdbgui@0.15.2.0
  pipx:git-when-merged@1.2.1
  pipx:liskin/foursquare-swarm-ical@172e1d0336fdab568ab6b5ed505a06daafa5078c
  pipx:liskin/liscopridge@a9c2debe41d045ef184c87bbad331ee6fa20b13c
  pipx:liskin/strava-gear@6883fefc8a8f0a2e5144f271480e406a33540417
  pipx:liskin/strava-offline@1abe986b2d1ba6a300954df6ff648d88bead6c80
  pipx:markdown2ctags@0.3.3
  pipx:pandoc-plantuml-filter@0.1.5
  pipx:pushl@0.3.5
  pipx:python-dxf@12.1.0
  pipx:timezonefinder@6.5.3
  ubi:YodaEmbedding/frece@v1.0.6
  ubi:astral-sh/uv@0.4.18
  ubi:cargo-bins/cargo-binstall@v1.10.6
  ubi:evcxr/evcxr@v0.17.0
  ubi:hadolint/hadolint@v2.12.0
  ubi:kubernetes-sigs/kind@v0.22.0
  ubi:oz/tz@v0.7.0
  ubi:pkolaczk/fclones@v0.34.0
  ubi:rust-analyzer/rust-analyzer@2024-09-16
  ubi:tamasfe/taplo@0.9.3
  ubi:tilt-dev/ctlptl@v0.8.32
  ubi:tilt-dev/tilt@v0.33.19
  ubi:wagoodman/dive@v0.12.0
  usage@0.8.4

env_vars:
  (none)

settings:
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf = true
  asdf_compat = false
  cache_prune_age = "30d"
  cargo_binstall = true
  ci = false
  color = true
  debug = false
  disable_default_shorthands = false
  disable_hints = []
  disable_tools = []
  experimental = true
  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
  log_level = "info"
  not_found_auto_install = false
  paranoid = true
  pipx_uvx = true
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "~/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  python_venv_auto_create = false
  quiet = false
  raw = false
  trace = false
  trusted_config_paths = []
  use_versions_host = true
  verbose = false
  vfox = false
  yes = false

  [node]

  [ruby]
  default_packages_file = "~/.default-gems"
  ruby_build_repo = "https://github.com/rbenv/ruby-build.git"
  ruby_install = false
  ruby_install_repo = "https://github.com/postmodern/ruby-install.git"

  [status]
  missing_tools = "always"
  show_env = true
  show_tools = false
No warnings found
No problems found

(but I've reproduced the issue in a clean debian:testing docker container with just apt install curl, curl … | sh for both ubi and mise, and mise settings set experimental true)

Additional context

``` [DEBUG] (1) mise::cli: [src/cli/mod.rs:222] ARGS: /root/.local/bin/mise upgrade --trace --bump ubi:rust-analyzer/rust-analyzer [TRACE] (1) mise::config: [src/config/mod.rs:70] Settings: Settings { activate_aggressive: false, all_compile: false, always_keep_download: false, always_keep_install: false, asdf: true, asdf_compat: false, cache_prune_age: "30d", cargo_binstall: true, cd: None, ci: false, color: true, debug: true, disable_default_shorthands: false, disable_hints: {}, disable_tools: {}, env_file: None, experimental: true, go_default_packages_file: "~/.default-go-packages", go_download_mirror: "https://dl.google.com/go", go_repo: "https://github.com/golang/go", go_set_gobin: None, 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, log_level: "trace", node: SettingsNode { compile: None, flavor: None, mirror_url: None, }, not_found_auto_install: true, paranoid: false, pipx_uvx: false, plugin_autoupdate_last_check_duration: "7d", python_compile: None, python_default_packages_file: Some( "/root/.default-python-packages", ), python_patch_url: None, python_patches_directory: None, python_precompiled_arch: None, python_precompiled_os: None, python_pyenv_repo: "https://github.com/pyenv/pyenv.git", python_venv_auto_create: false, quiet: false, raw: false, ruby: SettingsRuby { apply_patches: None, default_packages_file: "~/.default-gems", ruby_build_opts: None, ruby_build_repo: "https://github.com/rbenv/ruby-build.git", ruby_install: false, ruby_install_opts: None, ruby_install_repo: "https://github.com/postmodern/ruby-install.git", verbose_install: None, }, shorthands_file: None, status: SettingsStatus { missing_tools: "if_other_versions_installed", show_env: false, show_tools: false, }, task_output: None, trace: true, trusted_config_paths: {}, use_versions_host: true, verbose: true, vfox: false, yes: false, } [TRACE] (1) mise::file: [src/file.rs:149] cat ~/.local/share/mise/installs/ubi-rust-analyzer-rust-analyzer/.mise.backend.json [TRACE] (1) mise::config: [src/config/mod.rs:82] load: config_paths: ["/root/.config/mise/config.toml"] [TRACE] (1) mise::file: [src/file.rs:149] cat ~/.config/mise/config.toml [TRACE] (1) mise::config::config_file::mise_toml: [src/config/config_file/mise_toml.rs:90] parsing: ~/.config/mise/config.toml [TRACE] (1) mise::file: [src/file.rs:149] cat ~/.config/mise/config.toml [TRACE] (1) mise::config::config_file::mise_toml: [src/config/config_file/mise_toml.rs:102] [settings] experimental = true [tools] "ubi:rust-analyzer/rust-analyzer" = "2024-09-16" [DEBUG] (1) mise::config: [src/config/mod.rs:95] Config { Config Files: [ "~/.config/mise/config.toml", ], } [DEBUG] (1) mise::toolset::builder: [src/toolset/builder.rs:48] Toolset (28.69µs): ubi:rust-analyzer/rust-analyzer@2024-09-16 [TRACE] (1) mise::backend: [src/backend/mod.rs:326] Ensuring dependencies installed for ubi:rust-analyzer/rust-analyzer [DEBUG] (1) mise::toolset::tool_request_set: [src/toolset/tool_request_set.rs:152] ToolRequestSet.build(11.276µs): ToolRequestSet: ubi:rust-analyzer/rust-analyzer@2024-09-16 [TRACE] (1) mise::backend: [src/backend/mod.rs:192] Listing remote versions for ubi:rust-analyzer/rust-analyzer [TRACE] (1) mise::cache: [src/cache.rs:128] reading ~/.cache/mise/ubi-rust-analyzer-rust-analyzer/remote_versions-89570.msgpack.z [DEBUG] (1) mise::toolset::builder: [src/toolset/builder.rs:48] Toolset (13.965µs): ubi:rust-analyzer/rust-analyzer@2024-09-16 [DEBUG] (1) mise::toolset: [src/toolset/mod.rs:163] install_versions: ubi:rust-analyzer/rust-analyzer@2024-09-16 [TRACE] (1) mise::toolset: [src/toolset/mod.rs:238] install: resolving [TRACE] (1) mise::toolset: [src/toolset/mod.rs:242] install: reshimming [TRACE] (1) mise::shims: [src/shims.rs:176] get_shim_diffs(389.761µs): sizes: (0,0) [TRACE] (1) mise::toolset: [src/toolset/mod.rs:245] install: done uninstall removing ~/.local/share/mise/installs/ubi-rust-analyzer-rust-analyzer/2024-09-16 [TRACE] (1) mise::file: [src/file.rs:38] rm -rf ~/.local/share/mise/installs/ubi-rust-analyzer-rust-analyzer/2024-09-16 removing ~/.cache/mise/ubi-rust-analyzer-rust-analyzer/2024-09-16 [TRACE] (1) mise::file: [src/file.rs:38] rm -rf ~/.cache/mise/ubi-rust-analyzer-rust-analyzer/2024-09-16 mise Uninstalling rust-analyzer/rust-analyzer@2024-09-16 ✓ done [TRACE] (1) mise::backend: [src/backend/mod.rs:326] Ensuring dependencies installed for ubi:rust-analyzer/rust-analyzer [TRACE] (1) mise::backend: [src/backend/mod.rs:192] Listing remote versions for ubi:rust-analyzer/rust-analyzer [DEBUG] (1) mise::toolset::builder: [src/toolset/builder.rs:48] Toolset (444.919µs): ubi:rust-analyzer/rust-analyzer@2024-09-16 [TRACE] (1) mise::shims: [src/shims.rs:176] get_shim_diffs(271.02µs): sizes: (0,1) [TRACE] (1) mise::file: [src/file.rs:62] rm ~/.local/share/mise/shims/rust-analyzer [TRACE] (1) mise::runtime_symlinks: [src/runtime_symlinks.rs:100] Removing missing symlink: /root/.local/share/mise/installs/ubi-rust-analyzer-rust-analyzer/2024-latest [TRACE] (1) mise::file: [src/file.rs:62] rm ~/.local/share/mise/installs/ubi-rust-analyzer-rust-analyzer/2024-latest [TRACE] (1) mise::file: [src/file.rs:85] rm -rf ~/.local/share/mise/installs/ubi-rust-analyzer-rust-analyzer [TRACE] (1) mise::file: [src/file.rs:38] rm -rf ~/.local/share/mise/installs/ubi-rust-analyzer-rust-analyzer ```
jdx commented 1 month ago

hmm I thought I fixed this but it didn't work

liskin commented 1 month ago

Yeah I was just writing a comment to say so. Now mise upgrade --bump ubi:rust-analyzer/rust-analyzer does nothing at all, and mise upgrade --interactive --bump prints

mise upgrade rust-analyzer/rust-analyzer 2024-09-16 -> 2024-09-30 (~/.config/mise/config.toml)

and only then proceeds to do nothing at all. :-)

liskin commented 1 month ago

I think the issue is that for some reason the bump field of OutdatedInfo is None and the tool_request field specifies the old version for the packages that get removed:

[
    OutdatedInfo {
        name: "astral-sh/uv",
        tool_request: Version { backend: BackendArg("ubi:astral-sh/uv"), version: "0.4.19", options: {} },
        tool_version: ToolVersion { request: Version { backend: BackendArg("ubi:astral-sh/uv"), version: "0.4.18", options: {} }, backend: BackendArg("ubi:astral-sh/uv"), version: "0.4.18" },
        requested: "0.4.18",
        current: Some("0.4.18"),
        bump: Some("0.4.19"),
        latest: "0.4.19",
        source: MiseToml("/home/tomi/.config/mise/config.toml")
    },
    OutdatedInfo {
        name: "cargo-bins/cargo-binstall",
        tool_request: Version { backend: BackendArg("ubi:cargo-bins/cargo-binstall"), version: "v1.10.6", options: {} },
        tool_version: ToolVersion { request: Version { backend: BackendArg("ubi:cargo-bins/cargo-binstall"), version: "v1.10.6", options: {} }, backend: BackendArg("ubi:cargo-bins/cargo-binstall"), version: "v1.10.6" },
        requested: "v1.10.6",
        current: Some("v1.10.6"),
        bump: None,
        latest: "v1.10.7",
        source: MiseToml("/home/tomi/.config/mise/config.toml")
    },
    …
]

Even the --dry-run output makes no sense:

[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall liskin/foursquare-swarm-ical@172e1d0336fdab568ab6b5ed505a06daafa5078c
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall liskin/strava-gear@6883fefc8a8f0a2e5144f271480e406a33540417
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall liskin/strava-offline@1abe986b2d1ba6a300954df6ff648d88bead6c80
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall kubernetes-sigs/kind@v0.22.0
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall tilt-dev/ctlptl@v0.8.32
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall tilt-dev/tilt@v0.33.19
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall astral-sh/uv@0.4.18
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:117] mise Would uninstall cargo-bins/cargo-binstall@v1.10.6
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install liskin/foursquare-swarm-ical@v1.0.3
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install liskin/strava-gear@v1.1.0
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install liskin/strava-offline@1.1.0
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install kubernetes-sigs/kind@v0.24.0
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install tilt-dev/ctlptl@v0.8.34
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install tilt-dev/tilt@v0.33.20
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install astral-sh/uv@0.4.19
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:120] mise Would install cargo-bins/cargo-binstall@v1.10.7
[INFO] (1) mise::cli::upgrade: [src/cli/upgrade.rs:123] mise Would bump astral-sh/uv@0.4.19 in ~/.config/mise/config.toml

Out of all of these, only uv will get correctly bumped. For all the others, ts.install_versions(config, new_versions, &mpr, &opts) will simply attempt to reinstall the old version (no-op), and then the version gets removed. The "would install" lines incorrectly claim that the new version will get installed, which is just not true.

So yeah I think src/cli/upgrade.rs does need an update — the dry_run logic clearly doesn't match what's actually going to happen. BUT also the logic that generates the tool_requests and bumps needs to be fixed.

liskin commented 1 month ago

Right, check_semver_bump in src/toolset/mod.rs as it's currently written only handles versions that parse as Ideal(SemVer { major: 0, minor: 4, patch: 18, pre_rel: None, meta: None }), but "v1.10.6" parses as General(Version { epoch: None, chunks: Chunks([Alphanum("v1"), Numeric(10), Numeric(6)]), release: None, meta: None }) so chunkify just returns an empty vec.

liskin commented 1 month ago

An easy workaround/fix would be to check if MISE_PIN=1 and if yes skip check_semver_bump and just do the bump whenever new != old. It'd still be broken for people who want to specify partial versions, but at least the pinning usecase would be unblocked.