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.
Until recently, we’ve been using kerl to manage Erlang versions, kiex to manage Elixir versions, rvm to manage Ruby versions and nvm to manage node versions. We’ve also been using virtualenv to manage Python 2.x virtual environments. We don’t deliberately manage Go versions (yet).
Yes, we do use all of those languages – and more – at Electric Imp.
For experimentation, I also have Rust, Haskell and OCAML installed on my development PC. These are out of scope (for now).
But: kerl, kiex and nvm only manage the installation of different versions. They don’t automatically switch to the correct version as you switch between projects.
For this, I’ve been using direnv.
But: direnv and rvm don’t play well together.
Our operations – #DevOps – team recently switched from rvm to rbenv, but that only covers Ruby versions. So I decided to try asdf for managing versions for everything.
That … didn’t work out so well.
- pip is broken
- bundler can’t install native extensions
- Some of our scripts directly use
nvm use, which complains about the node prefix being set. That is: both asdf and nvm want to manage the node version; they don’t play well together.
- We have a shonky script that expects
erlto be the real thing, not asdf’s shim. That’s our fault, but it makes team adoption harder.
So I’m going back to direnv, but with some knobs on.
This forms the first of a series of blog posts:
- Using direnv to manage tool versions (this post)
- Installing direnv
- Installing kerl
- Installing Erlang with kerl
- Building Erlang: Prerequisites (Ubuntu)
- Integrating direnv with kerl
- Getting Erlang version
- Installing kiex
- Installing Elixir with kiex
- Integrating direnv with kiex
- Installing Python with python-build
- Integrating direnv with python-build
- Installing Ruby with ruby-install
- Integrating direnv with ruby-install
- Integrating direnv with nvm
.direnvrc file is in my
dotfiles repo: https://github.com/rlipscombe/dotfiles/blob/master/direnvrc