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

Not generating mise completions despite usage CLI is installed #1710

Closed
filipeltsilva opened this issue Feb 25, 2024 · 6 comments
Closed

Not generating mise completions despite usage CLI is installed #1710

filipeltsilva opened this issue Feb 25, 2024 · 6 comments

Comments

@filipeltsilva
Copy link

filipeltsilva commented Feb 25, 2024

Hi!

I migrated from rtx to mise and I'm trying to generate the completions through mise completion fish command, but I got this return:

# if "usage" is not installed show an error
if ! command -v usage &> /dev/null
    echo "Error: usage not found. This is required for completions to work in mise. https://usage.jdx.dev" >&2
    return 1
end

set _usage_spec_mise (mise usage | string collect)
complete -xc mise -a '(usage complete-word -s "$_usage_spec_mise" -- (commandline -cop) (commandline -t))

I installed the usage plugin through mise use -g usage command and the system detected its presence when I run the command -v usage above.

Here is my mise doctor log:

version: 2024.2.18 linux-x64 (4893e09 2024-02-24)
activated: yes
shims_on_path: no

build_info: 
  Target: x86_64-unknown-linux-musl
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Sat, 24 Feb 2024 06:33:38 +0000
  Rust Version: rustc 1.76.0 (07dca489a 2024-02-04)
  Profile: release

shell: 
  /usr/bin/fish
  fish, version 3.7.0

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

plugins: 
  bun         (core)
  deno        (core)
  erlang      (core)
  go          (core)
  java        (core)
  neovim      https://github.com/richin13/asdf-neovim.git#0b7b611
  node        (core)
  python      (core)
  ruby        (core)
  shellcheck  https://github.com/luizm/asdf-shellcheck.git#b160a52
  usage       https://github.com/jdx/mise-usage.git#fe3888a

toolset: 
  go@1.22.0         
  neovim@0.9.5      
  node@20.11.1      
  ruby@3.3.0        
  shellcheck@0.9.0  
  usage@0.1.9       

env_vars: 
  MISE_NODE_DEFAULT_PACKAGES_FILE=/home/filipelemos/.config/mise/.default-npm-packages
  MISE_SHELL=fish
  MISE_GO_DEFAULT_PACKAGES_FILE=/home/filipelemos/.config/mise/.default-go-packages
  MISE_RUBY_DEFAULT_PACKAGES_FILE=/home/filipelemos/.config/mise/.default-gems

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = true
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = true
  go_default_packages_file = "/home/filipelemos/.config/mise/.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
  jobs = 5
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "1 week"
  python_compile = false
  python_default_packages_file = "/home/filipelemos/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = true
  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 problems found

What can be missing to generate the completions?

Thanks for the help.

@jdx
Copy link
Owner

jdx commented Feb 26, 2024

I just tested with fish, mise use -g usage and it works for me so I'm not sure

@ches
Copy link

ches commented Mar 1, 2024

Completions broke for me recently as well, using bash.

I've been migrated from rtx/using mise for awhile, completions working as expected.

Now, when I type mise <Tab> I get the error about usage:

$ mise Error: usage not found. This is required for completions to work in mise. https://usage.jdx.dev
^C

I'm guessing the relevant change was #1652, but I have not bisected yet. I haven't grokked the PR diff fully to understand the feature that that change brings, but just starting with the doc updates there, this seems relevant:

I install/update mise with Homebrew, and it appears the formula installs the bash completion script with mise completion without --usage option.

I have never installed a usage mise plugin, running mise usage prints a bunch of completion & help output which probably is a "spec" for the usage Rust crate which the mise plugin would install for me as an executable (from my 90 seconds of grokking #1652 😅).

I assume that mise's completion support from the usage crate is supposed to be something optional, that mise completion should produce something that works without opting in to usage, and that I should not need to install the usage mise plugin if I am not opting into this feature. Is that correct?

Putting it another way: previously with a working bash-completion setup, brew install mise and eval "$(mise activate bash)" gave me great completion support with no further setup steps. After updating to a release beyond #1652, is it expected that a pre-existing setup is broken until users install an additional plugin?

My Doctor Report
version: 2024.2.19 macos-arm64 (2024-02-28)
activated: yes
shims_on_path: no

build_info: 
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS
  Built: Wed, 28 Feb 2024 05:54:30 +0000
  Rust Version: rustc 1.76.0 (07dca489a 2024-02-04) (Homebrew)
  Profile: release

shell: 
  /opt/homebrew/bin/bash
  GNU bash, version 5.2.26(1)-release (aarch64-apple-darwin22.6.0)
  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: ~/Library/Caches/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files: 
  ~/.ruby-version
  ~/.config/mise/config.toml

plugins: 
  bun     (core)
  deno    (core)
  erlang  (core)
  go      (core)
  java    (core)
  node    (core)
  python  (core)
  ruby    (core)

toolset: 
  java@zulu-11  

env_vars: 
  MISE_SHELL=bash

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  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
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_compile = false
  python_default_packages_file = "/Users/cmartin/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = 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 problems found

@jdx
Copy link
Owner

jdx commented Mar 1, 2024

You need to install usage in order to use mise's completions

@ches
Copy link

ches commented Mar 4, 2024

You need to install usage in order to use mise's completions

Okay so I guess this was a slightly breaking change, we now need to install something additional and that was not the case before #1652, is that correct?

I'm sorry to belabor tediously here, but it sounds to me like upgrade notes are needed for users. I'd try to contribute those if I understood clearly. There's nothing explanatory in the GitHub Releases notes, #1652 has no description in the PR or commit message.

mise completion bash and mise completion --usage bash output the exact same function code, strictly from looking at doc changes in #1652 that was not intuitive, it sounds like an optional choice where the flag would change something. Later a further note was added to the help which sheds a bit of light…

Currently, usage is the default for fish and bash but not zsh since it has a few quirks to work out first.

Now I understand why the output is the same with or without the flag: it's not really an option. The --usage flag should only be valid/accepted with zsh argument to mise completion.

Except mise completion zsh and mise completion --usage zsh also produce the same output 🤷🏼

I don't know anything about usage, why it has a standalone executable and why that is a thing that users should be glad to install because it has benefits for them over a solution that doesn't need another tool. I might mention that in upgrade notes, if I can deduce the intent of this change.

@nilium
Copy link

nilium commented Mar 5, 2024

This is unrelated to the original problem (the issue is about this failing while usage is installed), but:

It does seem like there needs to be an option to disable this for at least fish and bash (and that the --usage option might not work either way, going by the above). Even if it means losing completions, this at least keeps the error message from overwriting shell prompts while typing until the user can do something about it (I'd hate if someone only started seeing this after getting paged and it gave them one more problem to deal with during an incident).

Package maintainers also probably need to be notified of this somehow? The mise packaged for unstable nixpkgs currently does not include usage (nor does the mise flake, from what I can tell?) and it doesn't seem to be packaged yet. usage itself does not have a flake, so users can't install it independently either. Similarly, there is no Void Linux package for usage. I would guess that other packages for mise are in a similar position. So, I think at minimum, communication of usage's usage is missing.

I tried going back to find where this was introduced, and it looks like (to reiterate the above) it's in https://github.com/jdx/mise/releases/tag/v2024.2.10. The line about "adding support" does not convey what someone would need to know when upgrading, and the pull request's description is empty. Changes like this should be handled better so there aren't surprises. Taking care to provide useful release notes would be a good start.

@jdx
Copy link
Owner

jdx commented Mar 5, 2024

You're overstating the harm that could be caused from something like shell completions. Nothing involving shell completions could be considered a "breaking change". Could release notes be better? Sure, but the tool tells you what you need to do in order to get completions to work so I don't see how release notes could offer much more hand-holding.

There certainly is never going to be support for the old completions. Usage supports much more advanced completions that would never be possible with clap's autogenerated completions. mise is an open source project, if you really want to use it without usage go ahead and fork it and maintain it yourself.

Similarly, if you'd like to see usage in more package managers: go ahead and put them in there. Usage is open source and there is nothing stopping you from doing that.

I'm closing since this is a bunch of petty complaints unrelated to the original problem. The original problem also doesn't appear to be reproducible.

@jdx jdx closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2024
Repository owner locked as too heated and limited conversation to collaborators Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants