Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nathanpalmer opened this issue May 19, 2022 · 16 comments · Fixed by #1311
Labels
bug homebrew Affects Homebrew users

Comments

@nathanpalmer
Copy link

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)

@derekhubbard
Copy link

derekhubbard commented May 19, 2022

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. 😞

@nathanpalmer
Copy link
Author

Looks like my desktop on macOS just upgraded to 0.10.1 this morning

homebrew install
==> Upgrading asdf
  0.9.0 -> 0.10.1

==> Installing dependencies for asdf: coreutils and unixodbc
==> Installing asdf dependency: coreutils
==> Pouring coreutils--9.1.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/coreutils/9.1: 480 files, 13.3MB
==> Installing asdf dependency: unixodbc
==> Pouring unixodbc--2.3.11.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/unixodbc/2.3.11: 48 files, 2.3MB
==> Installing asdf
==> Pouring asdf--0.10.1.all.bottle.tar.gz
==> Caveats
To use asdf, add the following line to your ~/.config/fish/config.fish:
  source /opt/homebrew/opt/asdf/libexec/asdf.fish

Restart your terminal for the settings to take effect.

fish completions have been installed to:
  /opt/homebrew/share/fish/vendor_completions.d
==> Summary
🍺  /opt/homebrew/Cellar/asdf/0.10.1: 168 files, 714.3KB
==> Running `brew cleanup asdf`...
Removing: /opt/homebrew/Cellar/asdf/0.9.0... (150 files, 627.4KB)

and now i'm getting the same error

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

@nathanpalmer nathanpalmer changed the title bug: asdf 0.10.1 can't find the commands directory on linux using homebrew and fish bug: asdf 0.10.1 can't find the commands directory on linux or macos using homebrew and fish May 21, 2022
@Stratus3D
Copy link
Member

Thanks for reporting. Is there anyway for you to downgrade to version 0.10.0 with Brew to verify that it is in fact due to a change in version 0.10.1? Thanks!

For reference, here is the list of changes in 0.10.1 - https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md#0101-2022-05-17 I really don't know what change introduced a problem - and with the git installation method I have not observed a problem. don't invoke asdf inside asdf commands (#1208) (27f7ef7) is the only significant change, but I wouldn't expect it to introduce this problem.

@yuhr
Copy link

yuhr commented May 23, 2022

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

@nathanpalmer
Copy link
Author

I don't think there is a way to downgrade using homebrew, unless they are setup in a versioned way. Typically I'd try to install a lower version like this brew install asdf@0.9.0 but that recipe doesn't exist.

My previous config.fish was set to do this

set -x ASDF_DIR (brew --prefix asdf)
source $ASDF_DIR/asdf.fish

Looks like according to the latest instructions that that might be outdated. I don't have my homebrew installed anymore to check though. I just changed my installation to install from git instead of homebrew and it seemed to work well.

@deivid-rodriguez
Copy link

For the record, I run brew edit asdf, then changed the version in the brew recipe, then run brew install asdf --build-from-source --verbose --debug, then got a error about the checksum, then edited the checksum too and retried and hopefully I managed to properly install 0.9.0 and 0.10.0 by doing this. But I still got the same error.

I didn't dig further and changed my installation too to install from git and it worked well.

@Stratus3D
Copy link
Member

If anyone is familiar with Homebrew the formula is here - https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/asdf.rb. I don't see any obvious issues there.

@jrogov
Copy link

jrogov commented May 24, 2022

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? 🤔

@jrogov
Copy link

jrogov commented May 24, 2022

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

exec $(asdf_dir)/bin/asdf exec "${executable_name}" "\$@" # asdf_allow: ' asdf '

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

jrogov added a commit to jrogov/asdf that referenced this issue May 24, 2022
Switch from generating static paths to asdf exec file to using user's ASDF_DIR
env variable to dynamically determine asdf location.

It ensures that regardless of updates for asdf installed on user system path
won't rely on single correct path to asdf. Since the path might contain version
number (e. g. `/opt/homebrew/Cellar/asdf/0.9.0/libexec/bin/asdf`), asdf
installation would break as soon as new release is installed.

Fixes asdf-vm#1231
@jthegedus jthegedus added the homebrew Affects Homebrew users label May 24, 2022
@kevdowney
Copy link

kevdowney commented Jun 11, 2022

I got the same issue, seems like shims are not updated properly when using brew since the versions is captured in the path.

Using 0.10.2 the shim was still pointing to non-existent 0.9.0.

~/asdf/shims/java: line 7: /usr/local/Cellar/asdf/0.9.0/libexec/bin/asdf: No such file or directory

Running asdf reshim java <version> does nothing to the actual exec command.

➜  spring-app asdf reshim java corretto-17.0.3.6.1
➜  spring-app cat ~/.asdf/shims/java
#!/usr/bin/env bash
# asdf-plugin: java corretto-11.0.14.10.1
# asdf-plugin: java corretto-8.322.06.1
# asdf-plugin: java corretto-11.0.15.9.1
# asdf-plugin: java corretto-17.0.3.6.1
# asdf-plugin: java graalvm-22.1.0+java17
exec /usr/local/Cellar/asdf/0.9.0/libexec/bin/asdf exec "java" "$@"

To fix I had to rm ~/.asdf/shims/<plugin> then reshim asdf reshim java <version> then it's fixed.

➜  spring-app rm ~/.asdf/shims/java
➜  spring-app asdf reshim java corretto-17.0.3.6.1
➜  spring-app cat ~/.asdf/shims/java
#!/usr/bin/env bash
# asdf-plugin: java corretto-17.0.3.6.1
exec /usr/local/Cellar/asdf/0.10.2/libexec/bin/asdf exec "java" "$@" # asdf_allow: ' asdf '
java -version
openjdk version "17.0.3" 2022-04-19 LTS
OpenJDK Runtime Environment Corretto-17.0.3.6.1 (build 17.0.3+6-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.3.6.1 (build 17.0.3+6-LTS, mixed mode, sharing)

@negibouze
Copy link

I encountered the similar error when I updated to 0.10.2 via Homebrew.
However, in my case, starting a new shell solved the problem.

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

@spacecowb0y
Copy link

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

@jthegedus
Copy link
Contributor

jthegedus commented Jun 21, 2022

This thread seems related to #531

Still awaiting feedback in potential fix PR #1236

@dylan-chong
Copy link
Contributor

Dupe of #1115. Think they're trying to use that as the main issue.

@f2acode
Copy link

f2acode commented Aug 9, 2022

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

jthegedus pushed a commit that referenced this issue Dec 20, 2022
Co-authored-by: James Hegedus <jthegedus@hey.com>
Fixes #1115
Fixes #1231
Fixes #1286
hyperupcall pushed a commit to fox-forks/asdf that referenced this issue Dec 21, 2022
Co-authored-by: James Hegedus <jthegedus@hey.com>
Fixes asdf-vm#1115
Fixes asdf-vm#1231
Fixes asdf-vm#1286
@1natsu172
Copy link

In fish shell, remove $ASDF_DIR.

set -eg ASDF_DIR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug homebrew Affects Homebrew users
Projects
None yet