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
- brew install asdf
- source /home/linuxbrew/.linuxbrew/opt/asdf/libexec/asdf.fish
- 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
- fix: Remove static paths to asdf for shims 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 regardl... — committed to jrogov/asdf by jrogov 2 years ago
- fix: `reshim` did not rewrite executable path (#1311) Co-authored-by: James Hegedus <jthegedus@hey.com> Fixes https://github.com/asdf-vm/asdf/issues/1115 Fixes https://github.com/asdf-vm/asdf/issue... — committed to asdf-vm/asdf by dylan-chong 2 years ago
- fix: `reshim` did not rewrite executable path (#1311) Co-authored-by: James Hegedus <jthegedus@hey.com> Fixes https://github.com/asdf-vm/asdf/issues/1115 Fixes https://github.com/asdf-vm/asdf/issue... — committed to fox-forks/asdf by dylan-chong 2 years ago
I’ve found a temporary workaround:
rm -rf ~/.asdf/shims
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:
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:And solved by adding this to my
~/.zshrc
file (you can just change for the version you need):And then:
I just installed the latest version via homebrew as well and am getting a similar error:
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
, sourcingasdf.fish
resulted in an error like this:Setting
ASDF_DIR
to the correct path before sourcingasdf.fish
worked for me as a temporary workaround.In fish shell, remove
$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.