Reading static files at runtime

Hello, I am trying to load a file at runtime that errors out as could not read file "my_app/priv/private.pem": no such file or directory the first time. However, if I refresh the page, it works perfectly fine. I assume this is because it did not have a chance to load the first time around. What can I do to make sure it works perfectly the first time around?

Can you share some code how you are accessing the file?

1 Like

You will need to use something like Path.join(:code.priv_dir(:my_app), "private.pem") to get the actual path to the priv dir in a compiled app/release


Application.app_dir(:my_app, "priv/private.pem") does the same with a tad less complexity.