asdf-vm / asdf-vm/asdf

Automatically re-hash shell commands after installing new tool version

Open
#446 2 comments 0 reactions 1 assignee Claimed by @vic View on GitHub
enhancement
Dominant language
Go
Stars
25.6k
Forks
941
Avg merge
9h 24m
Merged PRs (30d)
3

Description

### Steps to reproduce

1) Install some tool using some other way (not through `asdf`)
2) Run the tool. At this point bash will hash the full path to the executable (so that next time it will avoid searching `$PATH`)
3) Install another version of the tool using `asdf`
4) Set the version you want to use, e.g. `asdf global x.y.z`
5) Run the tool.

### Expected behavior

I would expect asdf shim to take over and execute the global version I've configured.

### Actual behavior

Bash just takes the hashed executable path of the original tool, bypassing our shim. You can confirm this by running:

```bash
$ type
is hashed (/snap/bin/)
```

### Environment

**OS**: Linux / Windows

**asdf version**:

0.6.3

Most other version managers clear hashes after installing a new version of the tool, e.g. you can see `pyenv` does it [here](https://github.com/pyenv/pyenv/blob/d08c9cfb362c5a7e18a92acd2253a16935ad9a99/libexec/pyenv-sh-rehash#L21).

It's simply a matter of running `hash -r` (for bash, at least) after the installation is complete. This can easily puzzle users who are not familiar with executable path hashing in bash.

P.S. [Here](https://askubuntu.com/a/446583/610681) is a nice stackoverflow answer explaining path hashing in bash.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.