asdf-vm / asdf

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
https://asdf-vm.com/
MIT License
21.54k stars 767 forks source link

feat: any shim should default to "system" version when no global or local is set #1559

Open XaF opened 1 year ago

XaF commented 1 year ago

Is your feature request related to a problem? Please describe

Using tools such as rbenv and goenv are not making things incompatible with system versions of the softwares. This means that if I'm in a directory with a .ruby-version or .go-version, the specified version is going to be used. But if outside such directory tree, and if a global version is not set, but I do have a system version of the tool, then that system version is going to be used.

That means that using rbenv or goenv are not forcing me to set a global version to keep using my tools outside of locally-defined versions, they "just work". asdf does not, showing the following message:

No version is set for command <tool>
Consider adding one of the following versions in your config file at
((list of installed "<tool> <version>" for <tool>))

Describe the proposed solution

When no global or local is set, before showing the No version is set for command for a shim, asdf should look through the path if such command, outside of the asdf path, does exist, and if such, default to using it.

asdf current could maybe also show system when using the system version of a tool.

Describe similar asdf features and why they are not sufficient

The only alternative is setting a global version (asdf global <tool> system) This still requires a manual operation, while this should be the default operation.

Describe other workarounds you've considered

Using other tools than asdf such as goenv, rbenv, pyenv, that do not allow to centralize all that logic into a single tool... but do allow support for the system version of the tools. I do believe asdf would benefit from that change.

hyperupcall commented 1 year ago

Related to #1314

rubencaro commented 4 months ago

This is already happening to me:

When no global or local is set, before showing the No version is set for command for a shim, asdf should look through the path if such command, outside of the asdf path, does exist, and if such, default to using it.

If there is a shim with the same name as a binary in the system's PATH, asdf will call the system's one before complaining.

For example, say you have Graphviz's dot binary in your system. When using the golang plugin, if you install a package exposing a binary called dot, then asdf sets up a shim for that. From that moment on, when you try to call dot, it will always be managed by asdf as a shim. That is: