Workstation Setup

Elixir setup

This document describes practices that are suitable for all projects.

It's the same as setting up environments for Ruby or JavaScript, with some nuances:

  • Postgres: to make your life easier, create a user with name postgres password postgres. This is the default for most Phoenix projects.
  • Asdf: this is the preferred version manager for Elixir, Erlang, and Node.js.

All of these steps are optional, but recommended.


Postgres

Most Elixir projects need PostgreSQL. See: PostgreSQL setup

asdf

You need Asdf version manager to install Erlang, Elixir, and Node.js. See: asdf setup

Installing Erlang, Elixir, and Node.js

(Linux) Install dependencies

For Ubuntu and other Debian distributions, install the following to properly get Erlang via asdf:

sudo apt-get install build-essential # C Compilers
sudo apt-get install libncurses5-dev libncursesw5-dev # Required header for Erlang source
sudo apt-get install libssl-dev # Required header for Erlang source as well
sudo apt-get install unzip # asdf's preferred utility to unpack Erlang

(macOS) Install Java

For fresh macOS installations, install the following to properly get Erlang via asdf:

# This is weird. I don't know why it's needed, but it is. -Rico
brew cask install java
brew install openssl

Configure global versions

To configure "global" versions in asdf, create ~/.tool-versions. Here's a fair starting point.

# These are stable versions as of April 2017.
# To check newer versions, use: `asdf list-all nodejs`
cd ~
echo 'erlang 19.3'   >> .tool-versions
echo 'nodejs 8.5.0'  >> .tool-versions
echo 'elixir 1.5.1'  >> .tool-versions
asdf install

Fix GPG auth for Node.js

Take note that nodejs installations via asdf-VM require gpg auth before doing asdf install. For more information, check here

Alternatives

There are other ways to acquire Postgres and Elixir:

  • Docker is the preferred way to get projects running.
  • Postgres.app is another way to install Postgres.
  • Kiex is an Elixir version manager. However, it doesn't manage Erlang installations (a dependency of Elixir).
  • You may also install Erlang and Elixir via Homebrew, though it may be difficult to switch versions later on.