Tool called asdf is a simple CLI tool for managing multiple runtime or tool versions. You can switch them whenever is needed or assign different versions for different folders or projects.
🇨🇿 V češtině si lze článek přečíst na kutac.cz
There are package managers like apt, snap, DNF, and many more, based on the distribution. However, those managers very often replace the old package version with a new one. And very often automatically.
How asdf can help is visible in the picture below. When I switched to a different folder, the
node command runs a different version of NodeJS.
Even asdf can be very handy and useful, it is very easy to install. The whole process consists of 3 steps and is well described in asdf-vm.com. It is enough to have installed
git and asdf can be installed just by
git clone and integrating into the Shell. The update is done simply by
asdf update and uninstalling by removing asdf directory.
asdf is supported with
The pure installation of asdf cannot do much. And because of that, there are plugins. Every plugin is specialized for 1 runtime or tool. There are plugins for NodeJS, Ruby, Elixir, PHP, Python. But also C#, .NET Core, Java. And tools like 1Password, GCloud, or SQLite. There are more than 250 plugins already.
When asdf is installed and integrated into the Shell, it is possible to run some asdf command described below.
# Prints current versions of runtimes/tools for current directory # But now prints: Oohes nooes ~! No plugins installed asdf current # Lets install NodeJS plugin asdf plugin-add nodejs # Now current produce different output # nodejs ______ No version set. Run "asdf <global|shell|local> nodejs <version>" asdf current
Now it is possible to install a concrete version of NodeJS. However, plugins can have some prerequisites as well. Check Readme of NodeJS plugin to asdf and add PGP keys. Now we are ready to continue.
# List all available versions for NodeJS asdf list all nodejs # Install selected version of NodeJS asdf install nodejs 15.5.0 # Activate same version globally asdf global nodejs 15.5.0
It is possible to repeat the last 3 steps again and again with a different version. And instead of
asdf global we can use
asdf local to activate a specific version only for the current directory. It will also create
.tool-versions, which can be shared via git and all co-workers will use the same versions always.