sashaafm
Including data files in a Distillery release
I’m trying to build a release of a project I’m working on which has several CSV, JSON and ETS files. There files are used at runtime to import ETS tables and at compile-time to dynamically generate certain modules. However, Distillery does not seem to include them in the release.
At the beginning I had them in a directory inside the Elixir project (alongside lib). I also tried moving the files inside the lib dir (and changing the config accordingly) but the results were the same.
I’ve been reading the docs but don’t find anything about this. There’s the following reference:
- code_paths (list of strings);
a list of additional code paths to use when searching
for applications/modules
but it does not seem to be related to extra needed files.
Marked As Solved
michalmuskala
The traditional place to put non-code resources that are needed at runtime is the priv folder. All the tools are aware of this convention and preserve proper paths.
You can access the files at runtime using Application.app_dir(app_name, "priv/path/to/file")
Also Liked
bitwalker
You can use :code.priv_dir(app) to get the priv directory directly as well, it’s what I typically use in my applications.
sashaafm
Thank you @michalmuskala. I’m going to try this and report back!
EDIT: Michal’s answer does work. Marking it as the solution.
bitwalker
New versions of your application will have a slightly different path (as the path includes the version of your app in a release), but the same version will always be the same path, regardless of OTP version, Elixir version, etc.








