Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mise hook-env: PATH is not updated after mise uninstall #2876

Closed
powerman opened this issue Oct 31, 2024 · 0 comments · Fixed by #2919
Closed

mise hook-env: PATH is not updated after mise uninstall #2876

powerman opened this issue Oct 31, 2024 · 0 comments · Fixed by #2919
Labels
bug Something isn't working

Comments

@powerman
Copy link
Contributor

Describe the bug
If there are some older tool versions installed (which also match version requirement in .mise.toml) and we do mise rm <tool@current_version> then we get broken $PATH and mise i is unable to fix this issue.

To fix this situation we need to do something unusual: either remove all versions of the tool and then mise i will fix it, or install just removed "current_version" back, or leave project's directory and enter again.

To Reproduce
Start clean, and ensure mise i won't add new tools to PATH, just in case (so far so good):

$ mkdir mise-rm-path-bug
$ cd mise-rm-path-bug
$ dust --version
zsh: command not found: dust
$ mise ls dust
Tool  Version  Config Source Requested
$ mise i [email protected] 
mise Installed binary into /home/powerman/.local/share/mise/installs/dust/0.8.1/bin/dust
mise ubi:bootandy/[email protected]      ✓ installed
$ mise i [email protected]
mise Installed binary into /home/powerman/.local/share/mise/installs/dust/0.8.3/bin/dust
mise ubi:bootandy/[email protected]      ✓ installed
$ mise ls dust
Tool  Version  Config Source Requested
dust  0.8.1                           
dust  0.8.3                           
$ dust --version
zsh: command not found: dust

Now, start using it and then upgrade, to ensure mise i will update PATH (so far so good too):

$ mise bin-paths | grep dust
$ printf "%s\n" $path | grep dust
$ mise use [email protected]
mise ~/tmp/mise-rm-path-bug/.mise.toml tools: ubi:bootandy/[email protected]
$ dust --version
Dust 0.8.3
$ mise i [email protected]
mise Installed binary into /home/powerman/.local/share/mise/installs/dust/0.8.2/bin/dust
mise ubi:bootandy/[email protected]      ✓ installed
$ dust --version
Dust 0.8.3
$ mise i [email protected]
mise Installed binary into /home/powerman/.local/share/mise/installs/dust/0.8.5/bin/dust
mise ubi:bootandy/[email protected]      ✓ installed                                                       
$ dust --version
Dust 0.8.5

Then, remove currently used version and get broken PATH:

$ mise ls dust
Tool  Version           Config Source                     Requested
dust  0.8.1                                                        
dust  0.8.2                                                        
dust  0.8.3                                                        
dust  0.8.5 (outdated)  ~/tmp/mise-rm-path-bug/.mise.toml 0.8      
$ mise bin-paths | grep dust
/home/powerman/.local/share/mise/installs/dust/0.8.5/bin
$ printf "%s\n" $path | grep dust
/home/powerman/.local/share/mise/installs/dust/0.8.5/bin
$ mise rm [email protected]
mise ubi:bootandy/[email protected]      ✓ uninstalled
$ mise exec -- dust --version
Dust 0.8.3
$ dust --version
zsh: command not found: dust
$ mise ls dust
Tool  Version           Config Source                     Requested
dust  0.8.1                                                        
dust  0.8.2                                                        
dust  0.8.3 (outdated)  ~/tmp/mise-rm-path-bug/.mise.toml 0.8      
$ mise bin-paths | grep dust
/home/powerman/.local/share/mise/installs/dust/0.8.3/bin
$ printf "%s\n" $path | grep dust
/home/powerman/.local/share/mise/installs/dust/0.8.5/bin

The last line (above) demonstrate the issue: PATH still contain uninstalled/non-existing version, while Mise tools like bin-paths and ls thinks PATH contains another, existing version. As result of this it's even impossible to "fix" this in usual way:

$ cat .mise.toml
[tools]
dust = "0.8"
$ mise i
mise all runtimes are installed
$ dust --version
zsh: command not found: dust

Expected behavior
If mise install updates $PATH when installing newer version which matches requirement in config then mise uninstall should do the same when uninstalling currently used version. Or, more precisely, mise hook-env should handle this case.

mise doctor output

version: 2024.10.13 linux-x64 (ee83488 2024-10-28)
activated: yes
shims_on_path: no

build_info:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Mon, 28 Oct 2024 03:25:17 +0000
  Rust Version: rustc 1.81.0 (eeb90cda1 2024-09-04)
  Profile: release

shell:
  /bin/zsh
  zsh 5.9 (x86_64-pc-linux-gnu)

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
  ~/tmp/mise-rm-path-bug/.mise.toml

backends:
  cargo
  core
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:

toolset:
  ubi:bootandy/[email protected]
  ubi:jdx/[email protected]
  ubi:aquaproj/[email protected]
  ubi:go-task/[email protected]
  go:github.com/oklog/ulid/v2/cmd/[email protected]
  ubi:santhosh-tekuri/[email protected]
  ubi:bronze1man/[email protected]
  ubi:mikefarah/[email protected]
  ubi:fullstorydev/[email protected]
  ubi:fullstorydev/[email protected]
  ubi:ktr0731/[email protected]
  pipx:a13xp0p0v/kernel-hardening-checker@latest
  go:golang.org/x/review/[email protected]
  ubi:ankitpokhrel/[email protected]
  ubi:noahgorstein/[email protected]
  ubi:cespare/[email protected]
  ubi:jondot/[email protected]
  ubi:kubernetes-sigs/[email protected]
  ubi:kubernetes/[email protected]
  go:github.com/bernardo-bruning/[email protected]
  ubi:plandex-ai/plandex@cli/v1.1.1
  npm:[email protected]
  ubi:magefile/[email protected]
  go:github.com/erning/gorun@latest
  ubi:myitcv/[email protected]
  ubi:traefik/[email protected]
  ubi:x-motemen/[email protected]
  go:golang.org/x/pkgsite/cmd/pkgsite@latest
  go:golang.org/x/tools/cmd/[email protected]
  go:golang.org/x/tools/cmd/[email protected]
  go:github.com/rogpeppe/[email protected]
  ubi:oligot/[email protected]
  ubi:psampaz/[email protected]
  ubi:uber-go/[email protected]
  go:golang.org/x/tools/cmd/[email protected]
  go:rsc.io/rf@latest
  go:github.com/quasilyte/gogrep/cmd/[email protected]
  go:golang.org/x/tools/cmd/[email protected]
  go:github.com/josharian/[email protected]
  go:github.com/koron/iferr@latest
  go:github.com/fatih/[email protected]
  go:github.com/davidrjenni/reftools/cmd/fillswitch@latest
  go:github.com/davidrjenni/reftools/cmd/fillstruct@latest
  go:github.com/maruel/panicparse/v2/cmd/[email protected]
  go:github.com/smartystreets/[email protected]
  go:golang.org/x/perf/cmd/benchstat@latest
  go:github.com/vugu/vgrun@latest

env_vars:
  MISE_SHELL=zsh

settings:
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cache_prune_age = "30d"
  ci = false
  color = true
  debug = false
  disable_backends = []
  disable_default_registry = false
  disable_hints = []
  disable_tools = []
  experimental = true
  fetch_remote_versions_cache = "1h"
  fetch_remote_versions_timeout = "10s"
  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 = "30s"
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  libgit2 = true
  lockfile = false
  log_level = "info"
  not_found_auto_install = true
  paranoid = false
  pin = false
  plugin_autoupdate_last_check_duration = "7d"
  quiet = false
  raw = false
  trace = false
  trusted_config_paths = []
  use_versions_host = true
  verbose = false
  yes = false

  [cargo]
  binstall = true

  [node]

  [pipx]
  uvx = true

  [python]
  default_packages_file = "~/.default-python-packages"
  pyenv_repo = "https://github.com/pyenv/pyenv.git"
  venv_auto_create = false
  venv_stdlib = false

  [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 = "if_other_versions_installed"
  show_env = false
  show_tools = false
No warnings found
No problems found
@powerman powerman added the bug Something isn't working label Oct 31, 2024
jdx added a commit that referenced this issue Nov 4, 2024
triggers hook-env execution

Fixes #2876
@jdx jdx closed this as completed in #2919 Nov 4, 2024
jdx added a commit that referenced this issue Nov 4, 2024
triggers hook-env execution

Fixes #2876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant