jdx / mise

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

Tool dependencies #2536

Open davidkuridza opened 2 months ago

davidkuridza commented 2 months ago

I came across a tool dependency issue and didn't find it documented anywhere. Please let me know if this is an expected behaviour and how to solve it.

I would like to have all the dependencies defined in .mise.toml and installed with mise install. Trying to add a Python package, for example yamllint, pipx has to be available on the system or installed with mise as documented. Is there a way to do it with a single command?

An alternative approach is to use a plugin. I found a community plugin, but it relies on other tools as well, for example, jq. With both jq and yamllint in .mise.toml, I assume it should be possible to run mise install but it fails due to missing jq even though it's installed before yamllint. Is there a way to specify dependencies between tools?

Thank you.

jdx commented 2 months ago

sort of but they're hardcoded into mise right now: https://github.com/jdx/mise/blob/0fd5c11c2501b230ecd86f4459b2f7629b02d72d/src/backend/asdf.rs#L299

we could probably add jq as a dependency against everything except jq itself to that list

davidkuridza commented 2 months ago

I forgot to include this in the post above:

❯ cat .mise.toml
[settings]
experimental = true

[tools]
"python" = "latest"
"jq" = "latest"
"yamllint" = "latest"

# first run fails
❯ mise install
... snip
/root/.local/share/mise/plugins/yamllint/lib/common.sh: line 74: jq: command not found
/root/.local/share/mise/plugins/yamllint/lib/common.sh: line 75: jq: command not found
/root/.local/share/mise/plugins/yamllint/lib/common.sh: line 76: jq: command not found
... snip
mise python@3.12.5 ✓ installed
mise jq@1.7.1 ✓ installed
mise ~/.local/share/mise/plugins/yamllint/bin/download exited with non-zero status: exit code 3
mise Run with --verbose or MISE_VERBOSE=1 for more information

# second run works since dependencies exist
❯ mise install
mise yamllint@1.35.1 ✓ installed

If there's a missing dependency, mise install fails for the dependent one (in this case, jq and python are installed, yamllint fails). Running mise install again works since the dependency is available. Running it several times locally is an inconvenience, not really an issue, but it is a bit cumbersome when trying to run in the CI.

I'm using jq and yamllint as an example here, but it could be any other tool, including other backends. Is there a way to instruct mise about the tools' dependencies?