-
Notifications
You must be signed in to change notification settings - Fork 626
Elixir
Jonas Chevalier edited this page Mar 20, 2022
·
2 revisions
Use kiex to install and manage multiple Elixir versions. This uses functions described in Find up with Alternates that should also be in your direnvrc
.
Put use_kiex
in your ~/.config/direnv/direnvrc
:
use_kiex()
{
has kiex || return
local version
version="${1}"
[[ "${version}" == --auto ]] && version="$(read_version_file .elixir-version)"
[[ -z "${version}" ]] && return
local activate
activate="${KIEX_HOME:-${HOME}/.kiex}"/elixirs/"$(
kiex list |
ruby -e "puts ARGF.read.scan(/elixir-${version}.*/).last"
)".env
[[ -f "${activate}" ]] && source "${activate}"
}
This is a conservative fuzzy use_
function: it does not fail if kiex
is not installed or if the Elixir version is not actually installed or usable. It does fuzzy matching preferring newer versions over earlier versions so that use kiex 1.7
will find Elixir 1.7.4 if that is the latest 1.7 version installed.
This can also read a .elixir-version
file containing a version specification so that your .envrc
may specify use kiex --auto
.