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: Error after updating to 0.16.1 using Homebrew and fish shell #1895

Open
crcastle opened this issue Feb 6, 2025 · 13 comments
Open

bug: Error after updating to 0.16.1 using Homebrew and fish shell #1895

crcastle opened this issue Feb 6, 2025 · 13 comments
Labels

Comments

@crcastle
Copy link

crcastle commented Feb 6, 2025

Describe the Bug

I receive the following error before every shell prompt and when I open a new shell:

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

It looks like maybe this is a breaking change when going from 0.15 to 0.16? The Getting Started instructions for pre-0.16.0 page says to use the following to install asdf, which I did when I installed it a long time ago.

Image

Should I now remove that source line? I do not see a libexec directory in /opt/homebrew/opt/asdf/ after running brew upgrade today.

Apologies if I missed it, but I didn't see any instructions to change or remove that line in the Upgrading to 0.16.0 page.

Steps to Reproduce

  1. While using fish shell, install a version of asdf less than 0.16.0 using Homebrew.
  2. Follow instructions at https://asdf-vm.com/guide/getting-started-legacy.html#_3-install-asdf in the "Fish & Homebrew" section to complete the asdf installation. i.e. run echo -e "\nsource "(brew --prefix asdf)"/libexec/asdf.fish" >> ~/.config/fish/config.fish
  3. Upgrade asdf using brew upgrade.
  4. Run asdf version to ensure you now have a version >= 0.16.0.
  5. Notice the error on every prompt and when starting a new shell (see actual behavior section below).

Expected Behaviour

No error on prompt or when starting a new shell.

Actual Behaviour

Errors on every prompt and when starting a new shell. For example:

Last login: Wed Feb  5 16:10:14 on ttys003
source: Error encountered while sourcing file '/opt/homebrew/opt/asdf/libexec/asdf.fish':
source: No such file or directory
~
❯ source: Error encountered while sourcing file '/opt/homebrew/opt/asdf/libexec/asdf.fish':
source: Error encountered while sourcing file '/opt/homebrew/opt/asdf/libexec/asdf.fish':
sourcesource: : No such file or directoryNo such file or directory
~
❯ echo "hi"
hi

~
❯ source: Error encountered while sourcing file '/opt/homebrew/opt/asdf/libexec/asdf.fish':
~
❯

Environment

❯ asdf info
OS:
Darwin cheddar.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000 arm64

SHELL:
fish, version 3.7.1

BASH VERSION:
5.2.37(1)-release

ASDF VERSION:
0.16.1

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/crcastle/.asdf
ASDF_CONFIG_FILE=/Users/crcastle/.asdfrc

ASDF INSTALLED PLUGINS:
crystal   https://github.com/asdf-community/asdf-crystal.git 6b5c52ad42c176f9415bf00cceec2d825d1ff92b
deno      https://github.com/asdf-community/asdf-deno.git    fec2a081b00f98490bdff9aa0cbe04bc313a8639
golang    https://github.com/kennyp/asdf-golang.git          0e86b1d5a7b2bf9ce39fc43b0ff6a744eaa269b8
nodejs    https://github.com/asdf-vm/asdf-nodejs.git         c5b7c40ea9ffc3470f44b6cf04a21e45dd6f81de
ruby      https://github.com/asdf-vm/asdf-ruby.git           37e32d1fc28a69173fba7f9a5ea434900cc36c1b

asdf plugins affected (if relevant)

No response

@crcastle crcastle added the bug label Feb 6, 2025
@dhoppe
Copy link

dhoppe commented Feb 6, 2025

The location of the file asdf.fish has changed.

dhoppe at mac-mini in ~
❯ cd /opt/homebrew/opt/asdf

dhoppe at mac-mini in homebrew/opt/asdf on  stable
❯ tree
.
├── bin
│   └── asdf
├── CHANGELOG.md
├── etc
│   └── bash_completion.d
│       └── asdf
├── INSTALL_RECEIPT.json
├── LICENSE
├── README.md
├── sbom.spdx.json
└── share
    ├── fish
    │   └── vendor_completions.d
    │       └── asdf.fish
    └── zsh
        └── site-functions
            └── _asdf

I also had to modify the file ~/.config/fish/config.fish. Otherwise the shims are not working.

# ASDF configuration code
if test -z $ASDF_DATA_DIR
    set _asdf_shims "$HOME/.asdf/shims"
else
    set _asdf_shims "$ASDF_DATA_DIR/shims"
end

# Do not use fish_add_path (added in Fish 3.2) because it
# potentially changes the order of items in PATH
if not contains $_asdf_shims $PATH
    set -gx --prepend PATH $_asdf_shims
end
set --erase _asdf_shims

@thomas-merz
Copy link

Adding

export ASDF_DATA_DIR="$HOME/.asdf"
export PATH="$ASDF_DATA_DIR/shims:$PATH"

to my ~/.bashrc and removing

. /opt/homebrew/opt/asdf/libexec/asdf.sh

from https://asdf-vm.com/guide/upgrading-to-v0-16.html#_3-add-asdf-data-dir-shims-to-the-front-of-your-path helped.

Plus

asdf reshim

to reshim all existing commands due to:

$ releasor patch
/Users/thomas.merz/.asdf/shims/releasor: line 3: /opt/homebrew/opt/asdf/libexec/bin/asdf: No such file or directory

@d34dh0r53
Copy link

The fix outlined by @thomas-merz works for ZSH as well

Thank you!

drmohundro added a commit to drmohundro/dotfiles that referenced this issue Feb 6, 2025
@crcastle
Copy link
Author

crcastle commented Feb 7, 2025

Thanks all. Based on @dhoppe's comment, I made the following changes. I'm guessing these will resolve Homebrew + fish shell users' similar problems.

- source (brew --prefix asdf)/libexec/asdf.fish
+ source (brew --prefix asdf)/share/fish/vendor_completions.d/asdf.fish

+ # ASDF configuration code
+ if test -z $ASDF_DATA_DIR
+     set _asdf_shims "$HOME/.asdf/shims"
+ else
+     set _asdf_shims "$ASDF_DATA_DIR/shims"
+ end
+ 
+ # Do not use fish_add_path (added in Fish 3.2) because it
+ # potentially changes the order of items in PATH
+ if not contains $_asdf_shims $PATH
+     set -gx --prepend PATH $_asdf_shims
+ end
+ set --erase _asdf_shims

Thanks @Stratus3D and other contributors to asdf. Feel free to close this. My blocking issue is resolved, but also feel free to keep it open if you want as an issue to update the migration docs.

And for what it's worth, my config.fish was getting too long and messy, so I keep tool-specific config in a conf.d folder. e.g. for asdf, I made the above changes in ~/.config/fish/conf.d/asdf.fish

@azat-io
Copy link

azat-io commented Feb 8, 2025

The same problem with Zsh

@azat-io
Copy link

azat-io commented Feb 8, 2025

/Users/azat/.zshrc:.:55: no such file or directory: /opt/homebrew/opt/asdf/libexec/asdf.sh
which asdf
/opt/homebrew/bin/asdf

@agrberg
Copy link

agrberg commented Feb 8, 2025

@azat-io I experienced the same and wrote how I fixed it in #785 (comment)

@gtnbssn
Copy link

gtnbssn commented Feb 9, 2025

I made the changes in @crcastle last post and it got me rid of the original error with the file not being in the expected location, but I am now getting a lot of these:

asdf complete: too many arguments
~/.config/fish/completions/asdf.fish (line 74): 
complete -f -c asdf -n __fish_asdf_needs_command -a plugin update -d "Update plugin"

I am getting these for all subcommands with spaces, such as plugin update, plugin list, etc.

I have tried refreshing the completions with asdf completion fish > ~/.config/fish/completions/asdf.fish as the documentation says, but it didn't help. Any clue?

@crcastle
Copy link
Author

crcastle commented Feb 9, 2025

@gtnbssn yep, sadly, the 0.16.2 release from yesterday (or the day before?) broke with the changes that I recommended above to fix the 0.16.1 release. 🫠

I haven't had time to look into the details or fix it, so I just disabled command completion for now. In ~/.config/fish/config.fish (or ~/.config/fish/conf.d/asdf.fish if you use that), comment out the line that loads the completions. For me that was

- source (brew --prefix)/opt/asdf/share/fish/vendor_completions.d/asdf.fish
+ #source (brew --prefix)/opt/asdf/share/fish/vendor_completions.d/asdf.fish

Looks like your's might be different, but you should similarly be able to just comment out the line that loads the completions.

@gtnbssn
Copy link

gtnbssn commented Feb 9, 2025

Thanks for the crazy fast answer @crcastle!

Ok sounds like a different bug then. It looks like completions for subcommands in fish can get complicated though...

I manually reverted the changes here: 2f806de to silence the errors and i will just be typing the commands when I have to for now.

@vigenere23
Copy link

/Users/azat/.zshrc:.:55: no such file or directory: /opt/homebrew/opt/asdf/libexec/asdf.sh
which asdf
/opt/homebrew/bin/asdf

Related to new 0.16.0 executable?

@dustinfarris
Copy link

Added to config.fish

set --export ASDF_DATA_DIR $HOME/.asdf
fish_add_path --prepend $ASDF_DATA_DIR/shims

and then

asdf reshim

rnakamine added a commit to rnakamine/dotfiles that referenced this issue Feb 15, 2025
nakahararuu added a commit to nakahararuu/dotfiles that referenced this issue Feb 22, 2025
@puzzlemoondev
Copy link

Added to config.fish

set --export ASDF_DATA_DIR $HOME/.asdf
fish_add_path --prepend $ASDF_DATA_DIR/shims

and then

asdf reshim

I had to use --move for prepending to work. if the shim path is already in paths --prepend will do nothing, which's my case.

fish_add_path --move $ASDF_DATA_DIR/shims

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants