Search code examples
elixir

How To Get The Root Directory Of an Elixir Project


In an Elixir project, you can use

Path.expand

to define a file or directory as a relative path from the current file.

For example: Path.expand("../../../lib/file.ex")

but how about finding a path from the root level of the project?


Solution

  • If you'd like to get the project's root directory, use

    File.cwd!
    

    source: https://groups.google.com/d/topic/elixir-lang-talk/Ls0eJDdMMW8

    (note: I pulled this here only so it's not buried in a dead forum behind Google auth wall & subject to Google data preservation policies)