Well, I recently discovered through a video by Fabio Akita, that there is a more practical way to manage versions of programming languages.
asdf is a CLI tool that can manage multiple language runtime versions on a per-project basis. It is like gvm, nvm, rbenv & pyenv (and more) all in one! Simply install your language's plugin!
Manage multiple runtime versions with a single CLI tool, extendable via plugins - docs at asdf-vm.com
asdf is a CLI tool that can manage multiple language runtime versions on a per-project basis. It is like
pyenv (and more) all in one! Simply install your language's plugin!
Why use asdf?
- single CLI for multiple languages
- consistent commands to manage all your languages
- single global config keeping defaults in one place
.tool-versionsconfig file per project
- support for existing config files
.ruby-versionfor easy migration
- automatically switches runtime versions as you traverse your directories
- simple plugin system to add support for your language of choice
- shell completion available for common shells (Bash, Zsh, Fish)
Clone only the latest branch:
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0
Then add the following line to your ~/.bashrc file.
Restart your shell so that PATH changes take effect.
Now that asdf is properly installed, we can start playing with it. First of all, know that it works with plugins, so first of all you need to install the official asdf plugin for your language, I will use Ruby as an example.
It is quite simple as you can see
asdf plugin add <name> # asdf plugin add ruby
once added, you can list all language versions. Using the command below
asdf plugin list # asdf ruby list or asdf list all ruby ou asdf list-all ruby
To install a version is as simple as
asdf install <name> latest # asdf install ruby latest or asdf install <name> latest:<version> # asdf install ruby latest:17
and finally, to set the installed version.
asdf global <name> <version> [<version>...] asdf shell <name> <version> [<version>...] asdf local <name> <version> [<version>...] # asdf global ruby 2.6.4
If you need to unset, use
asdf uninstall <name> <version> # asdf uninstall ruby 2.6.4asdf plugin update <name> # asdf plugin update erlang
Photo by Carl Raw on Unsplash.