Thanks for your response.
After investigating, I can confirm that it doesn’t work with Distillery or mix releases.
Regarding mix releases, the problem is that module atom names are not properly escaped when written to the sys.config
files. For instance:
{token_store_refresh_token_before_store_callback, fun Elixir.Asteroid.Utils:id_first_param/2},
is written instead of:
{token_store_refresh_token_before_store_callback, fun 'Elixir.Asteroid.Utils':id_first_param/2},
and so you’ll end up with one of the following message (adding it for search engines):
Distillery:
==> Assembling release..
==> Building release asteroid:0.1.0 using environment prod
==> Including ERTS 10.0 from /usr/lib/erlang/erts-10.0
==> Packaging release..
==> Release packaging failed due to errors:
Cannot add file sys.config to tar file - [{error,{22,erl_parse,["syntax error before: ","'.'"]}}]
Mix releases:
$ MIX_ENV=prod mix release
Compiling 88 files (.ex)
Generated asteroid app
* assembling prod-0.1.0 on MIX_ENV=prod
* skipping runtime configuration (config/releases.exs not found)
** (Mix) Could not read configuration file. It likely has invalid configuration terms such as functions, references, and pids. Please make sure your configuration is made of numbers, atoms, strings, maps, tuples and lists. Reason: {22, :erl_parse, ['syntax error before: ', '\'.\'']}
I’ll report an issue on Elixir’s Github. That said there may be other reasons why allowing named functions in config files are a bad idea? Mix source code seems to exclude this possibility (source) unless it’s not recommended only for anonymous functions.
EDIT: opened github issue