WARNING
This is a drat
This week I recorded 2 live coding session, a bit of Haskell and a lot of Erlang. I will try to summarize in this article how to bootstrap your environment (in my case VoidLinux (opens new window)) to program with Erlang.
# Install from package via xbps-install
We have lot of different ways to install a package, the first common one, is to use prebuild package from your favorite distribution. On VoidLinux, xbps-install is the tool you need.
# update repository and packages
xbps-install -Su
#install erlang
xbps-install erlang
This action will install all files in /usr/lib/erlang and configure
all default requirement to run properly Erlang on your computer.
# Build from source with xbps-src
If you know FreeBSD, OpenBSD or Gentoo a little, you will not be
surprised to build all your package or software from source via ports
(or portage for Gentoo). VoidLinux has the same feature, named
xbps-src giving you the ability to configure and build all your
software easily from source.
mkdir ${HOME}/src
cd ${HOME}/src
git clone [https://github.com/void-linux/void-packages.git](https://github.com/void-linux/void-packages.git)
cd void-packages
# bootstrap environment for xbps-src
./xbps-src binary-bootstrap
# build standard erlang release without x11
./xbps-src pkg erlang
#if you want x11 support:
./xbps-src pkg -ox11
# install erlang
./xbps-install -R ${path} erlang
I will write an article soon on how to create template for VoidLinux, 2 years ago, I tried to make lot of packages I didn’t really upstreamed… I think, now its the time to commit them.
# Build from source from github
If you want the development version of Erlang, the best way is to build it directly from fresh daily source, from github. This will give you the ability to use the last version with, probably, some bugs but also lot of new features.
mkdir ${HOME}/src
cd ${HOME}src
git clone [https://github.com/erlang/otp](https://github.com/otp/erlang)
./otp_build all
./bin/erl
This installation script will generate all required information for running Erlang on the last version…
# Configure your home environment (extra-package)
I like to have my own binary executable in my home directory, sometime, it can help you a lot, eventually, when you don’t have the right to install packages on your system, but you still need them for your work.
mkdir ~/bin
echo 'PATH=${PATH}:${HOME}/bin' >> .bashrc
echo 'PATH=${PATH}:${HOME}/bin' >> .shrc
Don’t forget to reload your environment.
# Install rebar3
rebar3 is the de facto packaging and building tool for Erlang,
there exist anothers like [erlang.mk](https://erlang.mk/) project
directed by Loïc Hoguin. rebar3 is not packaged (yet) on VoidLinux,
its a good opportunity to install it from source.
mkdir src
cd src
git clone [https://github.com/erlang/rebar3](https://github.com/erlang/rebar3)
cd rebar3
./bootstrap
./rebar3
ln -s ${PWD}/rebar3 ${HOME}/bin
We can now use rebar3 without installing it as system package.
# Configure Emacs or your favorite editor
Traditionnaly, Erlang developers are using Emacs as main editor, I don’t know why, but, one thing is sure: when you install Erlang, you have all necessary configuration for Emacs!
touch ${HOME}/.emacs
cat >> .emacs << EOF
(setq load-path (cons "/usr/lib/erlang/lib/tools-3.0.0/emacs" load-path))
(setq erlang-root-dir "/usr/lib/erlang")
(setq exec-path (cons "/usr/lib/erlang/bin" exec-path))(require 'erlang-start)
EOF
Your Emacs is now ready! But… Your favorite editor is not Emacs, but Vim? Okay, let’s do it:
# do vim configuration
Vim is ready too!
# Don’t forget the documentation
One of the best thing with Erlang, is the documentation! Every piece of code is documented, and available directly with the sources and packages.
# Start coding
We are now ready to code and produce some crazy Erlang based software!