Using direnv to manage tool versions
At Electric Imp, we use a variety of different languages, and each project might be using a different mix of versions.
At Electric Imp, we use a variety of different languages, and each project might be using a different mix of versions.
From direnv.net:
direnvis an environment switcher for the shell.
direnv is available as an Ubuntu package, but unless you’re on a really recent Ubuntu, it’ll be outdated.
If you want to use kerl to build your Erlang installation, you’re going to
need some packages installed first.
curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl
chmod +x kerl
sudo mv kerl /usr/local/bin
brew install kerl
To integrate direnv with kerl, add the following to ~/.direnvrc:
At Electric Imp, on developer PCs, we manage our Erlang versions with kerl.
Use this helper function:
erlang_version() {
erl -eval '
{ok, Version} = file:read_file(
filename:join(
[code:root_dir(),
"releases",
erlang:system_info(otp_release),
"OTP_VERSION"])),
io:format("Erlang/OTP ~s", [Version]),
halt().' -noshell
}erl; it doesn’t work in a released application.
To integrate direnv with kiex, add the following to ~/.direnvrc:
\curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | bash -sThen ensure it’s in your path. I copied it to /usr/local/bin:
At Electric Imp, we manage our Elixir versions with kiex.
To integrate direnv with nvm, add the following to ~/.direnvrc:
Install pyenv. We’re not going to use it as-is, but it includes the python-build script that we will use:
To integrate direnv with python-build – installation instructions here – add the following to ~/.direnvrc:
Install ruby-install:
To integrate direnv with ruby-install – installation instructions here – add the following to ~/.direnvrc:
I’m reading “Practical Haskell”, which requires a different version of Haskell than Ubuntu installs so I figured I’d add another entry to my direnv series.
By now you should be using Python 3.x. You can integrate it with direnv (2.21 or newer)
by putting the following in your .envrc
Compiling Ruby 2.7.7 fails with the following error about openssl: