How can I tell what version of Erlang was used to compile an Elixir application?

Rosemary Ledesma
Code for RentPath
Published in
1 min readMar 15, 2021

--

It’s possible to learn more about the Erlang version by inspecting the *.beam files.

A compiled Elixir or Erlang application includes *.beam files, which are byte code to be executed in the BEAM (Erlang virtual machine).

beam_lib is an Erlang module that provides an interface for this kind of file. You can use it to inspect the data chunks of the file and learn more about it.

Using beam_lib you can determine the version of the Erlang compiler that was used to compile a given file by decoding the relevant chunk.

Using Elixir:

:beam_lib.chunks(‘<path_to_file>’, [:compile_info])

iex(1)> :beam_lib.chunks(‘/Users/my_user/source/my_project/foo.beam’, [:compile_info])
{:ok,
{MyProject.Foo,
[
compile_info: [
version: ‘7.3.2’,
options: [:dialyzer, :no_spawn_compiler_process, :from_core,
:no_core_prepare, :no_auto_import],
source: ‘/Users/my_user/source/my_project/foo.ex’
]
]}}

Using Erlang:

beam_lib:chunks(“<path_to_file>”, [compile_info]).

1> beam_lib:chunks(“/Users/my_user/source/my_project/foo.beam”, [compile_info]).
{ok,{‘MyProject.Foo’,[{compile_info,[{version,”7.3.2"},
{options,[dialyzer,no_spawn_compiler_process,from_core,
no_core_prepare,no_auto_import]},
{source,”/Users/my_user/source/my_project/foo.ex”}]}]}}

The “version: ‘7.3.2’” part is the version of the Erlang compiler that was used to compile this file. You can examine the version history of the Erlang compiler here.

Note that the *.beam file data includes the full path to the original source file, so it’s a good idea to avoid including any sensitive information in the path name!

Acknowledgements

Thanks to Trevor Brown for help and feedback.

--

--