Closed erszcz closed 1 year ago
With ASDF in the env it's roughly:
> {elixir_bin, 0} = System.cmd("asdf", ["which", "elixir"])
> Path.wildcard(elixir_bin |> Path.dirname() |> Path.dirname() |> Path.join("lib/*/ebin"))
["/Users/erszcz/.asdf/installs/elixir/1.13.3-otp-24/lib/eex/ebin",
"/Users/erszcz/.asdf/installs/elixir/1.13.3-otp-24/lib/elixir/ebin",
"/Users/erszcz/.asdf/installs/elixir/1.13.3-otp-24/lib/ex_unit/ebin",
"/Users/erszcz/.asdf/installs/elixir/1.13.3-otp-24/lib/iex/ebin",
"/Users/erszcz/.asdf/installs/elixir/1.13.3-otp-24/lib/logger/ebin",
"/Users/erszcz/.asdf/installs/elixir/1.13.3-otp-24/lib/mix/ebin"]
Example code which leads to the problem:
$ cat 1.12/range_step.ex
defmodule RangeStep do
def to_list do
Enum.to_list(1..100//5)
end
end
Invocation without --path-add
:
$ ../../gradient 1.12/range_step.ex
Typechecking files...
1.12/range_step.ex: Call to undefined function Enum.to_list/1 on line 3
Total errors: 1
With the flag:
$ ../../gradient --path-add /Users/erszcz/.asdf/installs/elixir/1.13.4-otp-24/lib/elixir/ebin 1.12/range_step.ex
Typechecking files...
No errors found!
So far the Gradient escript developed in #121 does not by default see Elixir libs, which will lead to false positives on unknown modules, like this:
The issue can be solved by using
--path-add
on the command line:But we could also try to solve it programmatically on escript startup by detecting if we're running with ASDF ~or Kiex in the env, or at least trying to locate Elixir with
which elixir
.~ EDIT: let's focus on asdf in this ticket. It would free the user from appending the--add-path
flag and looking for the right path(s) each time the escript is used.