asdf
asdf copied to clipboard
Auto reshim
Steps to reproduce
Install any binaries with most plugins, including rust, python.
According to https://github.com/code-lever/asdf-rust/issues/14#issuecomment-438029075 , nodejs does a reshim sometimes.
Expected behavior
reshim should occur automatically whenever possible.
Actual behavior
Users are regularly wondering why the binaries they have installed are not available.
One very easy way to detect a reshim is needed is for plugins to expose a list of filenames which when modified indicate a reshim is needed.
Typically, the plugins would provide a list of lock filenames which may appear in the source tree.
A slightly more complicated approach is for plugins to expose a list of directories in the plugin installs area which are where new binaries will appear, and should be auto-reshimmed.
Current master supports pre/post command hooks (#434), you could use something like
This example will reshim after you execute cargo install
# in your $HOME/.asdfrc
post_rust_cargo = my_post_cargo_install_hook ${@}
#!/usr/bin/env bash
# This is my_post_cargo_install_hook
# when cargo was called with install as first argument, reshim
if [ "install" == "$1" ] ; then
asdf reshim rust
fi
Hi, I'm new to asdf and python and faced with this issue with python pip, searched and found this which points to here.
Anyways. For a possible global solution, would be possible to add and change the PATH to point to the currently active language/bin directory, this way, it would work for all language I suppose. What are the restrictions for this possible solution?
@tutume You are looking for asdf-direnv then.
Maybe reshim automatically after bundle and gem commands are run. Perhaps with install, uninstall (gem only), update sub-commands.
I added this and it seems to work
--- a/lib/commands/command-exec.bash
+++ b/lib/commands/command-exec.bash
@@ -25,6 +25,7 @@ shim_exec_command() {
if [ "$pre_status" -ne 0 ]; then
return "$pre_status"
fi
+ { while kill -0 $$ >/dev/null 2>&1; do sleep 1; done; asdf_run_hook "post_${plugin_name}_${shim_name}" "${shim_args[@]}"; } &
exec "$executable_path" "${shim_args[@]}"
}
# ~/.asdfrc
post_python_pip = ~/.local/bin/post_python_pip ${@}
# ~/.local/bin/post_python_pip
asdf reshim python "$(asdf current python | tr -s ' ' | cut -d' ' -f2)"