なっく日報

技術やら生活やらのメモ

asdf-vm入れてみた

asdf-vmなるものがあると知りMacに入れてみた際のメモ

github.com

asdf-vmとはなにか?

各言語やツールのバージョン統一的に管理してくれるツールです。

xxxenvとかxxxbrewの代替になるツール。

似たツールとしては anyenvがあります。

github.com

言語/ツール対応がすごい(語彙力)ようです。

www.thoughtworks.com

ThoughtWorksのTechnology Radarでも取り上げられています。

入れてみた

とりあえずnodebrewを置き換えてみることにしました。

# HomeBrewで入れる
brew install asdf

# 普段使いがfishなので↓  bash使いの人は https://asdf-vm.com/#/core-manage-asdf-vm みるべし
echo "source "(brew --prefix asdf)"/asdf.fish" >> ~/.config/fish/config.fish

# ↓ Node.jsの場合必要 https://github.com/asdf-vm/asdf-nodejs#macos
brew install coreutils gpg

# Node.js用のプラグインを追加
asdf plugin-add nodejs
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring

# バージョンを指定していれる
# asdf list-all  nodejs でバージョンは確認できる
asdf install nodejs 12.14.1

# 利用するバージョンを指定する
asdf global nodejs 12.14.1

# 普通に使える
node -v 
# v12.14.1

Node.jsでハマる箇所

bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring を実行しないと下記のようなエラーがなんか出ます。

❯ asdf install nodejs 12.14.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3684    0  3684    0     0  48473      0 --:--:-- --:--:-- --:--:-- 48473
Authenticity of checksum file can not be assured! Please be sure to check the README of asdf-nodejs in case you did not yet bootstrap trust. If you already did that then that is the point to become SUSPICIOUS! There must be a reason why this is failing. If you are installing an older NodeJS version you might need to import OpenPGP keys of previous release managers. Exiting.

まとめ

正直nodebrewのほうが使いやすい・・・ですが、言語・ツール問わず統一的なインターフェースで使えるのは魅力かなと思います。

もうちょっと使い続けてみます。