Correct way to save Makie plot to IOBuffer

Huh, that works great in the REPL but fails when called in the full code with

MethodError: no method matching show(::IOBuffer, ::Type{MIME{Symbol("image/png")}}, ::Makie.Figure)

Adding a call to methods immediately before the call to show only makes me more confused, the method is right there!

methods(show, [IO, MIME"image/png", Any]) = # 2 methods for generic function "show":
[1] show(io::IO, m::MIME, figlike::Union{Makie.Figure, Makie.FigureAxisPlot, Makie.Scene}) in Makie at /home/user/.julia/packages/Makie/Ppzqh/src/display.jl:114
[2] show(io::IO, ::MIME{Symbol("image/png")}, surface::Cairo.CairoSurface) in Cairo at /home/user/.julia/packages/Cairo/smWIA/src/Cairo.jl:441

I’ll continue to investigate.