16
loading...
This website collects cookies to deliver better user experience
Photo by Nana Smirnova on Unsplash
asdf
.This project uses node 7. But I have node 10 installed... Oh no…
rvm
, I found NVM (Node Version Manager), which does the same thing as rvm
but for the Node runtime.Why the heck don't you use asdf
for all these languages?
asdf
is a CLI tool that solves the runtime version management in a well-architected and elegant way: by being a single tool for all runtimes.asdf
is a core application that does the handling heavy-lifting of providing CLI options, being hooked via terminal, etc. but instead of also solving the version available for every single runtime that exists, it delegates this to third party plugins.asdf
does not care about any runtime like java, go, deno, rust, or whatever, but it provides an abstract interface where someone in the community can simply create and maintain a plugin that provides all the information to download the version X for example.asdf
properly installed and configured in your bash, fish, or zsh terminal configuration.asdf-ruby
plugin only deals with how to download ruby runtime, which version was released, etc.Check here all plugins available for asdf
asdf plugin add <plugin-name> <git-url>
. The git-url
isn’t required but recommended just to be sure you’re consuming for the correct repository:asdf plugin add nodejs
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
asdf
will have 2 plugins: one capable to manage node versions and another to manage ruby versions.10.2
version of node14
version of node2.6.5
version of Ruby2.7
version of Rubyasdf install <plugin-name> <version>
. So all I need to do is running in the terminal:asdf install nodejs latest:10.2
asdf install nodejs latest:14
asdf install ruby 2.6.5
asdf install ruby latest:2.7
Obs.: depending on your environment you might need to install some stuff before being able to install a runtime, like ruby for example that requires having libssl-dev
, etc, in a Linux machine before installing successfully.
latest:
prefix before the version number and this will end up installing the latest version available for that number.asdf list <plugin-name>
:asdf list nodejs
10.24.1
14.17.3
asdf list ruby
2.6.5
2.7.4
asdf global <plugin-name> <version>
:asdf global nodejs 14.17.3
node -v
v14.17.3
asdf local <plugin-name> <version>
:asdf local nodejs 10.24.1
asdf
will create a file in the folder you’re called .tool-versions
that contains the following content:nodejs 10.24.1
yarn start
for example (which will invoke somehow node runtime) because asdf
is intercepting the call and finds this file, it’ll use version 10
instead of my global 14
.Tip: if for some reason you don't want to commit the .tool-versions
file you can either add it in the .gitignore
of your project or if this rule will be applied to all projects, setting this ignore globally like I explain here
ruby
versions in your machine.asdf plugin remove <plugin-name>
:asdf plugin remove ruby
ruby
plugin and all versions we've installed in the previous steps will be completely removed from our machine.asdf
without having to remove the existing version file, in your $HOME path you can create a file called .asdfrc
and add the flag legacy version file:legacy_version_file = yes
asdf
is not only to solve this cumbersome version problem but also in terms of using a very robust plugin mechanism for the correct problem.16