What does `/priv` mean?

I haven’t found this in the docs, so here goes:

The name /priv throws me off: what is the name supposed to represent?

I’m guessing private. But private from whom?

I don’t think it’s from the app developer because we go in there for localization files, db migrations, the seed file, and maybe more.

It’s not private from the framework…

It’s not private in the sense of PII or app secrets…

So, how should I understand this?

1 Like

It’s private from other OTP applications. It’s the stuff that is used by your app only. (In opposition to the include directory. But that’s an Erlang thing.) priv is rather a “resources that are mostly not code” directory.

Back at Basho we used /priv for non-Erlang files. Scripts to generate syntax for a parser, configuration file schemas and built-in functions for an embedded JS interpreter, collections of internal tools, CSS file for generated documentation, that kind of thing.

Code you want distributed with your package in some contexts, but not necessarily compiled in to ebin files.

3 Likes

Here is a quote from José Valim in 2015 on the topic. Not explicitly called out here but important to understand it was inherited from OTP itself. See :code.priv_dir/1

“priv” is like “OTP” where its name made sense at the beginning but today it has grown beyond that. All it matters now is that we put in the “priv” directory any artifact that you need in production alongside your code.

6 Likes