Erlang Notes

asdf cheat sheet
Login

asdf cheat sheet

Erlang documentation

Tragically, Erlang uses fop for documentation, which is a massive pain to build as it uses Java's alien toolchains. If your build system can supply fop, use that. Otherwise, you can unpack a binary distribution and put a symlink to the fop/fop binary in your PATH, e.g.:

$ tar xvf ~/Downloads/fop-2.9-bin.tar.g
$ cd fop-2.9
$ fop/fop  # yeah, that works
$ ln -sf $PWD/fop/fop ~/bin/fop

Once that's done you shouldn't get "fop is missing" complaints during these builds, and can keep the long KERL_BUILD_DOCS=yes KERN_INSTALL_MANPAGES=yes KERN_INSTALL_HTMLDOCS=yes prefix to the asdf install commands.

After which, maybe you'll even have documentation after this next section. I didn't.

first steps

Install the latest release, then install a release candidate. --branch for the first command comes from https://asdf-vm.com/guide/getting-started.html#official-download

$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
$ cat >> ~/.bashrc
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
$ exec bash --login

Hit ctrl-d to stop the cat, or add those lines and refresh your shell some other way.

$ asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
$ asdf list erlang
$ KERL_BUILD_DOCS=yes KERN_INSTALL_MANPAGES=yes KERN_INSTALL_HTMLDOCS=yes asdf install erlang 27.0-rc3

If you're missing some libraries (for wxWindows, for ODBC), you'll get messages to that effect and can asdf uninstall erlang 27.0-rc3 and then repeat the last step, after adding those libraries.

$ asdf global erlang 27.0-rc3
$ KERL_BUILD_DOCS=yes KERN_INSTALL_MANPAGES=yes KERN_INSTALL_HTMLDOCS=yes asdf install erlang 26.2.5

You should now have two versions of Erlang installed. Confirm that:

$ which erl
~/.asdf/shims/erl
$ erl -s init stop
Erlang/OTP 27 [RELEASE CANDIDATE 3] [erts-15.0] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
$ asdf list erlang
  26.2.5
 *27.0-rc3
$ asdf shell erlang 26.2.5  # switch versions for only the current shell
$ erl -s init stop
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

get manpages if necessary

erl -man erl doesn't find anything? Try this:

$ function getman() { wget https://github.com/erlang/otp/releases/download/OTP-$1/otp_doc_man_$1.tar.gz && tar -C ~/.asdf/installs/erlang/$1/ -zxvf otp_doc_man_$1.tar.gz && rm -fv otp_doc_man_$1.tar.gz; }
$ getman 26.2.5
$ getman 27.0-rc3

That just downloads the official manpage tarball from erlang.org, which also works for release candidates as you can see, and extracts it into the location that erl looks in.

alternative documentation

For quick module lookup, instead of erl -man erl, try xdg-open https://www.erlang.org/doc/man/erl.

In general, start at https://www.erlang.org/doc/