We have some shared elixir files (generated pb schemas, test factories) outside of our projects. I guess the correct way to do this is to turn them into proper projects + dependencies. But I thought I'd document the issue in case anyone else runs into it.
To reproduce, create the following structure:
proj/
lib/
lib/valid.ex
mix.exs
bad/
hello.ex
hello.ex can be simple:
defmodule Hello do
def world(), do: "hello world"
end
In mix.exs reference both paths: elixirc_paths: ["./lib", "../bad"] and from valid.ex try calling Hello.world/0.
In 1.8.2 this compiles and runs. In 1.9, https://github.com/elixir-lang/elixir/blob/v1.9/lib/mix/lib/mix/compilers/elixir.ex#L267 fails because the List.keyfind/3 returns nil.
Fundamentally, this happens because:
Path.relative_to("/home/karl/code/bad/hello.ex", "/home/karl/code/test")
returns "/home/karl/code/bad/hello.ex" instead of "../bad/hello.ex"
This appears to have been broken by https://github.com/elixir-lang/elixir/commit/a3c5820d125a472c0fb43eee935d1fb4bddfc72d
Thanks for the report! Indeed using a dep would be the best way to go. I think this can also be fixed in your project by doing elixirc_paths: ["./lib", Path.expand("../bad")].
But I am considering documenting that elixirc_paths have to be relative paths to the current directory. Other assumptions may break by having the paths out.
We are raising cleaner errors with 7ce98af5a8fabb48265896ff526fbbffa6d06221. Thank you!
Most helpful comment
Thanks for the report! Indeed using a dep would be the best way to go. I think this can also be fixed in your project by doing
elixirc_paths: ["./lib", Path.expand("../bad")].But I am considering documenting that
elixirc_pathshave to be relative paths to the current directory. Other assumptions may break by having the paths out.