Erlang開発環境構築

# はじめに
Erlangの環境構築手順のメモ

以下のような環境で、構築していきます

```
~ » cat /etc/lsb-release                                                                                                     vagrant@vagrant
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"
```

# kerlのインストール

まずはErlangのversion管理ツールの[kerl](https://github.com/kerl/kerl)をインストールする

```
$ sudo curl https://raw.githubusercontent.com/kerl/kerl/master/kerl --output /usr/local/bin/kerl
$ sudo chmod a+x /usr/local/bin/kerl
$ kerl
kerl: build and install Erlang/OTP
usage: /usr/local/bin/kerl <command> [options ...]

  <command>       Command to be executed

Valid commands are:
  build    Build specified release or git repository
  install  Install the specified release at the given location
  deploy   Deploy the specified installation to the given host and location
  update   Update the list of available releases from your source provider
  list     List releases, builds and installations
  delete   Delete builds and installations
  active   Print the path of the active installation
  plt      Print Dialyzer PLT path for the active installation
  status   Print available builds and installations
  prompt   Print a string suitable for insertion in prompt
  cleanup  Remove compilation artifacts (use after installation)
  version  Print current version (current: 1.5.1)
```

# Erlangのインストール

まずはインストールできるversionを確認する

```
$ kerl list releases                                                                                                       vagrant@vagrant
R10B-0 R10B-10 R10B-1a R10B-2 R10B-3 R10B-4 R10B-5 R10B-6 R10B-7 R10B-8 R10B-9 R11B-0 R11B-1 R11B-2 R11B-3 R11B-4 R11B-5 R12B-0 R12B-1 R12B-2 R12B-3 R12B-4 R12B-5 R13A R13B01 R13B02-1 R13B02 R13B03 R13B04 R13B R14A R14B01 R14B02 R14B03 R14B04 R14B_erts-5.8.1.1 R14B R15B01 R15B02 R15B02_with_MSVCR100_installer_fix R15B03-1 R15B03 R15B R16A_RELEASE_CANDIDATE R16B01 R16B02 R16B03-1 R16B03 R16B 17.0-rc1 17.0-rc2 17.0 17.1 17.3 17.4 17.5 18.0 18.1 18.2.1 18.2 18.3 19.0 19.1 19.2 19.3
Run '/usr/local/bin/kerl update releases' to update this list from erlang.org
```

今回は最新版の19.3をビルドする

```
$ kerl build 19.3 19.3                                                                                                     vagrant@vagrant
Verifying archive checksum...
Checksum verified (a8c259ec47bf84e77510673e1b76b6db)
Building Erlang/OTP 19.3 (19.3), please wait...
APPLICATIONS DISABLED (See: /home/vagrant/.kerl/builds/19.3/otp_build_19.3.log)
 * jinterface     : No Java compiler found
 * odbc           : ODBC library - link check failed

APPLICATIONS INFORMATION (See: /home/vagrant/.kerl/builds/19.3/otp_build_19.3.log)
 * wx             : wxWidgets not found, wx will NOT be usable

DOCUMENTATION INFORMATION (See: /home/vagrant/.kerl/builds/19.3/otp_build_19.3.log)
 * documentation  : 
 *                  xsltproc is missing.
 *                  fop is missing.
 *                  xmllint is missing.
 *                  The documentation can not be built.

Erlang/OTP 19.3 (19.3) has been successfully built
```

なんか怪しげなログが流れているが、buildはできてるっぽい。

次はビルドされた言語本体をインストールする

```
$ kerl install 19.3 ~/kerl/19.3                                                                                            vagrant@vagran
Installing Erlang/OTP 19.3 (19.3) in /home/vagrant/kerl/19.3...
You can activate this installation running the following command:
. /home/vagrant/kerl/19.3/activate
Later on, you can leave the installation typing:
kerl_deactivate
```

インストールされたものをディレクトリの中のみ有効にする。
例えば`~/project/erlang`内のみ有効にするには。

```
$ cd ~/project/erlang
$ . ~/kerl/19.3/activate
```

確認する

```
$ erl                                                                                                       vagrant@vagrant
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]

Eshell V8.3  (abort with ^G)
1> 
```

以上です