Read env variable in mix.exs to conditionally add a package


Is it ok to read an env variable like this in mix.exs?


I’m using it to conditionally load Oban Web & Pro packages.
It works in development.
Yet, in production, it’s like the env variable doesn’t exist — and it does.

Any idea? Thanks!

If you’re using releases, then mix.exs won’t be executed. You must set the environment variable before compiling a production release.


Yes, I am using releases on

How should I set the env variable?
Do you mean something like this in Dockerfile?

  mix deps.get --only $MIX_ENV

If it helps, you can see the full Dockerfile here.

It still doesn’t find the env variable.
What am I missing?

You’ve sprinkled NOTESCLUB_IS_OBAN_WEB_PRO_ENABLED in a few RUN statements, but you could set it with ENV instead.

1 Like

Thanks, it’s working now.

Besides using ENV, I also set the env variable to "true" instead of true.

As a reference, I updated the Dockerfile

1 Like