How to get app version from mix.exs?

I’m wondering how I can retrieve an application’s version (as specified in its mix.exs)? I’d like to have that value available for logging.

Thanks!

Application.spec(app_name)[:vsn]
5 Likes

This can also be written as Application.spec(app_name, :vsn), slightly shorter and if you mistype the key you will get a FunctionClauseError (could be better or worse depending on your use case)

3 Likes