Oximeeg

年収を上げたいITエンジニア

asdfの使い方

asdf はバージョン管理ツールであり、対応しているツールが豊富。

インストール

brew install asdf
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc

各種コマンド

一覧

利用できる SDK個々のコミュニティで管理している。

asdf plugin list all

追加

asdf plugin add <name>

削除

asdf plugin remove <name>

インストール済み一覧

asdf plugin list --urls

アップデート

asdf plugin update --all

バージョン一覧

asdf list all <name>

インストール

asdf install <name> latest[:<version>]

アンインストール

asdf uninstall <name> <version>

インストールされているバージョン

asdf list <name>

グローバルで使用するバージョン

asdf global <name> <version>

ローカルで使用するバージョン

asdf local <name> <version>

使用しているバージョン一覧

asdf current

バージョンファイルの使用

asdf.tool-versions でバージョン管理する。

asdf globalasdf local を実行すると .tool-versions にバージョンが書き込まれる。

  • .ruby-version.nvmrc.node-version もサポートしているが利用するには設定を有効にする必要がある。
  • echo -e "\nlegacy_version_file = yes" >> $HOME/.asdfrc で有効する。

インストール

.tool-versions で設定されているバージョンをインストールする。

asdf install

アンインストール

  1. ${ZDOTDIR:-~}/.zshrc から . $(brew --prefix asdf)/libexec/asdf.sh を削除
  2. brew uninstall asdf --force && brew autoremove
  3. rm -rf $HOME/.tool-versions $HOME/.asdfrc

困ったら

  • asdf help