I am doing the Elixir for Programmers course and really enjoying it. I’ve come up against an issue where a relative path defining an asset for one subcomponent of the project is incorrect when running another component that uses it as a dependency.
The project structure is this:
root/
|_dictionary/
| |_assets/
| | |_words.txt
| |
| |_lib/
| | |_impl/
| | | |_word_list.ex # this file contains call to read the above words.txt file
| | |
| | |_runtime/ # rest of stuff I believe irrelevant to this ?
| |
| |_dictionary.ex # defined as application in mix.exs so this is what the other components are calling to
|
|_hangman/ # duplicates above structure essentially, again probably not relevant to ? below this level in large part
|_mix.exs # contains {:dictionary, path: "../dictionary"} in deps
When calling the Dictionary
app in iex
launched from the dictionary
directory the relative path assets/words.txt
works. When calling the Hangman
app in iex
launched from the hangman
directory, the relative path needs to be ../dictionary/assets/words.txt
. I understand why this would be, however I need to be able to define the path in such a way that would be correct regardless of the directory I’m in when I open iex
. Any suggestions or tips?