67 words, 1 min read
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.
continue reading on elixirdrops.net
⚠️ This post links to an external website. ⚠️
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.