Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 18, 2021 05:50 am GMT

Introducing you to asdf-vm

Well, I recently discovered through a video by Fabio Akita, that there is a more practical way to manage versions of programming languages.

We work on several different projects. Some projects are new and use, for example Ruby 2.6.3. But sometimes we need to maintain projects from 3 or 4 years ago that may still be in Ruby 2.4.4 for example. It means that we need to have all of these versions installed on our machine at the same time. The same goes for Javascript or other languages. But a Linux distro's package manager only manages one version. After it updates, the old version no longer exists. So we need an outside way to manage this. Over the years, each language has built its own version manager like RVM and RBENV in Ruby, or Javascript's NVM, or Python's Virtualenv. But it is also a pain to have to remember the syntax and settings of so many different tools. And to save us came the Universal version manager, ASDF.

Managing the managers

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!

Installation and first steps

GitHub logo asdf-vm / asdf

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more

asdf Main workflow

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 gvm, nvm, rbenv & 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
  • single .tool-versions config file per project
  • support for existing config files .node-version, .nvmrc, .ruby-version for 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)

Documentation

Please head over to the documentation site for more information!

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.

. $HOME/.asdf/asdf.sh

and

. $HOME/.asdf/completions/asdf.bash

Restart your shell so that PATH changes take effect.

First steps

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.

Add a plugin

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 listor asdf list all ruby ou asdf list-all ruby

List a language version

To install a version is as simple as

asdf install <name> latest# asdf install ruby latestorasdf 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.


Original Link: https://dev.to/fariasmateuss/introducing-you-to-asdf-vm-491d

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To