Manage your runtime environments using ASDF and not NVM or RVM etc...
Tags: opensource, productivity, node, ruby
Published: 2019-12-16 18:19:31

---
title: Manage your runtime environments using ASDF and not NVM or RVM etc...
published: true
description: Manage your runtime environments using ASDF and not NVM or RVM etc...
tags: opensource, productivity, node, ruby
---

Many of us have used [rvm](https://rvm.io/) or [rbenv](https://github.com/rbenv/rbenv) to manage Ruby, [nvm](https://github.com/nvm-sh/nvm) or [n](https://github.com/tj/n) to manage our Node installs, [pyenv](https://github.com/pyenv/pyenv) for Python. The problem is when you need to add other things into the mix like [gvm](https://github.com/moovweb/gvm) for Go, the list goes on. 

![crazy](https://media.giphy.com/media/l0IylOPCNkiqOgMyA/giphy.gif)

## [ASDF](https://asdf-vm.com/) to the rescue! 
>  Manage multiple runtime versions with a single CLI tool

ASDF allows you to manage many environments on a _per project_ basis. ASDF has done for my project management what homebrew did for my Mac.

Let's say for example you had RVM and NVM installed and Dart was done via shell scripts. Sure, you're already on top of it - but why accept the pain involved with managing them on top of the environments themselves? 

You may not suffer from any of the above and just have one environment to handle, but nonetheless, make it easy for someone who has to manage or maintain your work after you're done with it.

If you're working on or maintaining multiple projects with a team of people, asdf will make all of your lives much easier.

I'll demonstrate how easy it is to take control and get some of your sanity back.
We'll work with Node for this example.

## Install asdf

via  Homebrew
```
brew install asdf
```

If you are on Linux or are using Linux subsystem on Windows or don't use homebrew on macOS, you can [install via git](https://asdf-vm.com/#/core-manage-asdf-vm).


## Update your shell to handle asdf

These are for anyone who installed via homebrew. If you installed via git, follow the instructions on the asdf website.

### BASH

```
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
```

### ZSH

```
echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.bash_profile
echo -e "\n. $(brew --prefix asdf)/etc/bash_completion.d/asdf.bash" >> ~/.bash_profile
```

## Install plugin dependencies for homebrew

You might not have all the dependencies installed, so you need to run:

```
brew install \
  coreutils automake autoconf openssl \
  libyaml readline libxslt libtool unixodbc \
  unzip curl
```


## Install a language plugin

ASDF comes with extensive language support via it's [plugin system](https://asdf-vm.com/#/plugins-all)

```
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
```

For nodejs we will also have to add the release team's OpenPGP keys to main keyring:

```
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
```

## List all versions for this package

```
asdf list-all nodejs
```

This will output all the versions you can install via asdf.

## Install the version you need

```
 asdf install nodejs 13.3.0
```

Let's set a system wide version, which will be the default version.

```
asdf global nodejs 13.3.0
```

### To install a different version:

```
 asdf install nodejs 7.9.0
```

### Now set it in your current project or directory by:

```
asdf local nodejs 7.9.0
```

## How to store your settings

You can store your settings for the project by creating a `.tool-versions` file.

inside your current project add the following setting:

```
nodejs 7.9.0
```

If you commit this to your project and someone else picks it up, asdf will understand what version to use and prompt you to install it if necessary.

## Keep asdf up to date

Now you have one manager to manage your multiple development environments. You only need to keep asdf up to date, which is easy peasy.

via homebrew:
```
brew upgrade asdf
```

or via git
```
asdf update
```

## Rinse and repeat!
You can rinse and repeat this for as many environments as you need, in as many projects as necessary.


How easy is that!

![ring](https://media.giphy.com/media/jgpinQdolRGCY/giphy.gif)