Skip to main content
Version: scarthgap

BEAM Tools

Building and running your own Erlang and/or Elixir version could be an alternative when the host does not provide those packages or when additional tools are necessary and you want to provide a single installation source.

The meta-erlang layer is able to make a specific tarball having the following tools:

This tarball builds all the listed tools natively, wrapping them into a tarball self-installed script and ready to be shared. The beamtools does not provides any way to cross-compile code. The aim is to provide a custom set of BEAM tools able to be run on any Linux machine.

Building beamtools

The first step is to define which Erlang and Elixir versions the beamtools will build. This is done configuring the following variables in the file conf/local.conf or in the distro configuration file:

PREFERRED_VERSION_erlang = "24.1.7"
PREFERRED_VERSION_erlang-native = "24.1.7"
PREFERRED_VERSION_nativesdk-erlang = "24.1.7"

PREFERRED_VERSION_elixir = "1.12.3"
PREFERRED_VERSION_elixir-native = "1.12.3"
PREFERRED_VERSION_nativesdk-elixir = "1.12.3"

After that, the next step is to call bitbake to build the beamtools tarball:

bitbake beamtools-tarball

Once the build has finished, the results can be found in the tmp/deploy/sdk folder. You can copy it to the development machine and install running the .sh script, like that:

sh x86_64-beamtools-nativesdk-standalone-3.4.1-erlang-24.1.7-elixir-1.12.3.sh

The installation script is going to ask the destination path. You are free to use whatever path you need.

When the installation has over, it is necessary to source the environment script which has all the definitions about where to find the tools:

source /opt/beamtools/3.4.1-erlang-24.1.7-elixir-1.12.3/environment-setup-x86_64-pokysdk-linux

The current shell has the environment variable setted to the correct Erlang and Elixir installation. And running: erl or iex gives you an Erlang and Elixir prompts.

note

For each new shell, it will be necessary to source the environment-setup-x86_64-pokysdk-linux file.

The follow lines show the full output for beamtools installation process:

joaohf@porco:~/work/opensource/kas-meta-erlang$ honister/tmp/deploy/sdk/x86_64-beamtools-nativesdk-standalone-3.4.1-erlang-24.1.7-elixir-1.12.3.sh
BEAM tools installer version 3.4.1-erlang-24.1.7-elixir-1.12.3
==============================================================
Enter target directory for SDK (default: /opt/beamtools/3.4.1-erlang-24.1.7-elixir-1.12.3): /home/joaohf/beamtools/3.4.1-erlang-24.1.7-elixir-1.12.3
You are about to install the SDK to "/home/joaohf/beamtools/3.4.1-erlang-24.1.7-elixir-1.12.3". Proceed [Y/n]?
Extracting SDK.....................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /home/joaohf/beamtools/3.4.1-erlang-24.1.7-elixir-1.12.3/environment-setup-x86_64-pokysdk-linux

Downloading a pre-built beamtools tarball

It is also possible to download and run a pre-built beamtools installer yourself with the following steps:

  1. Locate and download the *.sh at https://github.com/meta-erlang/meta-erlang/releases

  2. Execute the installation script. Here is an example for the traditional installer:

    sh ~/Downloads/x86_64-beamtools-nativesdk-standalone-3.4.1-erlang-24.1.7-elixir-1.12.3.sh
    note

    During execution, a prompt appears that allows you to choose the installation directory. For example, you could choose the following: /home/your-username/beamtools

  3. Source the tools environment setup script by using a command like the following:

    source /home/your_username/beamtools/environment-setup-x86_64-pokysdk-linux

After you have sourced the setup script, the tools are added to PATH and any other environment variables required to run the tools are initialized. The results are working versions versions of rebar3, Erlang/OTP and Elixir.

Start livebook from beamtools

As livebook is included into standard beamtools SDK, it's possible to start a livebook session easily following the steps below:

  1. Source the beamtools SDK

    source /home/your_username/beamtools/nvironment-setup-x86_64-pokysdk-linux
  2. Check if the livebook scripts exists in your environment:

    $ livebook
    Usage: livebook COMMAND [ARGS]

    The known commands are:

    start Starts the system
    start_iex Starts the system with IEx attached
    daemon Starts the system as a daemon
    daemon_iex Starts the system as a daemon with IEx attached
    eval "EXPR" Executes the given expression on a new, non-booted system
    rpc "EXPR" Executes the given expression remotely on the running system
    remote Connects to the running system via a remote shell
    restart Restarts the running system via a remote command
    stop Stops the running system via a remote command
    pid Prints the operating system PID of the running system via a remote command
    version Prints the release name and version to be booted

  3. Start livebook system:

    $ livebook start
    [Livebook] Application running at http://localhost:8080/?token=z4nrl62iqojkttdq3fuha7vm7ynkhwis
  4. It's done, you can play with livebook locally without need to install anything else.