We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Reliable File Access in Elixir Release
mbashia
0 comments
Copy link
When dealing with file access in Elixir releases, using File.read!(file_path) directly might cause issues, as it may not locate files bundled in the release. To ensure your file is correctly located within the release, especially in priv directories, use :code.priv_dir/1 with Path.join/2:
file_path = Path.join(:code.priv_dir(:phx_tools), "file.sh")
File.read!(file_path)
This approach ensures that the file path works reliably in both development and production, avoiding missing file errors in releases.
copied to clipboard