`Jason.Encoder is not available, cannot derive Jason.Encoder` using `mix compile.elixir`

In case someone runs into the same problems I have run into:

  1. If you derive Protocols of external dependencies like Jason.Encoder, for compile.elixir to work, you need to first run mix compile.protocols
  2. Unlike stated here Rewriting imports to aliases with compilation tracers - Dashbit Blog, it seems like you need to use mix run import2alias.exs ... instead of elixir import2alias.exs ... otherwise the will be no mix environment (af far as I understand) and you’ll get this error: ** (exit) exited in: GenServer.call(Mix.ProjectStack, {:get_stack, #Function<10.68469381/1 in Mix.ProjectStack.peek/0>}, :infinity). At least that worked for me.