Unknown key for struct

So I’m trying to add ecto_psql_extras 0.6 to my project which pulls in table_rex 3.1.1. Now when I try to compile I get

== Compilation error in file lib/table_rex/renderer/text.ex ==
** (CompileError) lib/table_rex/renderer/text.ex:282: unknown key :wrapped_lines for struct TableRex.Cell
    (elixir 1.11.4) src/elixir_fn.erl:15: anonymous fn/4 in :elixir_fn.expand/3
    (elixir 1.11.4) expanding macro: Kernel.|>/2

This is perplexing to me. There is a wrapped_lines key in the struct.

grep 'defstruct' deps/table_rex/lib/table_rex/cell.ex
  defstruct raw_value: nil, rendered_value: "", align: nil, color: nil, wrapped_lines: [""]

I’ve deleted deps, build, run mix clean, etc. Nothing seems to do the trick. However, what’s odd is every time I try to compile I get a bunch of redefining module warnings. Even on a fresh deps pull and compile:

==> table_rex
Compiling 7 files (.ex)
warning: redefining module TableRex.Column (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.Column.beam)
  lib/table_rex/column.ex:1

warning: redefining module TableRex.Table (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.Table.beam)
  lib/table_rex/table.ex:1

warning: redefining module TableRex.Renderer.Text (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.Renderer.Text.beam)
  lib/table_rex/renderer/text.ex:1

warning: redefining module TableRex (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.beam)
  lib/table_rex.ex:1

warning: redefining module TableRex.Cell (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.Cell.beam)
  lib/table_rex/cell.ex:1

warning: redefining module TableRex.Renderer.Text.Meta (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.Renderer.Text.Meta.beam)
  lib/table_rex/renderer/text/meta.ex:1

warning: redefining module TableRex.Renderer (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.Renderer.beam)
  lib/table_rex/renderer.ex:1


== Compilation error in file lib/table_rex/renderer/text.ex ==
** (CompileError) lib/table_rex/renderer/text.ex:282: unknown key :wrapped_lines for struct TableRex.Cell
    (elixir 1.11.4) src/elixir_fn.erl:15: anonymous fn/4 in :elixir_fn.expand/3
    (elixir 1.11.4) expanding macro: Kernel.|>/2

It works for me.

You should mention which versions You use (Elixir, Phoenix, BEAM, OS etc).

$ elixir --version
Erlang/OTP 23 [erts-11.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Elixir 1.11.4 (compiled with Erlang/OTP 23)

Phoenix 1.6.2 on a Mac 10.15.7

It’s working for me for later versions.

Elixir 1.12.3, BEAM 24.

Maybe try to update Elixir, just a guess…

try to debug the infomation you are passing, specially row and cell
you can do IO.inspect(row, structs: false) and see what’s in it.

I can’t compile / run the app with this dependency so there’s not much I can do to debug it

Looking at the warnings messages that was printed, you can see this:

warning: redefining module TableRex.Renderer.Text (current version loaded from /Users/m/workspace/dozer/_build/dev/lib/licensir/ebin/Elixir.TableRex.Renderer.Text.beam)
  lib/table_rex/renderer/text.ex:1

What is licensir and why does it have TableRex modules inside of it? Could it have been vendored inside in a way it conflicts with other modules? If this is the case, then it means you are loading those modules, not the ones from latest TableRex.

3 Likes

Clone the repo, add the IO.inspect calles and update your mix.exs to locally load this dependency. and see what you see on the terminal.

Thanks Jose! I should have looked more closely to those paths. That does appear to be the issue as (I’m now just discovering) that project copys table_rex directly in to their codebase licensir/lib/table_rex at master · unnawut/licensir · GitHub