(CompileError) undefined function attr/3 (there is no such import)

Why am i receiving compile error?

It’s returning “(CompileError) undefined function attr/3 (there is no such import)” from compilation.

It’s a Core module of heex functions, and i’m trying to use attr/3 macro.

image

1 Like

Can you show the output of mix deps|grep phoenix

1 Like

Version of phoenix_live_view. Sorry, and thanks!

* phoenix 1.6.15 (Hex package) (mix)
  locked at 1.6.15 (phoenix) d70ab9fb
* phoenix_ecto 4.4.0 (Hex package) (mix)
  locked at 4.4.0 (phoenix_ecto) 09864e55
* phoenix_html 3.2.0 (Hex package) (mix)
  locked at 3.2.0 (phoenix_html) 36ec97ba
* phoenix_live_dashboard 0.6.5 (Hex package) (mix)
  locked at 0.6.5 (phoenix_live_dashboard) ef4fa50d
* phoenix_live_reload 1.4.1 (Hex package) (mix)
  locked at 1.4.1 (phoenix_live_reload) 9bffb834
* phoenix_live_view 0.17.12 (Hex package) (mix)
  locked at 0.17.12 (phoenix_live_view) af6dd5e0
* phoenix_pubsub 2.1.1 (Hex package) (mix)
  locked at 2.1.1 (phoenix_pubsub) 81367c6d
* phoenix_template 1.0.0 (Hex package) (mix)
  locked at 1.0.0 (phoenix_template) 1b066f99
* phoenix_view 2.0.2 (Hex package) (mix)
  locked at 2.0.2 (phoenix_view) a929e723
1 Like

To clarify for other people coming here:

phoenix live view 0.18. introduced the attr feature. Upgrading is not that straightforward but explained here:
https://hexdocs.pm/phoenix_live_view/changelog.html#0-18-0-2022-09-20

You need Elixir v1.14.0+

1 Like

I think that’s only a requirement for the validation/warnings at compile time, not for 0.18 to work though.