InitError for a combination of ImageMagick and MATLAB

I’d appreciate any help with this cryptic issue:
Building a package with just two dependencies, ImageMagick and MATLAB, will result in this:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.1 (2018-09-29)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Kaka
[ Info: Recompiling stale cache file /home/yakir/.julia/compiled/v1.0/Kaka/RH5vt.ji for Kaka [9b64631b-9168-58e0-9795-6abd08b5997b]
ERROR: InitError: error compiling __init__: could not load library "/home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/libMagickWand-6.Q16.so"
/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/libpng16.so.16)
Stacktrace:
 [1] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:630
 [2] macro expansion at ./logging.jl:312 [inlined]
 [3] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:701
 [4] _tryrequire_from_serialized(::Base.PkgId, ::UInt64, ::Nothing) at ./loading.jl:645
 [5] _require_from_serialized(::String) at ./loading.jl:676
 [6] _require(::Base.PkgId) at ./logging.jl:317
 [7] require(::Base.PkgId) at ./loading.jl:855
 [8] macro expansion at ./logging.jl:311 [inlined]
 [9] require(::Module, ::Symbol) at ./loading.jl:837
during initialization of module ImageMagick

Kaka (excuse the name) Project.toml:

name = "Kaka"
uuid = "9b64631b-9168-58e0-9795-6abd08b5997b"
authors = ["yakir12 <12.yakir@gmail.com>"]
version = "0.1.0"

[deps]
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
MATLAB = "10e44e05-a98a-55b3-a45b-ba969058deb6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

and source:

module Kaka
using ImageMagick, MATLAB
end # module

I posted an issue in ImageMagick, but that might have been the wrong place?

More information about this bug can be found here and here.

Switching the order of the two packages did not resolve this issue for me.

A shot in the dark and only a temporary workaround if it works. Try to start Julia with

LD_PRELOAD=/home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/libz.so julia

to force loading the newer version of libz before any dependency manages to bring in the old system libz.

Worked! Thanks, I had no idea how to specify which libz julia should use. Awesome, thanks!