Skip to content
Austin Ziegler edited this page Aug 2, 2019 · 2 revisions

From http:https://joedevivo.com/2016/10/06/e-too-many-erlangs.html

Erlang version switching

Use kerl to install multiple erlang versions.

In your direnvrc:

use_kerl () {
    . $KERL_DEFAULT_INSTALL_DIR/$1/activate
}

Then in the .envrc:

use kerl 19.1.2

Automated Fuzzy Erlang Version Switching

Combined with find_up and read_version_file, it is possible to have a version of use_kerl that will look for a .erlang-version file. This version is conservative; it does not fail if kerl is not installed or if the Erlang version found is not actually installed (it is unusual but not impossible for the installed directories to be different than the installation index file), but it does nothing. This could be changed to fail if there is an error.

use_kerl()
{
  has kerl || return

  local version
  version="${1}"

  [[ "${version}" == --auto ]] && version="$(read_version_file .erlang-version)"
  [[ -z "${version}" ]] && return

  local activate
  activate="$(
    kerl list installations |
      ruby -e "puts ARGF.read.scan(/${version}.*/).last.split.last"
  )"/activate

  [[ -f "${activate}" ]] && source "${activate}"
}

Use this just like the above (use kerl 19.1.2) or with use kerl --auto. The version matching is fuzzy and prefers later versions over earlier versions (so use kerl 19.1 will use Erlang 19.1.2 if that is the latest installed version).

Clone this wiki locally