Elixir: compilation warnings only in nix-shell -- ERL_LIBS

While trying out elixir in a nix-shell, running mix compile caused lots of compilation warnings:

$ nix-shell -p elixir
$ mix new foo
$ cd foo
$ mix compile
warning: this clause cannot match because a previous clause at line 1 always matches
  lib/list/chars.ex:1
...
warning: this clause cannot match because a previous clause at line 6 always matches
  lib/inspect.ex:6

I’m running NixOS, so I tried adding elixir to my nixos config instead of using the nix-shell and the warnings disappeared. I compared env inside and outside the nix-shell and found that in the shell, the environment had set:

ERL_LIBS=/nix/store/h7zp9vg05m4jimbvp4d9majqnq4qa8jb-elixir-1.9.1/lib/elixir/lib:/nix/store/h7zp9vg05m4jimbvp4d9majqnq4qa8jb-elixir-1.9.1/lib/elixir/lib

Since the above contains the same path twice, I tried removing the duplicate entry, but this made no difference.

Unsetting ERL_LIBS entirely, however, eliminated the warnings, and so far things seem to work as expected (I can run mix new , mix compile , and mix test without issue).

I don’t know enough about Elixir or Erlang to say whether this will break something else further down the line.

Does anyone know whether this is a reasonable workaround, or if there’s a better solution?

2 Likes

I encountered same warnings on macOS.

I got a hint from your unsetting ERL_LIBS and made my own nix user repository and it seems working.

Try my user repository GitHub - jechol/nix-beam: Nix Packages for Erlang, Elixir

1 Like