asdf: bug: 0.9.0 installation using homebrew missing lib folders/files

Describe the Bug

When installing the latest 0.9.0 release of asdf, none of the commands work.

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

It looks like it’s trying to reference files that aren’t there:

$ tree "${ASDF_DIR}/lib"
/opt/homebrew/opt/asdf/lib
├── asdf.fish
└── asdf.sh

I believe there’s supposed to be a commands/ directory in there and some other files based on the repo

Steps to Reproduce

Install the latest asdf (0.9.0) via homebrew brew install asdf or update to the latest.

Expected Behaviour

I believe the commands should have worked.

Actual Behaviour

No commands work

Environment

That command does not work for me

asdf plugins affected (if relevant)

no plugins works.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 67
  • Comments: 53 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I confirm that shims broken by Homebrew upgrade can be fixed with:

rm ~/.asdf/shims/*
asdf reshim

I confirm that shims broken by Homebrew upgrade can be fixed with:

rm ~/.asdf/shims/*
asdf reshim

Thanks, change asdf path and reshim works.

After the upgrade, I fixed it with the following. I hope this can also help others.

Setting up the correct the path

export ASDF_DIR="$(brew --prefix asdf)/libexec"
source $ASDF_DIR/asdf.sh

Fixing existing old shims

cd ~/.asdf/shims

Fixing all Shims after the upgrade with a small grep and replace

grep -rl 'exec /usr/local/Cellar/asdf/0.8.1_1' . | xargs sed -i '' 's|exec /usr/local/Cellar/asdf/0.8.1_1|exec /usr/local/opt/asdf|g'

Reload

source $HOME/.zshrc

I encountered this error too but I set ASDF_DIR previously to

export ASDF_DIR='/usr/local/opt/asdf'

it seems asdf.sh changed in the meantime and the correct ASDF_DIR now is:

export ASDF_DIR='/usr/local/opt/asdf/libexec'

This works well for me:

ASDF_DIR="$(brew --prefix asdf)/libexec"
. "$ASDF_DIR/asdf.sh"

Which is what the oh-my-zsh plugin does with @sshishov’s fix (https://github.com/ohmyzsh/ohmyzsh/pull/10481).

It does look like all of the missing files exist inside the libexec directory. I can confirm that just putting this in fixes it as @jonatan-ivanov suggested:

export ASDF_DIR='/usr/local/opt/asdf/libexec'

I use the asdf oh-my-zsh plugin, and I had to put that after oh-my-zsh is loaded. Perhaps it’s just something that needs to be fixed in the oh-my-zsh plugin?

I encountered this error too but I set ASDF_DIR previously to

export ASDF_DIR='/usr/local/opt/asdf'

it seems asdf.sh changed in the meantime and the correct ASDF_DIR now is:

export ASDF_DIR='/usr/local/opt/asdf/libexec'

If you’ve installed with Homebrew, then export ASDF_DIR='/opt/homebrew/opt/asdf/libexec' - this worked for me.

I think we should close this issue. It’s hard for a layperson to tell that this issue actually is fixed, and if you’re running into trouble, it’s because you’ve incorrectly configured a Homebrew asdf installation.

At the risk of overloading an already overloaded thread, here’s my take on the situation:

AFAICT, the goal is to create shims that never have to change: I don’t think there’s any interest (or even a good mechanism) for regenerating shims whenever you upgrade asdf (and it’s not like asdf reshim would even fix the problem, because of https://github.com/asdf-vm/asdf/issues/1115).

tl;dr, If you find that your shims mention a specific version of asdf, you’ve probably installed asdf with homebrew and are setting it up incorrectly.

Here’s a broken setup on zsh, but the same basic idea applies to any shell. Note how asdf 0.9.0 shows up in my shims. This works for now, but once a new version of asdf comes out, this will break:

$ cat ~/.asdf/shims/node  
#!/usr/bin/env bash
# asdf-plugin: nodejs 14.18.2
exec /opt/homebrew/Cellar/asdf/0.9.0/libexec/bin/asdf exec "node" "$@"

That’s because of this incorrect source directive in my ~/.zshrc:

$ grep asdf ~/.zshrc
source "$(brew --prefix asdf)/asdf.sh"

To fix this, you need to instead source an asdf.sh in a libexec directory (this is from the “ZSH & Homebrew” instructions on https://asdf-vm.com/guide/getting-started.html#_3-install-asdf):

$ grep asdf ~/.zshrc
source "$(brew --prefix asdf)/libexec/asdf.sh"

Then start a new terminal, and regenerate your shims (the rm is necessary because of https://github.com/asdf-vm/asdf/issues/1115):

$ rm -f ~/.asdf/shims/* && asdf reshim

And tada! My shims no longer mention a specific version of asdf:

$ cat ~/.asdf/shims/node
#!/usr/bin/env bash
# asdf-plugin: nodejs 14.18.2
exec /opt/homebrew/opt/asdf/libexec/bin/asdf exec "node" "$@"

IMO, this is very hard to understand, in part because it’s so easy for someone to source the wrong asdf.sh script. I think this will all get a little easier to understand when brew follows through on their plan to remove these placeholder scripts in August 2022. It’s also possible there’s a bug in how they’re generating the placeholder script, but I have already spent way too much time reading through issues this morning.

<shameless-self-promotion>If you are like me, and find shims confusing at best and annoying at worst, I encourage you to check out asdf-direnv and try out a shimless life!<shameless-self-promotion>

after fresh install, updating .zshrc i see this

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

I haven’t read this thread in a while as almost all issues with Homebrew are not an issue with any other mechanism of installing asdf and I am not a Homebrew user nor do we maintain the Homebrew Formulae/Cask/whatever.

It has been suggested this issue be closed. Quoting @jfly:

I think we should close this issue. It’s hard for a layperson to tell that this issue actually is fixed, and if you’re running into trouble, it’s because you’ve incorrectly configured a Homebrew asdf installation.

Naturally another issue for a different version number has been raised in https://github.com/asdf-vm/asdf/issues/1231 .

I agree that this is way too tricky to get right, and using a git installation of asdf seems a lot easier, but it’s annoying to have yet another thing to have to remember to periodically update.

Homebrew auto-updating is really screwing peoples days. Manually updating is an intentional act which should help users control when their systems might break.

I cannot begin to tell you all how much time I have spent on Homebrew related issues on this repo over the years.

I beg you to use the Git installation method and read the instructions carefully, lord only knows how many countless hours I have spent on those.

Thanks to those in this thread who have helped your fellow devs resolve their issues.

I’m thinking my takeaway from this is that it’s better to just install asdf directly instead of installing it via homebrew

@Codex- , instead of manually changing shims, you have to remove the shims folder and then run reshim. Regenerated shims will have symlink instead of hardcoded version. Example:

❯ cat ~/.asdf/shims/django-admin
#!/usr/bin/env bash
# asdf-plugin: python 3.10-dev
exec /usr/local/opt/asdf/libexec/bin/asdf exec "django-admin" "$@"

In addition to some of the issues seen here, I was experiencing this after updating to 0.9.0 and upgrading to new macos:

/Users/username/.asdf/shims/node: line 4: /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf: No such file or directory
/Users/username/.asdf/shims/node: line 4: exec: /opt/homebrew/Cellar/asdf/0.8.1_1/libexec/bin/asdf: cannot execute: No such file or directory

So had to replace all of the versions in the shims with 0.9.0 to get things working again: grep -rl /0.8.1_1/ /Users/username/.asdf/shims/ | xargs sed -i "" 's/\/0.8.1_1\//\/0.9.0\//g'

Hopefully, this helps someone

Bump into the same problem. Somehow unset ASDF_DIR works for my environment. (macOS 11.6)

I am not sure why find_asdf_cmd kept the previous ASDF_DIR after upgrade asdf formula to 0.9

I just sent in a PR to Homebrew to remove the broken placeholder scripts that are the source of all this confusion: https://github.com/Homebrew/homebrew-core/pull/112102

With these scripts gone, people with incorrect asdf setups will clearly see their source "$(brew --prefix asdf)/asdf.sh" fail, and that should be a clue to use the correct source directive (source "$(brew --prefix asdf)/libexec/asdf.sh").

And to anyone on this thread who just did a rm ~/.asdf/shims/* && asdf reshim, found that things were working, and moved on with your lives: your shims will still break the next time you upgrade asdf. Fix the way you source asdf, reshim one last time, and then you should hopefully never have to deal with this again. See my comment above for details on how to check if your shims are broken and how to fix them.

Hello guys, I guess we have to add libexec to the plugin. I have created the PR: https://github.com/ohmyzsh/ohmyzsh/pull/10481

The git repo contains the missing directory https://github.com/asdf-vm/asdf/tree/master/lib/commands but for some reason the homebrew version does not. I cloned the repo and copied in the folder to /usr/local/opt/asdf/lib/commands and now all works again. Guessing it’s missing from the recipe https://github.com/Homebrew/homebrew-core/blob/master/Formula/asdf.rb.

@jfly Thank you so much for your investigation and triaging of this complex issues which spans the interaction between Homebrew and asdf. Your explanatory post is a case study for some of the best technical explanations I have seen in a GitHub issues. This saved me so much time and grief. Thank you so much! 👏🏻

Asking users not to use the most popular dependency manager on MacOS doesn’t seem like a solution to this bug in asdf.

@AndrewRayCode

  • Its not a bug in asdf
  • Its Homebrew changing the file structure i.e different file locations and not updating files upon updates which is breaking asdf.
  • Basically, I think it’s reasonable to suggest those who change the behaviour of software should maintain their changes
  • Therefore it will be an issue until the Homebrew community solves the issue i.e I would guess they need to update all paths in files that they changed to the latest path they have stored asdf in under after updating.

Homebrew upgrade removes v0.10.1 under /opt/homebrew/Cellar/asdf/0.10.1/ then installs v0.10.2 /opt/homebrew/Cellar/asdf/0.10.2/ unfortunately the Homebrew formula script doesn’t update the shims scripts generated under ~/.asdf/ that use paths /opt/homebrew/Cellar/asdf/0.10.1/ to /opt/homebrew/Cellar/asdf/0.10.2/

The recommended/default way of installation git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2 Installs everything under ~/.asdf and no paths contain version numbers that could break Updating can be done via asdf update; asdf plugin update --all

Possible Homebrew fix The simple solution… I don’t know why the Homebrew formula doesn’t just create symbolic links to ~/.asdf from /opt/homebrew/Cellar/asdf/<version>/ that would maintain asdf’s file structure and paths in configuration and shims allowing homebrew to keep the application under homebrew/Celler. It probably breaks one of homebrew’s own standards.

Just to pin the gem of this thread again - this one did the trick for me 👍 https://github.com/asdf-vm/asdf/issues/1103#issuecomment-990795248

but it’s annoying to have yet another thing to have to remember to periodically update.

@jfly Create a script to do brew updates make it then call asdf update and update all asdf plugins from the one command line command.

I’m on an M1 mac and it seems asdf is installed to /opt/homebrew/opt/asdf but when I try to source that from my .zshrc, I still get errors. Does anyone know why or have a fix that will work on my setup?

@solidnerd either:

  • set ASDF_DIR to the location Homebrew installs:
    ASDF_DIR="/usr/local/opt/asdf/libexec"
    . "$ASDF_DIR/asdf.sh"
    
    or,
  • avoid setting ASDF_DIR and just source the configuration script
    . /usr/local/opt/asdf/libexec/asdf.sh
    

I think Homebrew has a custom merging process. The change is actually on the master branch: https://github.com/Homebrew/homebrew-core/commit/cd3d21ba3a2c1041b64191b82cee3bffcbe2efdf

Closing and re-opening the shell and reinstalling installed versions seems to have fixed this for me.