Open5

asdfがうまく起動できなくなった

hitochan777hitochan777

brewであるツールをインストールしてからzsh起動時に下記のエラーでasdfがうまくhookできなくなった。

/home/my-user/.zshrc:.:158: no such file or directory: /home/linuxbrew/.linuxbrew/opt/asdf/asdf.sh

確かに/home/linuxbrew/.linuxbrew/opt/asdf/ にはasdf.shはなかった。

hitochan777hitochan777

こういうときは再インストールすればなんとかなるかと思って下記実行した。

$ brew uninstall asdf                             
Uninstalling /home/linuxbrew/.linuxbrew/Cellar/asdf/0.11.1... (174 files, 891.3KB)

$ brew install asdf 
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).

You have 4 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

==> Fetching asdf
==> Downloading https://ghcr.io/v2/homebrew/core/asdf/manifests/0.11.1
Already downloaded: /home/hitochan/.cache/Homebrew/downloads/5f1bf3ae9bccf9ca0a5e302cb071389e203fa0eee8f4a8b043840a0b222d49c5--asdf-0.11.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/asdf/blobs/sha256:9ba9f78ec97892b0e463df856a3b5570fd3d92868e2acb6979f4074be066fa18
Already downloaded: /home/hitochan/.cache/Homebrew/downloads/b4373e701da08013e47a4b11b8631dd50e0d2ecb657301a6d3789465bc3f2f33--asdf--0.11.1.all.bottle.tar.gz
==> Pouring asdf--0.11.1.all.bottle.tar.gz
==> Caveats
To use asdf, add the following line to your ~/.zshrc:
  . /home/linuxbrew/.linuxbrew/opt/asdf/libexec/asdf.sh

Restart your terminal for the settings to take effect.

zsh completions have been installed to:
  /home/linuxbrew/.linuxbrew/share/zsh/site-functions
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/asdf/0.11.1: 174 files, 891.3KB
==> Running `brew cleanup asdf`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
hitochan777hitochan777

するとなんとインストール時のログに出ているパスがzshrcに記載していたものと違うので下記の通り修正して. ~/.zshrc実行、

  . /home/linuxbrew/.linuxbrew/opt/asdf/libexec/asdf.sh

だがエラーは変わらず。

$ source ~/.zshrc  
/home/linuxbrew/.linuxbrew/Cellar/asdf/0.10.2/libexec is not a directory
/home/linuxbrew/.linuxbrew/opt/asdf/libexec/asdf.sh:.:35: no such file or directory: /home/linuxbrew/.linuxbrew/Cellar/asdf/0.10.2/libexec/lib/asdf.sh
hitochan777hitochan777

ASDF_DIRなるものを出力するとなんか古いバージョンさしてそう。

$ echo $ASDF_DIR                                         
/home/linuxbrew/.linuxbrew/Cellar/asdf/0.10.2/libexec

強制的に新しいバージョンにしてGitHubのイシューにある通り、reshimしたら直った。

$ export ASDF_DIR=/home/linuxbrew/.linuxbrew/Cellar/asdf/0.11.1/libexec
$ rm ~/.asdf/shims/*
$ asdf reshim
hitochan777hitochan777

reshimしたらASDF_DIRのパスもなんか変わってた。

$ echo $ASDF_DIR                                                       
/home/linuxbrew/.linuxbrew/opt/asdf/libexe

なぜ直ったかよくわからないが、brew installで別のツールも影響受けるのやめてほしい。。。