asdf-vm / asdf

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
https://asdf-vm.com/
MIT License
22k stars 782 forks source link

bug: 0.9.0 installation using homebrew missing lib folders/files #1103

Closed ksmithut closed 2 years ago

ksmithut commented 2 years ago

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.

sahina commented 2 years ago

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
zane commented 2 years ago

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

jonatan-ivanov commented 2 years ago

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'
orignaux commented 2 years ago

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.

ksmithut commented 2 years ago

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?

sshishov commented 2 years ago

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

jthegedus commented 2 years ago

@ericbn could this be related to changes in #1008 ?

dkam commented 2 years ago

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.

sahina commented 2 years ago

@dkam that worked for me too, mine was export ASDF_DIR=$(brew --prefix asdf) changed to export ASDF_DIR='/usr/local/opt/asdf/libexec' and it works now.

kaxing commented 2 years ago

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

jthegedus commented 2 years ago

I believe #1008 was part of an incremental improvement to the core of asdf to better support the Homebrew Formulae. I believe there needs to be an accompanying update on the Homebrew side, but not clear on what it is since I am not a Homebrew user.

Can a Brewer look into what @ericbn was trying to achieve with #1008 and lend a hand in resolving this?

orien commented 2 years ago

1008 allows users to specify an ASDF_DIR value that asdf will respect.

In https://github.com/Homebrew/homebrew-core/pull/81664, this feature was used to support moving the installation to /usr/local/opt/asdf/libexec/. Unfortunately, this is a breaking change for downstream users of Homebrew and asdf as we'll all need to update our shell environments to ensure ASDF_DIR points to this new location.

orien commented 2 years ago

The Homebrew post-install message says:

To use asdf, add the following line to your ~/.zshrc:

. /usr/local/opt/asdf/libexec/asdf.sh

Restart your terminal for the settings to take effect.

Perhaps this is a preferable approach to manually setting the ASDF_DIR environment variable.

orien commented 2 years ago

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

jthegedus commented 2 years ago

Glad everyone is agreeing on a solution :)

As I understand from reading this thread, the main change the core should make is a documentation update to tell new users to

Add . $(brew --prefix asdf)/libexec/asdf.sh to your ~/.bashrc or ~/.zshrc file.

Additionally, this update won't affect existing users as it includes a script to rewrite the old entrypoint to the new entrypoint at libexec/asdf.sh?

Is my understanding correct?

This is my comment on https://github.com/Homebrew/homebrew-core/pull/81664#issuecomment-889527721

It seems the changes in #1008 relied upon https://github.com/Homebrew/homebrew-core/pull/81664 to be merged for it to not be a breaking change. Not sure why https://github.com/Homebrew/homebrew-core/pull/81664 didn't end up getting merged.

If someone could open a new PR with the code in https://github.com/Homebrew/homebrew-core/pull/81664 as that would resolve everyone's issue.

orien commented 2 years ago

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

orien commented 2 years ago

1008 allows users to specify an ASDF_DIR value that asdf will respect.

In https://github.com/Homebrew/homebrew-core/pull/81664, this feature was used to support moving the installation to /usr/local/opt/asdf/libexec/. Unfortunately, this is a breaking change for downstream users of Homebrew and asdf as we'll all need to update our shell environments to ensure ASDF_DIR points to this new location.

I'm not sure my initial estimation of the situation was correct. I now think the situation is as follows:

  1. the asdf.sh script overwrites the ASDF_DIR variable in version 0.8.1 (and prior)
  2. many people install asdf via Homebrew (at /usr/local/opt/asdf)
  3. these people configure their environment (custom or via plugins) by setting ASDF_DIR:
    ASDF_DIR="/usr/local/opt/asdf"
    . "$ASDF_DIR/asdf.sh"
  4. The PR Homebrew/homebrew-core#81664 is merged on Aug 7. This changes the asdf installation directory from /usr/local/opt/asdf to usr/local/opt/asdf/libexec. This change includes pointer scripts for backwards compatibility. For example, the /usr/local/opt/asdf/asdf.sh script executes /usr/local/opt/asdf/libexec/asdf.sh

    This works with the above configuration because, although the ASDF_DIR value is now incorrect, the /usr/local/opt/asdf/libexec/asdf.sh script actually ignores it and re-sets ASDF_DIR based on location of the script to the correct value.

  5. asdf v0.9.0 is released on Dec 4 via Homebrew. In this new version, the asdf.sh script now acknowledges externally set ASDF_DIR values. Unfortunately, this doesn't work for us Homebrew users who have incorrectly configured ASDF_DIR="/usr/local/opt/asdf" in our dotfiles.
solidnerd commented 2 years ago

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
solidnerd commented 2 years ago

1008 allows users to specify an ASDF_DIR value that asdf will respect.

In Homebrew/homebrew-core#81664, this feature was used to support moving the installation to /usr/local/opt/asdf/libexec/. Unfortunately, this is a breaking change for downstream users of Homebrew and asdf as we'll all need to update our shell environments to ensure ASDF_DIR points to this new location.

I'm not sure my initial estimation of the situation was correct. I now think the situation is as follows:

  1. the asdf.sh script overwrites the ASDF_DIR variable in version 0.8.1 (and prior)
  2. many people install asdf via Homebrew (at /usr/local/opt/asdf)
  3. these people configure their environment (custom or via plugins) by setting ASDF_DIR:
    ASDF_DIR="/usr/local/opt/asdf"
    . "$ASDF_DIR/asdf.sh"
  4. The PR Homebrew/homebrew-core#81664 is merged on Aug 7. This changes the asdf installation directory from /usr/local/opt/asdf to usr/local/opt/asdf/libexec. This change includes pointer scripts for backwards compatibility. For example, the /usr/local/opt/asdf/asdf.sh script executes /usr/local/opt/asdf/libexec/asdf.sh This works with the above configuration because, although the ASDF_DIR value is now incorrect, the /usr/local/opt/asdf/libexec/asdf.sh script actually ignores it and re-sets ASDF_DIR based on location of the script to the correct value.
  5. asdf v0.9.0 is released on Dec 4 via Homebrew. In this new version, the asdf.sh script now acknowledges externally set ASDF_DIR values. Unfortunately, this doesn't work for us Homebrew users who have incorrectly configured ASDF_DIR="/usr/local/opt/asdf" in our dotfiles.

@orien In simple terms it would mean that we need only to unset the ASDF_DIR ?

OmriSama commented 2 years ago

Anyone on Homebrew + Oh-My-Zsh figured out what to do about command-help? Or asdf/lib/commands?

orien commented 2 years ago

@OmriSama For Homebrew + Oh My Zsh:

  1. apply the fix in https://github.com/ohmyzsh/ohmyzsh/pull/10481 (hopefully this will be merged soon)
  2. start a new shell
orien commented 2 years ago

@solidnerd either:

keldin-coding commented 2 years ago

So I did the "avoid setting ASDF_DIR option" and put this in my ~/.zshrc file to replace the old version of this that was . /usr/local/opt/asdf/asdf.sh:

. /usr/local/opt/asdf/libexec/asdf.sh

and asdf commands work 🎊, though asdf on its own does output the following:

RESOURCES
GitHub: https://github.com/asdf-vm/asdf
Docs:   https://asdf-vm.com
find: /Users/lirossarvet/.asdf/plugins/crystal/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/elixir/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/erlang/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/golang/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/lua/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/nodejs/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/ruby/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/tanka/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/terraform/lib/commands: No such file or directory
find: /Users/lirossarvet/.asdf/plugins/yarn/lib/commands: No such file or directory

Is that related to this?

orien commented 2 years ago

That's a separate issue. See #1101. A fix has been merged and will be included in the next release.

keldin-coding commented 2 years ago

@orien ah! Thank you, sorry I missed that one.

mgmodell commented 2 years ago

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?

kushalpandya commented 2 years ago

I'm on M1 Max MBP as well but I'm using Rosetta terminal and facing the same issue, ran brew upgrade (where Homebrew is installed under Rosetta) which ended up upgrading asdf too and now I'm seeing following error:

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 tried several workarounds as mentioned in comments above but it doesn't help. I can manually install v0.8.1 (via git clone) but my ~/.asdf dir is not empty and has many shims added.

Update

I had oh-my-zsh installed and asdf plugin enabled, so the fix needed was to manually update ~/.oh-my-zsh/plugins/asdf/asdf.plugin.zsh as per this PR https://github.com/ohmyzsh/ohmyzsh/pull/10481/ and it fixed the problem. Sorry for the noise. 🙂

hoxu commented 2 years ago

Is this the same issue? I started seeing this after upgrading with homebrew to 0.9.0:

$ kubectl
/Users/username/.asdf/shims/kubectl: line 5: /usr/local/Cellar/asdf/0.8.1_1/libexec/bin/asdf: No such file or directory
ericbn commented 2 years ago

There is a conflict between the Oh-My-Zsh plugin, Homebrew with https://github.com/Homebrew/homebrew-core/pull/81664, and asdf with #1008 (which was released with asdf v0.9.0).

With #1008, asdf will respect any ASDF_DIR previously set.

And with https://github.com/Homebrew/homebrew-core/pull/81664, the ASDF_DIR changed to /usr/local/opt/asdf/libexec.

The issue reported by lirossarvet above seems to be a separate issue. Didn't investigate this one yet, but I'm having the same issue too. EDIT: Oh, I see this will be fixed with #1101.

Codex- commented 2 years ago

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

sshishov commented 2 years ago

@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" "$@"
Codex- commented 2 years ago

^ good to know, have done this now, cheers

hoxu commented 2 years ago

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

rm ~/.asdf/shims/*
asdf reshim
Ppang0405 commented 2 years ago

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

rm ~/.asdf/shims/*
asdf reshim

Thanks, change asdf path and reshim works.

ghost commented 2 years ago

I ran into the same problem, but I'm neither a Bash nor a Zsh user; instead; I use the Fish shell.

asdf error ``` node-v17.3.0-darwin-x64.tar.gz: OK Unknown command: `asdf reshim nodejs 17.3.0` /usr/local/Cellar/asdf/0.9.0/libexec/bin/asdf: line 82: /Users/fibric/.asdf/lib/commands/command-help.bash: No such file or directory version 17.3.0 is not installed for nodejs ```

As stated in the getting started docs, I source the file directly and never had to maintain a ASDF_DIR env variable.

install instructions ![asdf-vm com_guide_getting-started html](https://user-images.githubusercontent.com/623932/146691920-a44b10ec-8b99-4cf8-b4fe-a6cac9f77bcc.png)

For now, I helped myself by symlinking the 'missing' lib folder into my users ~/.asdf folder. ln -s /usr/local/Cellar/asdf/0.9.0/libexec/lib/ ~/.asdf/lib

asdf info ``` asdf info OS: Darwin Dennys-MacBook-Pro.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64 i386 MacBookPro16,2 Darwin SHELL: fish, version 3.3.1 ASDF VERSION: v0.9.0 ASDF ENVIRONMENT VARIABLES: ASDF INSTALLED PLUGINS: crystal https://github.com/asdf-community/asdf-crystal.git master ff6bec9 deno https://github.com/asdf-community/asdf-deno.git master f55ffbf elixir https://github.com/asdf-vm/asdf-elixir.git master 8d018f2 erlang https://github.com/asdf-vm/asdf-erlang.git master 255743c grain https://github.com/cometkim/asdf-grain.git main 4330993 julia https://github.com/rkyleg/asdf-julia.git master b702779 nodejs https://github.com/asdf-vm/asdf-nodejs.git master 54113a9 pnpm https://github.com/jonathanmorley/asdf-pnpm.git master 2349db8 python https://github.com/danhper/asdf-python.git master 57a4d72 ruby https://github.com/asdf-vm/asdf-ruby.git master de87a40 yarn https://github.com/twuni/asdf-yarn.git main 376c540 ```
jfly commented 2 years ago

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>

axelson commented 2 years ago

@jfly I used to use source "$(brew --prefix asdf)/asdf.sh" directly in my .zshrc but I removed it to speed up my zsh startup time. Although it seems that brew --prefix asdf is faster now than it used to be, but 32ms (how long it takes on my current MacBook Air) is still a decent chunk of time to add to the startup of every shell. Is there a "correct" way that doesn't require executing a binary on every shell startup?

jfly commented 2 years ago

@jfly I used to use source "$(brew --prefix asdf)/asdf.sh" directly in my .zshrc

For the record, this looks like the wrong source directive. I'd expect libexec to show up in there somewhere.

but I removed it to speed up my zsh startup time

Did you replace it with something else? Or are you just using asdf with no special shell setup? If so, I think that'll work (because homebrew probably put asdf in your PATH), but I expect you'll find that asdf shell doesn't work, and that your shims all mention a version specific version of asdf.

Is there a "correct" way that doesn't require executing a binary on every shell startup

I don't know. I guess you could inline whatever brew --prefix asdf returns? On my machine, it returns /opt/homebrew/opt/asdf, which looks like something that's unlikely to change? But I don't know enough about homebrew to say that with any certainty.

andrewcrook commented 2 years ago

Is there a "correct" way that doesn't require executing a binary on every shell startup

yes

You can just go through the scripts and use the expanded paths, adding to PATH, the ENVs etc and add them directly into your .zshrc (other shells are avalible). It does shave a hundred ms esp not calling brew. The issue with the homebrew version is the way homebrew installs different versions of asdf. It uses version numbers in the paths which change every major update thus breaking hardcode paths etc. The additional/modified scripts in the homebrew version get around this.

An alternative might be to install asdf from script/git outside of homebrew and, which has a more generic path and use asdf’s built in update (asdf update)(cron job). If these paths are more generic then hardcoded paths etc are less likely to break.

Personally I don't like package managers managing package managers if it can be avoided.

installing outside homebrew (simple)

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.9.0

then do the same as below but with $HOME/.asdf/asdf.sh I don't actually think there this is much to speed things up

homebrew version (messy)

replace brew --prefix asdf with its output /opt/homebrew/opt/asdf NOTE: this will be a different path on Intel Macs /lib/homebrew/ iirc

regarding

source /opt/homebrew/opt/asdf/asdf.sh
source /opt/homebrew/opt/asdf/etc/bash_completion.d/asdf.bash

Up to here is probably the biggest save. The rest probably not so much and you start to get into breakable paths

asdf.sh it just calls /opt/homebrew/Cellar/asdf/0.9.0/libexec/asdf.sh you could hardcode in you .zshrc it but future versions might break it. taking it further /opt/homebrew/Cellar/asdf/0.9.0/libexec/asdf.sh looks like just just add binary and shims to PATH and runs an initialisation script NOTE: 0.9.0 in path "${ASDF_DIR}/lib/asdf.sh” -> /opt/homebrew/Cellar/asdf/0.9.0/libexec/lib/asdf.sh this contains the important function asdf() which is called from commandline. could also go into zshrc

I think the brew call would be the biggest save or just install adfs from git. Anyway you get the gist ....

axelson commented 2 years ago

@jfly I just tried your full directions again and my shims still have the asdf version in them:

jason@Jasons-Work-MacBook-Air-7 config % cat ~/.zshrc
#. /opt/homebrew/opt/asdf/libexec/asdf.sh
export KERL_CONFIGURE_OPTIONS="--without-javac --with-ssl=/opt/homebrew/opt/openssl@1.1"

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

#. $(brew --prefix asdf)/libexec/asdf.sh
source "$(brew --prefix asdf)/libexec/asdf.sh"
jason@Jasons-Work-MacBook-Air-7 config % zsh
jason@Jasons-Work-MacBook-Air-7 config % echo $ASDF_DIR
/opt/homebrew/Cellar/asdf/0.10.0/libexec
jason@Jasons-Work-MacBook-Air-7 config % rm -f ~/.asdf/shims/* && asdf reshim
zsh: sure you want to delete all 71 files in /Users/jason/.asdf/shims [yn]? y
jason@Jasons-Work-MacBook-Air-7 config % cat ~/.asdf/shims/dotenv
#!/usr/bin/env bash
# asdf-plugin: ruby 3.0.2
exec /opt/homebrew/Cellar/asdf/0.10.0/libexec/bin/asdf exec "dotenv" "$@"
axelson commented 2 years ago

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

andrewcrook commented 2 years ago

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

@axelson That's what I did it's much better in my view. HomeBrew version keeps breaking, like it did today with v0.10.1 , because the version number is hardcoded in paths in various scripts.

My advice install via git into .asdf in the users home directory and use asdf update (which updates via git).

jfly commented 2 years ago

@axelson, darn! I'm not sure, but I wonder if the reason that didn't work for you is because you started zsh inside of a running zsh (which perhaps already had some problematic environment variables from the incorrect setup of asdf). I wonder if something different would have happened if you had instead started a completely fresh terminal instance?

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.

andrewcrook commented 2 years ago

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.

jthegedus commented 2 years ago

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.

kabirbaidhya commented 2 years ago

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

XA21X commented 2 years ago

I found it quite surprising that reshim by itself doesn't do the same thing as deleting the shims first. :O

I encountered broken paths after switching from Homebrew to installing asdf using chezmoi external.

AndrewRayCode commented 2 years ago

I don't understand something - no other homebrew library I've used has had any issue like this, nor is the ~/.asdf/shims a brew path. I just got this again on v0.10.2. Is this issue fixed after v0.10.2? Asking users not to use the most popular dependency manager on MacOS doesn't seem like a solution to this bug in asdf.

andrewcrook commented 2 years ago

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

@AndrewRayCode

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 ~/.asdfand 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.

jfly commented 2 years ago

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.