* feat: Displays a warning when the plugin from the tools-version does not exist
When calling the install command, it tried to look for versions for all
the plugins available and installed them. With this change, it will attempt to
find versions for all the installed plugins and plugins defined in the
`.tool-versions`.
Fixes https://github.com/asdf-vm/asdf/issues/574
* feat: Changes the algorithm to detect not installed plugins
This patch changes the algorithm. It preserves the original logic for
the plugin resolution, but at the same time, reports entries with plugins not
available.
* fix: Addresses the pull request comments.
- Changes the comparison to be strict rather than partial.
- Prints a list of missing plugins.
- Exists if at least one plugin is not present.
- Adds unit tests.
find: warning: you have specified the global option -mindepth after the argument
-type, but global options are not positional, i.e., -mindepth affects tests
specified before it as well as those specified after it. Please specify global
options before other arguments.
find: warning: you have specified the global option -maxdepth after the argument
-type, but global options are not positional, i.e., -maxdepth affects tests
specified before it as well as those specified after it. Please specify global
options before other arguments.
Process substitution isn't specified by POSIX and makes shims break when called by a script that `export POSIXLY_CORRECT=1` (like gitflow [here](https://github.com/nvie/gitflow/blob/develop/git-flow#L78)).
Here we replace `grep -f <(cmd1) <(cmd2)` with `cmd2 | grep -F "$(cmd1)"` so that we can provide a string instead of a file descriptor and get the same result as before.
(Note: We also check if the result of `cmd1` is empty before running `grep` to get the same behavior as with `-f`. This also prevent crashes if null results are piped to `xargs` and fits nicely with the `with_shim_executable` function that already check the result of `$selected_version` before going on).
Fixes: #581
Issue: when asdf is first installed, there are no plugins, and running `asdf plugin-update --all` crashes because the plugin directory doesn't exist; similarly, the command crashes if the plugins directory exists yet doesn't contain any subdirectories.
Solution: This patch changes the directory loop from using a wildcard `plugins/*` to a more robust approach: first verify the plugins directory exists, then use the`find` command to list subdirectories and correctly handle the corner case of no subdirectories.
Future: Consider printing an error message and/or advice message. Consider automatically creating the plugins directory as needed. Consider prompting the user to install some popular plugins.
`asdf install <name>` installs that single tool at the version specified
in `.tool-versions`. If there is no `.tool-versions` or if that tool is
not in it, an error message is shown and `asdf` exits `1`.
Implements #759
Rename custom scripts for `plugin-add` and `plugin-remove` phases in plugins to make clear when they are executed:
`plugin-add` -> `post-plugin-add`
`plugin-remove` -> `pre-plugin-remove`
If asdf-vm was installed with a package manager and the user doesn't
have the necessary permissions to update it with `asdf update`, asdf-vm
emits an informational message and exits with exit code 1.
This makes it hard to programmatically detect whether the update failed
or wasn't even attempted because it's not possible.
With this change, asdf-vm would exit with the exit code 42 if updates are
disabled instead of exit code 1, which signals an error during update.
Refs r-darwish/topgrade#367
If ASDF_DATA_DIR variable is undefined it will assign an empty value to
it so bash instances running with set -o nounset can run the script
without error.
Previously, the shims directory was only excluded for system versions,
which meant that `asdf exec` would fall back to a shim if the install
didn't have the desired binary. If the shims are up to date this isn't a
problem since we check the metadata, but it causes issues if those are
out of sync for whatever reason.
I've checked all the uses of this function and I'm not seeing anywhere
we should need the old behavior.