mise icon indicating copy to clipboard operation
mise copied to clipboard

Missing tools silently fall back to system version

Open egnor opened this issue 1 year ago • 4 comments

Describe the bug / To reproduce I'm not sure how this is supposed to work.. but if I create (or check out from git, etc) a .mise.toml that says something like this

[tools]
node = "15"

...and I didn't have node v15 installed in mise's cache already, then mise just... does nothing; whatever version of node is present on the system gets run:

% node -v
v18.13.0

mise doctor doesn't see anything wrong:

% mise doctor
[... stuff elided, see below for full output ...]

toolset:
  node@15

No problems found

Now mise ls does show that the tool is missing

% mise ls
Plugin  Version            Config Source                         Requested
node    14.21.3                                                           
node    15.14.0 (missing)  ~/source/jolly-roger/.mise.local.toml 15       
node    20.10.0

And of course mise install goes and gets the missing version and all is well, BUT, when introducing people to mise, this can all be somewhat confusing, as if they happen to have some version of a tool installed globally things will sort-of kind-of work but with the wrong version, and it can be a while before I think to say "...wait, you did run mise install right??".

Expected behavior EITHER auto install missing tools on entry into a directory (or when config files are changed), but I do see https://github.com/jdx/mise/issues/814 and https://github.com/jdx/mise/issues/735 which point out issues with that

OR swap the system version of the tool with one that fails with an error saying that it's not installed (and recommending to run mise install), or perhaps asks for permission to go ahead and install; I think this already happens if the tool in question is NOT already installed at the system level

OR at least issue a warning on entry (or when a tool is run) that a tool version is missing, and recommends running install

In any case it seems like mise doctor should have some note when current tool versions are missing?

mise doctor output

mise version:
  2024.1.7 linux-x64 (292e4ac 2024-01-05)

build:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Fri, 5 Jan 2024 19:07:03 +0000
  Rust Version: rustc 1.75.0 (82e1608df 2023-12-21)
  Profile: release

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

mise data directory:
  /home/egnor/.local/share/mise

mise environment variables:
  MISE_SHELL=zsh

settings:
  {
    "experimental": false,
    "color": true,
    "always_keep_download": false,
    "always_keep_install": false,
    "legacy_version_file": true,
    "legacy_version_file_disable_tools": [],
    "plugin_autoupdate_last_check_duration": "7d",
    "trusted_config_paths": [],
    "log_level": "info",
    "trace": false,
    "debug": false,
    "verbose": false,
    "quiet": false,
    "asdf_compat": false,
    "jobs": 4,
    "shorthands_file": null,
    "disable_default_shorthands": false,
    "disable_tools": [],
    "raw": false,
    "yes": false,
    "task_output": null,
    "not_found_auto_install": true,
    "ci": false,
    "env_file": null,
    "cd": null
  }

config files:
  /home/egnor/source/jolly-roger/.mise.local.toml

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

toolset:
  node@15

No problems found

egnor avatar Jan 07 '24 06:01 egnor

this is by design. If someone doesn't want to manage a particular tool via mise they don't have to and by default mise won't complain about it. If you want to see a warning for missing tools you can use mise activate --status.

jdx avatar Jan 07 '24 07:01 jdx

Thanks for the quick reply (and thanks for the excellent tool)!!

That feels odd to me? If the desire is to honor user intent to bypass parts of a .mise.toml, that's a fragile path for that... after all if the user had installed that particular tool for any OTHER project on the system, mise would have gone ahead and quietly used it. Cache status as configuration is a bit strange no?

It feels like warning by default for requested-but-missing tools (even if status is not otherwise shown) and either having a warning-suppress option or (better?) letting a user specifically say "do NOT honor this particular .mise.toml request for this particular tool" would be friendlier and less error prone.

Again the struggle here is when adopting mise for a project, telling everyone "ok install this thing! it's easy!" but then they skip one step and now things are silently weird.

(Heck I'd argue that activate --status would be a good default. Be explicit by default, let the power users silence it. It's the uninitiated / passive users who need to see what's going on.)

That said, that would make this an enhancement request, and perhaps a rather low priority one at that...

egnor avatar Jan 07 '24 16:01 egnor

Didn't rtx warn about this? Since moving to mise I've been running into issues with projects all the time because it was using my globally set dependency versions instead of the project specific ones (which were uninstalled). Mise should warn about uninstalled versions when switching into a folder where dependencies are missing.

LostKobrakai avatar Jan 09 '24 11:01 LostKobrakai

It's an area that's been continuously iterated on. At different points in rtx different warnings/behavior/defaults around this have been tried. Finding the right balance to show effective warnings in hook-env is challenging.

I'll have a look again to see if there is more visibility we can show here, but in the meantime you should always be able to opt into the behavior with --status

Keep in mind though that a lot of users disagree with you and don't want to see a warning for this. My gut tells me there is more people on that side than are in favor of the warning. I'm not sure there is a default behavior that is what everyone wants.

jdx avatar Jan 09 '24 14:01 jdx

FWIW, I just ran into this after an rtx -> mise migration because I didn't have the Python version installed that the project called for. I was using which python to test if the virtualenv (managed by mise) was activated and it never was. In frustration I finally typed python --version even though there shouldn't have been a python binary installed at that point and rtx kicked in and installed that version of Python and then the virtualenv was activated.

I'd second a "warning by default" with a setting/config that can disable it.

I also ran doctor several times to try and diagnose what was going on to no avail. It might also help to know that I activate mise in .bashrc.

rsyring avatar Jan 11 '24 21:01 rsyring

my hope was that the "not_found" handler that worked in your situation would mitigate this problem. It probably has to some extent but it has a lot of gaps which python is one, but also it only works if you have a different version of the tool installed. If you don't have any python versions installed it doesn't know that it needs to run.

That second problem might be fixable now that I think of it though. I would have to hardcode the binary names, e.g.: pip3 -> python and npm -> node because mise needs to know which binaries mean which tools should be installed. It can do this when there are other versions installed, because it can just look at what the other versions export, but not if you haven't installed anything yet.

jdx avatar Jan 11 '24 21:01 jdx

I think all the work you are doing on this, as well as your desire to make mise as friendly as possible, is commendable.

For whatever its worth, I found it surprising that typing python installed the version requested and would have preferred a warning that told me something to the effect of "run mise install or mise setting ignore-missing-tools=true to silence this warning."

rsyring avatar Jan 11 '24 21:01 rsyring

I don't want to show the warning if the not found handler is in place. That will mean I show them a warning telling them to install manually but chances are if they just run the tool it'll automatically install anyways.

I think the not found handler gives a much better experience. I also know that users don't like the warning so I think it's a better default.

~~What I can do is improve the not found handler so it works in more cases. I won't get all of them, but I think I can get enough to give a good experience.~~ EDIT: actually I've changed my mind on this. I think the right behavior is what we have today—only autoinstall versions when you have an existing version of the same tool installed. mise should not automatically install anything a user hasn't explicitly installed already.

Of course if you want the warning, just use --status

jdx avatar Jan 11 '24 22:01 jdx

This is a minor thing but perhaps --status is better managed via settings

jdx avatar Jan 11 '24 22:01 jdx

Using --status works but it also includes the current versions of other languages, which isn't desirable:

mise [email protected] [email protected] [email protected] [email protected] [email protected]
mise missing: [email protected]

It would be nice to be able to recreate the rtx behavior, or at least be have an option for it.

dnicolson avatar Jan 15 '24 16:01 dnicolson

this wasn't a change with mise but I believe you can get the behavior you want with mise activate --status --log-level=warn—though I am wondering if this would benefit from a dedicated setting like MISE_ACTIVATE_MISSING_TOOL=warn or something

jdx avatar Jan 16 '24 05:01 jdx

After switching from asdf to rtx, I immediately noticed terminal messages about missing versions. This wasn't how it functioned?

I have this in my config.fish file but I still get both lines in the terminal:

mise activate --status --log-level=warn fish | source

dnicolson avatar Jan 16 '24 18:01 dnicolson

@dnicolson I believe:

  • Warnings about missing tools are hidden by default with mise
  • Using mise activate --status --log-level=warn will give you the warnings

So, assuming "both lines in your terminal" refer to the missing tool warning messages it seems like its working as currently designed. What exactly are you asking?

rsyring avatar Jan 16 '24 18:01 rsyring

Both lines as in --log-level=warn has no effect preventing the first line appearing in every session:

mise [email protected] [email protected] [email protected] [email protected] [email protected]
mise missing: [email protected]

dnicolson avatar Jan 16 '24 18:01 dnicolson

It might actually be necessary to set MISE_LOG_LEVEL=warn but if so that's a bug

jdx avatar Jan 16 '24 18:01 jdx

Setting MISE_LOG_LEVEL=warn results in no output.

dnicolson avatar Jan 16 '24 18:01 dnicolson

yeah I see the same behavior. I think rather than fixing that I kind of want to make a new config that's clearer. I think these 2 lines warrant a dedicated setting.

I'm thinking maybe we make it something where you can pick what you want to see with csv, like this:

MISE_ACTIVATE_STATUS=none # the default
MISE_ACTIVATE_STATUS=tools # see all tools, missing or not
MISE_ACTIVATE_STATUS=missing_tools # just see the missing tools
MISE_ACTIVATE_STATUS=env # see env var changes
MISE_ACTIVATE_STATUS=all # equivalent to tools,missing_tools,env

jdx avatar Jan 16 '24 18:01 jdx

Perhaps a reasonable default could be to show the warning when you are in a project directory that specifies a version (eg. .node-version) that is not installed, maybe?

dnicolson avatar Jan 16 '24 23:01 dnicolson

I explained my reasoning here: https://github.com/jdx/mise/issues/1387#issuecomment-1888053657

jdx avatar Jan 16 '24 23:01 jdx