elixir-image/image

Compile error on elixir 1.15 and erlang 26.0.1

Closed this issue · 9 comments

==> image
Compiling 70 files (.ex)

== Compilation error in file lib/image/math.ex ==
** (SyntaxError) lib/image/math.ex:60:24: syntax error before: do
    |
 60 |   def -(%Vimage{} = a) do
    |                        ^
    (elixir 1.15.4) lib/kernel/parallel_compiler.ex:377: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8
could not compile dependency :image, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile image --force", update it with "mix deps.update image" or clean it with "mix deps.clean image"

Upgrading to the latest elixir/erlang fixed the issue. Might want to bump the min erlang/elixir version requirements.

Same issue here:

$ elixir -v
Erlang/OTP 25 [erts-13.1.5] [source] [64-bit] [smp:32:12] [ds:32:12:10] [async-threads:1] [jit:ns]

Elixir 1.14.0 (compiled with Erlang/OTP 24)

Thanks for the reports. I'm not surprised it doesn't compile on Elixir 1.14 given that it doesn't compile on Elixir 1.15.

But I am surprised it doesn't compile on Elixit 1.15 - unary minus as a function must have been introduced after that.

I'll update the minimum requirement to Elixir 1.16 for now and see if there is a way to get it to compile on Elixir 1.15. I try to have current release plus the 2 previous being supported. But it may not be possible in this case.

Wow, maybe it's even an Elixir 1.17 requirement - which is not the objective. I'll do some more research.

Wow, maybe it's even an Elixir 1.17 requirement - which is not the objective. I'll do some more research.

What is the last version of Image that doesn't require Elixir > 1.14?

(I'm using Elixir from the Debian bookworm apt repo, and had been using Image without any problems thus far, so I'd rather not have to deal with managing Elixir versions with asdf, just to make a thumbnail :))

I think I can make this work back to 1.14, will need a few hours to validate.

@waseigo, @stocks29, I've published image version 0.54.1 with the following changelog entry:

Bug Fixes

  • Adjust Image.Math.-/1 (unary minus) syntax to be compatible on more elixir versions. Should be ok back to Elixir 1.12 depending on vix version support requirement on OTP.

I've tested this on Elixir 1.14.2 and OTP 26. Current vix requires OTP 26. If you need an earlier OTP version then you may need to find an earlier version of vix that supports it.

Let me know if this gets you both back in business?

@kipcole9 I confirm that Image v0.54.1 compiles successfully with Elixir v1.14.0 (compiled with Erlang/OTP 24) and Erlang/OTP 25 out of the Debian bookworm apt repository. Interesting -- maybe it won't work as expected, due to the dependency of vix on OTP 26?

Many, many thanks!

Edit: nope, it (thumbnailing) seems to work as expected!

iex> File.read!("/tmp/northwind_elixir_traders_bg_1080p.png") |> Image.from_binary |> elem(1) |> Image.thumbnail(400) |> elem(1) |> Image.write("/tmp/test.png")
{:ok, %Vix.Vips.Image{ref: #Reference<0.4235122929.1975386177.30151>}}

vix will fail at compile time if the version of OTP is not compatible. So if image compiles, you should be good to go - which is what you're seeing.

Closing for now - please do reopen if needed.

Awesome, thank you!