Getting Erlang version

30 Jan 2019 17:05 erlang

Use this helper function:

erlang_version() {
    erl -eval '
        {ok, Version} = file:read_file(
                            filename:join(
                                [code:root_dir(),
                                 "releases",
                                 erlang:system_info(otp_release),
                                 "OTP_VERSION"])),
        io:format("Erlang/OTP ~s", [Version]),
        halt().' -noshell
}
Note that this only works when you run erl; it doesn’t work in a released application.