asdf icon indicating copy to clipboard operation
asdf copied to clipboard

Auto reshim

Open jayvdb opened this issue 7 years ago • 9 comments

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.

jayvdb avatar Nov 28 '18 03:11 jayvdb

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

vic avatar Jan 19 '19 20:01 vic

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 avatar Nov 05 '19 22:11 tutume

@tutume You are looking for asdf-direnv then.

vic avatar Nov 06 '19 00:11 vic

@tutume You are looking for asdf-direnv then.

Thanks. Gonna have a look.

tutume avatar Nov 08 '19 15:11 tutume

Maybe reshim automatically after bundle and gem commands are run. Perhaps with install, uninstall (gem only), update sub-commands.

akostadinov avatar Sep 22 '21 08:09 akostadinov

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)"

jtzero avatar Sep 24 '21 00:09 jtzero