I use asdf to work with different versions of erlang and make releases. Is there any way to make rebar3 releases with a specific version of glibc ? I have encountered the fact that the production environment does not match my development environment and this is a problem for me
In the relx
section of rebar.config
you can set a different built erts to include: Releases | Rebar3
{include_erts, "/path/to/erlang"},
{system_libs, "/path/to/erlang"},
So if you copy over an Erlang built for the production target you can build a release that will run on it (assuming you don’t also have NIF depenedencies you are building).
but how to prepare the required version? First you need to compile the required version, how to do this on my machine?
I would strongly advise you to set up build agents that run an environment compatible with your production environment. E.g. if your production is on Amazon Linux 2023 your build agents should also be.
If you’re deploying to some embedded target the agents would instead use cross-compilers.
For personal hobby projects you could run cross-compilers locally (whether to another platform or to the same but with an older glibc).
You can’t expect rebar3
to know how to do any of this.
Just in case you’re interested in an example, I have a lengthy script that cross-compiles portable binary releases by linking against an old glibc version (and linking all other dependencies statically) for two architectures here.
(We do the same thing for building ejabberd releases, but that script is even longer.)