Rebar3: restrict compilation to a specific Erlang version

Hi guys

Sorry if the question was already answred, but i’d like to restrict my project to compile with only Erlang 24.x.y.z. By using this:
{require_otp_vsn, “24”}.

or even this:
{minimum_otp_vsn, “24”}.
{require_otp_vsn, “24”}.

it still accepts to compile with Erlang 25 (which i want to prevent).

Thanks

2 Likes

Yeah, you can do this. This is not officially documented which may or may not be intentional, so there’s that, however :

{minimum_otp_vsn, "24"}.
{blacklisted_otp_vsns, ["25"]}.

Curious, why? I suspect it’s that your app simply isn’t ready yet…

3 Likes

@starbelly thanks for the tip. And yes, some of our apps aren’t ready for 25 yet.

1 Like

You can also use -onload directive to detect current major release and exit not ok, with a log and message on stdout.

1 Like

@crownedgrouse thank you but we can’t afford building a release, deploying to finally detect the Erlang version isn’t the right one.

1 Like

Stick the following in some .erl or .hrl that’s always compiled into the thingy:

-if(?OTP_RELEASE =/= 24).
-error("OTP =/= 24").
-endif.

Not talking about deployment here.
Unit test and common test will fail.

1 Like

If your real question : how to detect i’m not using a module or function not available in 24.x.y ?
Your should use my project Geas with frame and range parameter.

1 Like

Thanks for all your answers guys.

1 Like