Hello
I got a Elixir library that I install using internal dependencies, because the library is private with no access to Private hex.pm. deps()
in mix.exs
is configured with the current line, which has been working great (so far).
{:protocols, git: "git@<redacted>/protocols.git", tag: "0.1.5", sparse: "protocols-elixir"},
When I try to run the app using mix run
or while build the Docker image, I’m facing the current error that stops the compilation:
** (CompileError) lib/brain/core/utils/to_protocols.ex:5: Protocols.TimeSeries.__struct__/1 is undefined,
cannot expand struct Protocols.TimeSeries.
Make sure the struct name is correct.
If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
#24 3.797 lib/brain/core/utils/to_protocols.ex:4: (module)
------
defmodule Brain.Core.Utils.ToProtocols do
def to_timeseries(forecast) do
%Protocols.TimeSeries{points: to_points(forecast)}
end
[...]
end
Maybe I have a problem of import or a cyclic usage, but the weird behavior is that,
- I got the compilation issue at 0.1.5
- I’m updating the dependency down to 0.1.4 with
mix deps.get + mix run
, the app is compiling and running seamlessly. - I’m updating the dependency up to 0.1.5 with
mix deps.get + mix run
, the app is compiling and running seamlessly. - One code edition in the current project triggering a new compilation, and the issue with the library is back.
The Dockerfile (FROM elixir:1.13.0-slim
) is facing the same issue, with those steps,
RUN mix local.rebar --force && mix local.hex --force
ARG MIX_ENV=prod
ENV LANG=C.UTF-8
ENV MIX_ENV=${MIX_ENV}
COPY mix.exs mix.lock ./
COPY config ./config
RUN mix do deps.get, deps.compile
COPY lib ./lib
RUN mix compile
COPY rel ./rel
RUN mix release
My current setup is,
elixir 1.13.0
erlang 24.1.7
Code can compile, which I conclude that there is no struct name issue or cyclic module usage, but somehow only when i’m {down,up}grading versions which is strange, leaving me without hypothesis left.
Do you have any ideas ? Or in need of further details ?
Thanks in advance !