asdf: bug: asdf 0.10.1 can't find the commands directory on linux or macos using homebrew and fish

Describe the Bug

I just installed asdf through homebrew on linux using the fish shell. When I run asdf it tells me this

/home/linuxbrew/.linuxbrew/Cellar/asdf/0.10.1/libexec/bin/asdf: line 82: /home/linuxbrew/.linuxbrew/opt/asdf/lib/commands/command-help.bash: No such file or directory

the lib directory just has two files in it, no subdirectories. ls -l /home/linuxbrew/.linuxbrew/opt/asdf/lib/

asdf.fish
asdf.sh

I can tell that /home/linuxbrew/.linuxbrew/opt/asdf/libexec/lib has a commands directory, but it’s not looking in the libexec subfolder.

I can get this to work by editing

libexec/bin/asdf

adding libexec to the asdf_cmd_dir

find_asdf_cmd() {
  local asdf_cmd_dir
  asdf_cmd_dir="$(asdf_dir)/lib/commands"
find_asdf_cmd() {
  local asdf_cmd_dir
  asdf_cmd_dir="$(asdf_dir)/libexec/lib/commands"

and then editing libexec/lib/commands/command-help.bash

adding libexec to the help.txt path

asdf_help() {
  printf "version: %s\\n\\n" "$(asdf_version)"
  cat "$(asdf_dir)/help.txt"
}
asdf_help() {
  printf "version: %s\\n\\n" "$(asdf_version)"
  cat "$(asdf_dir)/libexec/help.txt"
}

and then editing libexec/lib/utils.bash

adding libexec to the version.txt path

asdf_version() {
  local version git_rev
  version="v$(cat "$(asdf_dir)/version.txt")"
  if [ -d "$(asdf_dir)/.git" ]; then
    git_rev="$(git --git-dir "$(asdf_dir)/.git" rev-parse --short HEAD)"
    printf "%s-%s\\n" "$version" "$git_rev"
  else
    printf "%s\\n" "$version"
  fi
}
asdf_version() {
  local version git_rev
  version="v$(cat "$(asdf_dir)/libexec/version.txt")"
  if [ -d "$(asdf_dir)/.git" ]; then
    git_rev="$(git --git-dir "$(asdf_dir)/.git" rev-parse --short HEAD)"
    printf "%s-%s\\n" "$version" "$git_rev"
  else
    printf "%s\\n" "$version"
  fi
}

Steps to Reproduce

  1. brew install asdf
  2. source /home/linuxbrew/.linuxbrew/opt/asdf/libexec/asdf.fish
  3. asdf

Expected Behaviour

it should execute the asdf command

Actual Behaviour

returns this error

/home/linuxbrew/.linuxbrew/Cellar/asdf/0.10.1/libexec/bin/asdf: line 82: /home/linuxbrew/.linuxbrew/opt/asdf/lib/commands/command-help.bash: No such file or directory

Environment

(asdf isn't working)

asdf plugins affected (if relevant)

(none)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 16
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve found a temporary workaround:

  1. Manually delete all shims: rm -rf ~/.asdf/shims
  2. Reshim them from scratch: asdf reshim

@Stratus3D I haven’t found the commit that caused it, but the issue stems from “hard-generating” the path to asdf installation and the path itself contains version number. For example:

#!/usr/bin/env bash
# asdf-plugin: erlang 24.2.1
exec /opt/homebrew/Cellar/asdf/0.9.0/libexec/bin/asdf exec "erl" "$@" # asdf_allow: ' asdf '

So whenever you upgrade asdf from brew, 0.9.0 dir just disappears and asdf fails to find it.

If I understand the logic in reshim.bash, this part right here doesn’t check if the directory is still valid:

https://github.com/asdf-vm/asdf/blob/788ccab5971cb828cf25364b0df5ed6f5e9e713d/lib/commands/reshim.bash#L91-L101=

One way to fix this is to switch from generating fixed prefix (/opt/homebrew/Cellar/asdf/0.10.1/ in the example above) to dynamically find the directory. But probably it’s something Homebrew formula should fix? 🤔

I’m having the same issue on OS X and running rm -rf ~/.asdf/shims && asdf reshim worked for me.

It’s seems a error with the new versions of asdf, I had a similar error:

/usr/local/Cellar/asdf/0.10.2/libexec/bin/asdf: line 82: /usr/local/Cellar/asdf/0.9.0/libexec/lib/commands/command-help.bash: No such file or directory

And solved by adding this to my ~/.zshrc file (you can just change for the version you need):

export ASDF_DIR=/usr/local/Cellar/asdf/0.10.2/libexec

And then:

asdf reshim

I just installed the latest version via homebrew as well and am getting a similar error:

/usr/local/Cellar/asdf/0.10.0/libexec is not a directory
/usr/local/Cellar/asdf/0.10.1/libexec/asdf.sh:.:35: no such file or directory: /usr/local/Cellar/asdf/0.10.0/libexec/lib/asdf.sh

In my setup, I am using zsh, and the error above happens upon sourcing my .zshrc file. I have tried reinstalling asdf, removing all existing shims, etc, but no luck. 😞

In macOS environment, it seems like there might be some kind of version number mismatch internally; after upgradeing to 0.10.1, sourcing asdf.fish resulted in an error like this:

.: Error encountered while sourcing file '/opt/homebrew/Cellar/asdf/0.10.0/libexec/lib/asdf.fish':                                  
.: No such file or directory

Setting ASDF_DIR to the correct path before sourcing asdf.fish worked for me as a temporary workaround.

# ~/.config/fish/config.fish

set -x ASDF_DIR '/opt/homebrew/Cellar/asdf/0.10.1/libexec'
source /opt/homebrew/opt/asdf/libexec/asdf.fish

In fish shell, remove $ASDF_DIR.

set -eg ASDF_DIR

This thread seems related to #531

Still awaiting feedback in potential fix PR #1236

@Stratus3D wouldn’t it makes sense to change $(asdf_dir) to \${ASDF_DIR} on line below so it would pick correct directory dynamically?

https://github.com/asdf-vm/asdf/blob/788ccab5971cb828cf25364b0df5ed6f5e9e713d/lib/commands/reshim.bash#L100

We still need to forcefully reshim all shims with new release for this to take place.