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

aliases for tool backend #2885

Closed
jdx opened this issue Nov 1, 2024 · 6 comments · Fixed by #2979
Closed

aliases for tool backend #2885

jdx opened this issue Nov 1, 2024 · 6 comments · Fixed by #2979

Comments

@jdx
Copy link
Owner

jdx commented Nov 1, 2024

right now the [aliases] portion of mise.toml is designed for tool versions:

[alias.node]
lts = "20"

however, what we don't have is a way for us to do this with the tool backend:

[alias]
docuum = "cargo:docuum"

I'm not sure how we might want to present this. The above is my first thought, but it wouldn't allow having both aliased versions and aliased backend, so that would need to be figured out. A couple of alternatives:

[default_backends]
docuum = "cargo:docuum"
[registry]
docuum = "cargo:docuum"

"registry" might be ideal here since it maps reasonably well to the codebase, and maybe it could allow for alternate registries like we have for the old asdf-specific shortname stuff

@jdx jdx added the enhancement label Nov 1, 2024
@travbale
Copy link

travbale commented Nov 1, 2024

I have what I think is a practical example of the usefulness of this.

I was trying to use the ubi backend with https://github.com/psastras/sarif-rs. The project publishes each cli tool it has as separate releases as opposed to a zip of all tools. I couldn't figure out a way to make it so I could grab multiple cli tools from the same source.

Something like perhaps:

[registry]
sarif-fmt = "ubi:psastras/sarif-rs"
shellcheck-sarif = "ubi:psastras/sarif-rs"

[tool]
sarif-fmt = "sarif-fmt-v0.6.6"
shellcheck-sarif = "shellcheck-sarif-v0.6.6"

That said my issue might be hinting more at a way to have multiple versions of the same tool (with an alias for the command) active at the same time.

@jdx
Copy link
Owner Author

jdx commented Nov 5, 2024

thinking about this more I'm starting to prefer this as the config:

[alias] # shorthand for `alias.docuum.full = "cargo:docuum"`
docuum = "cargo:docuum" 

[alias.docuum] # long version
full = "cargo:docuum"
versions = {lts = "20"} # in case you want to alias the name and the versions

Of course this would still do the same thing as today for backwards-compatibility, but I probably would remove it from the docs:

[alias.node]
lts = "20"

jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
@jdx jdx closed this as completed in #2979 Nov 10, 2024
jdx added a commit that referenced this issue Nov 10, 2024
@liskin
Copy link
Contributor

liskin commented Nov 13, 2024

I'm trying to test this but it doesn't seem to work… am I using it right?

[tools]
rust-analyzer = "2024-10-21"
[alias]
rust-analyzer = "ubi:rust-analyzer/rust-analyzer"
$ RUST_BACKTRACE=full mise install --verbose --verbose
…
TRACE  1 [src/config/mod.rs:91] config_paths: ["/home/tomi/.config/mise/config.toml"]
TRACE  1 [src/file.rs:151] cat ~/.config/mise/config.toml
TRACE  1 [src/config/config_file/mise_toml.rs:91] parsing: ~/.config/mise/config.toml
TRACE  1 [src/config/mod.rs:108] config: Config {
    Config Files: [
        "~/.config/mise/config.toml",
    ],
    Aliases: {
        "rust-analyzer": Alias {
            full: Some(
                "ubi:rust-analyzer/rust-analyzer",
            ),
            versions: {},
        },
    },
}
DEBUG  1 [src/toolset/mod.rs:177] install_versions: rust-analyzer@2024-10-21
TRACE 16 [src/cache.rs:129] reading ~/.cache/mise/ubi-rust-analyzer-rust-analyzer/remote_versions-308df.msgpack.z
The application panicked (crashed).
Message:  Pre-condition of install_version violated: ctx.tv.backend().backend_type == self.get_type()
Location: src/backend/mod.rs:424

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮                               
   8: mise::backend::Backend::install_version::panic_cold_display::h0f39cf1b060a97d4
      at <unknown source file>:<unknown line>
   9: mise::backend::Backend::install_version::hb81e72d33ecf14ac
      at <unknown source file>:<unknown line>
  10: std::sys::backtrace::__rust_begin_short_backtrace::ha532bcb1e3a0268c
      at <unknown source file>:<unknown line>
  11: core::ops::function::FnOnce::call_once{{vtable.shim}}::h76b2f83f951e502e
      at <unknown source file>:<unknown line>
  12: std::sys::pal::unix::thread::Thread::new::thread_start::hcdbd1049068002f4
      at <unknown source file>:<unknown line>
  13: start_thread<unknown>
      at ./nptl/pthread_create.c:447
  14: __GI___clone3<unknown>
      at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.

And then with

[tools]
stylua = "0.20.0"
[alias]
stylua = "ubi:JohnnyMorganz/StyLua[exe=stylua]"

I get

DEBUG  1 [src/toolset/mod.rs:177] install_versions: stylua@0.20.0
Error: 
   0: No repository found for plugin ubi:JohnnyMorganz/StyLua[exe=stylua]

Location:
   src/plugins/asdf_plugin.rs:79

Version:
   2024.11.9 linux-x64 (01b7d8b 2024-11-13)

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 2 frames hidden ⋮                               
   3: mise::plugins::asdf_plugin::AsdfPlugin::get_repo_url::hb16368ea7a51e16e
      at <unknown source file>:<unknown line>
   4: <mise::plugins::asdf_plugin::AsdfPlugin as mise::plugins::Plugin>::install::hd83a98779f0b8581
      at <unknown source file>:<unknown line>
   5: <mise::plugins::asdf_plugin::AsdfPlugin as mise::plugins::Plugin>::ensure_installed::h7ff8ca041caad607
      at <unknown source file>:<unknown line>
   6: mise::toolset::Toolset::install_versions::h5c5f6cd6b47fbfdf
      at <unknown source file>:<unknown line>
   7: mise::cli::Commands::run::hb56a6fa380ec3d7a
      at <unknown source file>:<unknown line>
   8: mise::cli::Cli::run::h94fd88e10d07547b
      at <unknown source file>:<unknown line>
   9: mise::main::h997cac13f6acb388
      at <unknown source file>:<unknown line>
  10: std::sys::backtrace::__rust_begin_short_backtrace::hdf707c4efda7a634
      at <unknown source file>:<unknown line>
  11: main<unknown>
      at <unknown source file>:<unknown line>
  12: __libc_start_call_main<unknown>
      at ./csu/../sysdeps/nptl/libc_start_call_main.h:58
  13: __libc_start_main_impl<unknown>
      at ./csu/../csu/libc-start.c:360
  14: _start<unknown>
      at <unknown source file>:<unknown line>
version: 2024.11.9 linux-x64 (01b7d8b 2024-11-13)
activated: no
shims_on_path: yes

build_info:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Wed, 13 Nov 2024 03:57:44 +0000
  Rust Version: rustc 1.82.0 (f6e511eec 2024-10-15)
  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:
  aqua
  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.28.0
  cargo:cargo-audit@0.21.0
  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.13
  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.4
  ubi:JohnnyMorganz/StyLua@0.20.0
  ubi:YodaEmbedding/frece@1.0.6
  ubi:ankitpokhrel/jira-cli@1.5.2
  ubi:astral-sh/uv@0.4.29
  ubi:bazelbuild/buildtools@7.3.1
  ubi:evcxr/evcxr@0.17.0
  ubi:kubernetes-sigs/kind@0.22.0
  ubi:oz/tz@0.7.0
  ubi:pkolaczk/fclones@0.34.0
  ubi:rust-analyzer/rust-analyzer@2024-10-21
  ubi:tilt-dev/ctlptl@0.8.35
  ubi:tilt-dev/tilt@0.33.21
  ubi:cargo-bins/cargo-binstall@1.10.12
  ubi:wagoodman/dive@0.12.0
  ubi:cli/cli@2.61.0
  ubi:hadolint/hadolint@2.12.0
  ubi:tamasfe/taplo@0.9.3
  usage@1.3.0
  ubi:watchexec/watchexec@2.2.0
  ubi:JohnnyMorganz/StyLua[exe=stylua]@0.20.0  (missing)

env_vars:
  (none)

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 = false
  paranoid = true
  pin = true
  pipx_uvx = true
  plugin_autoupdate_last_check_duration = "7d"
  quiet = false
  raw = false
  task_timings = false
  trace = false
  trusted_config_paths = ["~/.config/mise/config.toml"]
  unix_default_file_shell_args = ["sh"]
  unix_default_inline_shell_args = [
      "sh",
      "-c",
  ]
  use_file_shell_for_executable_tasks = false
  use_versions_host = true
  verbose = false
  windows_default_file_shell_args = [
      "cmd",
      "/c",
  ]
  windows_default_inline_shell_args = [
      "cmd",
      "/c",
  ]
  windows_executable_extensions = [
      "exe",
      "bat",
      "cmd",
      "com",
      "ps1",
      "vbs",
  ]
  yes = false

  [cargo]
  binstall = true

  [node]

  [npm]
  bun = false

  [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 = "always"
  show_env = true
  show_tools = false
No warnings found
No problems found

@jdx
Copy link
Owner Author

jdx commented Nov 13, 2024

it won't do anything if the plugin is already installed with that name

@liskin
Copy link
Contributor

liskin commented Nov 17, 2024

it won't do anything if the plugin is already installed with that name

Okay, fair enough, but the stylua = "ubi:JohnnyMorganz/StyLua[exe=stylua]" alias still doesn't work even if after I uninstall:

$ mise install
mise ERROR failed to install ubi:JohnnyMorganz/StyLua[exe=stylua]@2.0.0
mise ERROR Failed to install with ubi 'ubi:JohnnyMorganz/StyLua[exe=stylua]@2.0.0': HTTP status client error (404 Not Found) for url (https://api.github.com/repos/jc00ke/asdf-stylua/releases/tags/v2.0.0)
mise ERROR Run with --verbose or MISE_VERBOSE=1 for more information

@powerman
Copy link
Contributor

You do not need [exe=stylua] in this case, just use lower case repo name: "ubi:JohnnyMorganz/stylua".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants