asdf は 0.16 からディレクトリ構造が大幅に変化している
asdf は様々なランタイムを管理出来るバージョンマネージャです。 Golang で実装されています。 ただ、後発の Rust で実装された mise (旧名は rtx) は「asdf 用のプラグインは全て使えるが、asdf より速い」とうたっています。 これを受けてなのか、asdf は バージョン 0.16.0 の Changelog に下記の記載があります。 記載内容によると「バージョン 0.16.0 からより速く、シンプルで、メンテナンスし易いように書き直した」ようです。
Rewrite asdf in Golang The rewrite in Go was spread across 88 pull requests that are all included in this release. The primary goal of the rewrite was to create a codebase that was faster, simpler and easier to maintain. The rewrite tries to maintain feature parity with the previous version. However, a number of breaking changes were introduced. Some of these were due to the change of language, a few out of a desire to simplify the code, and some to improve the user experience. For the full list of breaking changes and the upgrade guide visit the Upgrading to 0.16.0 page on the asdf website. It is highly recommended that you read this guide before upgrading.
ですが、私の macOS 環境では 0.15 系から 0.16.1 へバージョンアップしたところ、下記のエラーが出るようになってしまいました。
.zshrc では バージョン 0.15 までのガイド に従って以下のように設定してありましたが、これがエラーになっているようです。
検証環境¶
| 対象 | バージョン |
|---|---|
| macOS | 15.3 |
バージョン 0.16 以前と以降での、ディレクトリ構造の違い¶
「asdf のバージョン 0.16 以前」と「以降」では大きくディレクトリ構造が異なります。 0.16.1 では前述のエラーになっていた /opt/homebrew/opt/asdf/libexec/asdf.sh が存在しません。
バージョン 0.14.1¶
~$ tree /opt/homebrew/opt/asdf/
/opt/homebrew/opt/asdf/
├── CHANGELOG.md
├── INSTALL_RECEIPT.json
├── LICENSE
├── README.md
├── bin
│ └── asdf
├── etc
│ └── bash_completion.d
│ └── asdf.bash
├── libexec
│ ├── CONTRIBUTING.md
│ ├── SECURITY.md
│ ├── asdf.elv
│ ├── asdf.fish
│ ├── asdf.nu
│ ├── asdf.ps1
│ ├── asdf.sh
│ ├── asdf_updates_disabled
│ ├── ballad-of-asdf.md
│ ├── bin
│ │ ├── asdf
│ │ └── private
│ │ └── asdf-exec
│ ├── completions
│ ├── defaults
│ ├── docs
│ │ ├── CNAME
│ │ ├── contribute
│ │ │ ├── core.md
│ │ │ ├── documentation.md
│ │ │ ├── first-party-plugins.md
│ │ │ └── github-actions.md
│ │ ├── guide
│ │ │ ├── getting-started.md
│ │ │ └── introduction.md
│ │ ├── index.md
│ │ ├── ja-jp
│ │ │ ├── contribute
│ │ │ │ ├── core.md
│ │ │ │ ├── documentation.md
│ │ │ │ ├── first-party-plugins.md
│ │ │ │ └── github-actions.md
│ │ │ ├── guide
│ │ │ │ ├── getting-started.md
│ │ │ │ └── introduction.md
│ │ │ ├── index.md
│ │ │ ├── manage
│ │ │ │ ├── commands.md
│ │ │ │ ├── configuration.md
│ │ │ │ ├── core.md
│ │ │ │ ├── plugins.md
│ │ │ │ └── versions.md
│ │ │ ├── more
│ │ │ │ ├── community-projects.md
│ │ │ │ ├── faq.md
│ │ │ │ └── thanks.md
│ │ │ └── plugins
│ │ │ └── create.md
│ │ ├── manage
│ │ │ ├── commands.md
│ │ │ ├── configuration.md
│ │ │ ├── core.md
│ │ │ ├── plugins.md
│ │ │ └── versions.md
│ │ ├── more
│ │ │ ├── community-projects.md
│ │ │ ├── faq.md
│ │ │ └── thanks.md
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── plugins
│ │ │ └── create.md
│ │ ├── pt-br
│ │ │ ├── contribute
│ │ │ │ ├── core.md
│ │ │ │ ├── documentation.md
│ │ │ │ ├── first-party-plugins.md
│ │ │ │ └── github-actions.md
│ │ │ ├── guide
│ │ │ │ ├── getting-started.md
│ │ │ │ └── introduction.md
│ │ │ ├── index.md
│ │ │ ├── manage
│ │ │ │ ├── commands.md
│ │ │ │ ├── configuration.md
│ │ │ │ ├── core.md
│ │ │ │ ├── plugins.md
│ │ │ │ └── versions.md
│ │ │ ├── more
│ │ │ │ ├── community-projects.md
│ │ │ │ ├── faq.md
│ │ │ │ └── thanks.md
│ │ │ └── plugins
│ │ │ └── create.md
│ │ └── zh-hans
│ │ ├── contribute
│ │ │ ├── core.md
│ │ │ ├── documentation.md
│ │ │ ├── first-party-plugins.md
│ │ │ └── github-actions.md
│ │ ├── guide
│ │ │ ├── getting-started.md
│ │ │ └── introduction.md
│ │ ├── index.md
│ │ ├── manage
│ │ │ ├── commands.md
│ │ │ ├── configuration.md
│ │ │ ├── core.md
│ │ │ ├── plugins.md
│ │ │ └── versions.md
│ │ ├── more
│ │ │ ├── community-projects.md
│ │ │ ├── faq.md
│ │ │ └── thanks.md
│ │ └── plugins
│ │ └── create.md
│ ├── help.txt
│ ├── lib
│ │ ├── commands
│ │ │ ├── command-current.bash
│ │ │ ├── command-env.bash
│ │ │ ├── command-exec.bash
│ │ │ ├── command-export-shell-version.bash
│ │ │ ├── command-global.bash
│ │ │ ├── command-help.bash
│ │ │ ├── command-info.bash
│ │ │ ├── command-install.bash
│ │ │ ├── command-latest.bash
│ │ │ ├── command-list-all.bash
│ │ │ ├── command-list.bash
│ │ │ ├── command-local.bash
│ │ │ ├── command-plugin-add.bash
│ │ │ ├── command-plugin-list-all.bash
│ │ │ ├── command-plugin-list.bash
│ │ │ ├── command-plugin-push.bash
│ │ │ ├── command-plugin-remove.bash
│ │ │ ├── command-plugin-test.bash
│ │ │ ├── command-plugin-update.bash
│ │ │ ├── command-reshim.bash
│ │ │ ├── command-shim-versions.bash
│ │ │ ├── command-uninstall.bash
│ │ │ ├── command-update.bash
│ │ │ ├── command-version.bash
│ │ │ ├── command-where.bash
│ │ │ ├── command-which.bash
│ │ │ ├── reshim.bash
│ │ │ └── version_commands.bash
│ │ ├── functions
│ │ │ ├── installs.bash
│ │ │ ├── plugins.bash
│ │ │ └── versions.bash
│ │ └── utils.bash
│ ├── scripts
│ │ ├── checkstyle.py
│ │ ├── install_dependencies.bash
│ │ ├── lint.bash
│ │ └── test.bash
│ ├── test
│ │ ├── asdf_elvish.bats
│ │ ├── asdf_fish.bats
│ │ ├── asdf_nu.bats
│ │ ├── asdf_pwsh.bats
│ │ ├── asdf_sh.bats
│ │ ├── banned_commands.bats
│ │ ├── current_command.bats
│ │ ├── fixtures
│ │ │ ├── dummy_broken_plugin
│ │ │ │ └── bin
│ │ │ │ ├── download
│ │ │ │ ├── install
│ │ │ │ └── list-all
│ │ │ ├── dummy_legacy_plugin
│ │ │ │ └── bin
│ │ │ │ ├── get-version-from-legacy-file
│ │ │ │ ├── install
│ │ │ │ ├── list-all
│ │ │ │ ├── list-legacy-filenames
│ │ │ │ └── parse-legacy-file
│ │ │ ├── dummy_plugin
│ │ │ │ ├── LICENSE
│ │ │ │ └── bin
│ │ │ │ ├── download
│ │ │ │ ├── get-version-from-legacy-file
│ │ │ │ ├── help.overview
│ │ │ │ ├── install
│ │ │ │ ├── latest-stable
│ │ │ │ ├── list-all
│ │ │ │ ├── list-legacy-filenames
│ │ │ │ ├── parse-legacy-file
│ │ │ │ ├── post-plugin-add
│ │ │ │ ├── post-plugin-update
│ │ │ │ └── pre-plugin-remove
│ │ │ ├── dummy_plugin_no_download
│ │ │ │ ├── LICENSE
│ │ │ │ └── bin
│ │ │ │ └── install
│ │ │ └── dummy_plugins_repo
│ │ │ └── plugins
│ │ │ ├── bar
│ │ │ ├── dummy
│ │ │ └── foo
│ │ ├── get_asdf_config_value.bats
│ │ ├── help_command.bats
│ │ ├── info_command.bats
│ │ ├── install_command.bats
│ │ ├── latest_command.bats
│ │ ├── list_command.bats
│ │ ├── plugin_add_command.bats
│ │ ├── plugin_extension_command.bats
│ │ ├── plugin_list_all_command.bats
│ │ ├── plugin_remove_command.bats
│ │ ├── plugin_test_command.bats
│ │ ├── plugin_update_command.bats
│ │ ├── remove_command.bats
│ │ ├── reshim_command.bats
│ │ ├── setup_suite.bash
│ │ ├── shim_env_command.bats
│ │ ├── shim_exec.bats
│ │ ├── shim_versions_command.bats
│ │ ├── test_helpers.bash
│ │ ├── uninstall_command.bats
│ │ ├── update_command.bats
│ │ ├── utils.bats
│ │ ├── version_commands.bats
│ │ ├── where_command.bats
│ │ └── which_command.bats
│ └── version.txt
├── sbom.spdx.json
└── share
├── fish
│ └── vendor_completions.d
│ └── asdf.fish
└── zsh
└── site-functions
└── _asdf
53 directories, 183 files
バージョン 0.16.1¶
% tree /opt/homebrew/opt/asdf/
/opt/homebrew/opt/asdf/
├── CHANGELOG.md
├── INSTALL_RECEIPT.json
├── LICENSE
├── README.md
├── bin
│ └── asdf
├── etc
│ └── bash_completion.d
│ └── asdf
├── sbom.spdx.json
└── share
├── fish
│ └── vendor_completions.d
│ └── asdf.fish
└── zsh
└── site-functions
└── _asdf
9 directories, 9 files
homebrew で 0.16 系をインストールした際のログ¶
homebrew を使い、zsh や bash 環境で asdf をインストールしたログは以下の通りです。 従来はインストール後に「シェル毎の環境変数を追加」するガイドが表示されていたのですが、バージョン 0.16 からは表示されなくなりました。
zsh でのインストールログ¶
% brew install asdf
==> Downloading https://ghcr.io/v2/homebrew/core/asdf/manifests/0.16.1
Already downloaded: /Users/USERNAME/Library/Caches/Homebrew/downloads/1b752e8b08e1066b848f2ca35441286f66ef53aa49e520801ff0c0670ee42618--asdf-0.16.1.bottle_manifest.json
==> Fetching asdf
==> Downloading https://ghcr.io/v2/homebrew/core/asdf/blobs/sha256:444c8ec5fa55d551794c4bf6d4374ddbc58298706a6843d29320dbd5c04284f3
Already downloaded: /Users/USERNAME/Library/Caches/Homebrew/downloads/43cfbfcd372314769da80b0464c4e75de247a218440531d544389251e3cf4497--asdf--0.16.1.arm64_sequoia.bottle.tar.gz
==> Pouring asdf--0.16.1.arm64_sequoia.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/asdf/0.16.1: 10 files, 10.9MB
==> Running `brew cleanup asdf`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
bash でのインストールログ¶
~$ brew install asdf
==> Downloading https://ghcr.io/v2/homebrew/core/asdf/manifests/0.16.1
Already downloaded: /Users/USERNAME/Library/Caches/Homebrew/downloads/1b752e8b08e1066b848f2ca35441286f66ef53aa49e520801ff0c0670ee42618--asdf-0.16.1.bottle_manifest.json
==> Fetching asdf
==> Downloading https://ghcr.io/v2/homebrew/core/asdf/blobs/sha256:444c8ec5fa55d551794c4bf6d4374ddbc58298706a6843d29320dbd5c04284f3
Already downloaded: /Users/USERNAME/Library/Caches/Homebrew/downloads/43cfbfcd372314769da80b0464c4e75de247a218440531d544389251e3cf4497--asdf--0.16.1.arm64_sequoia.bottle.tar.gz
==> Pouring asdf--0.16.1.arm64_sequoia.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/opt/homebrew/etc/bash_completion.d
==> Summary
🍺 /opt/homebrew/Cellar/asdf/0.16.1: 10 files, 10.9MB
==> Running `brew cleanup asdf`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
asdf 0.16 環境の再構築¶
冒頭に記載したように、0.16 以前のバージョンから 0.16 以降へバージョンアップしたところ、以下のエラーが出ていました。
このエラーを解消するにはシェルごとに ~/.bash_profile や ~/.zshrc で定義した asdf 用の環境変数を削除した上で、homebrew で asdf を再インストールすれば良さそうです。 一旦、古いバージョンを削除、asdf 用のディレクトリ (~/.asdf) も削除したら asdf を再インストールします。
~/.zshrc に以下を追記します。
asdf で Python をインストールする¶
バージョン 0.15 以前は asdf global や asdf local を利用していましたが、これらのコマンドはバージョン 0.16 以降で廃止されました。 代わりに 6. Set a Version に記載されている asdf set を使って利用するバージョンを指定します。 asdf set で指定したバージョンは .tool-versions ファイルに保存されます。 -u オプションを指定した場合はホームディレクトリの .tool-versions にバージョンが保存されます。
参考¶
asdf のヘルプ¶
% asdf --help
Incorrect Usage: flag: help requested
NAME:
asdf - The multiple runtime version manager
USAGE:
The Multiple Runtime Version Manager.
Manage all your runtime versions with one tool!
Complete documentation is available at https://asdf-vm.com/
VERSION:
0.16.1
AUTHOR:
Trevor Brown
COMMANDS:
cmd
completion
current
env
exec
help
info
install
latest
list
plugin
reshim
set
shimversions
uninstall
update
where
which
GLOBAL OPTIONS:
--version, -v print the version
COPYRIGHT:
(c) 2024 Trevor Brown
asdf set のヘルプ¶
% asdf set --help
NAME:
asdf set
USAGE:
asdf set [command options] [arguments...]
OPTIONS:
--home, -u The version should be set in the current users home directory (default: false)
--parent, -p The version should be set in the closest existing .tool-versions file in a parent directory (default: false)
--help, -h show help