HDF5 cannot compile in M1 pro mac

The julia version is v1.7.0 rc-2, installed by official dmg.
OS: OSX Monterey

Hope to learn about how to resolve this problem, thanks!

The log:

julia> using HDF5
[ Info: Precompiling HDF5 [f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f]
ERROR: LoadError: UndefVarError: libhdf5 not defined
Stacktrace:
[1] top-level scope
@ ~/.julia/packages/HDF5/pIJra/src/api_types.jl:119
[2] include(mod::Module, _path::String)
@ Base ./Base.jl:420
[3] include(x::String)
@ HDF5 ~/.julia/packages/HDF5/pIJra/src/HDF5.jl:1
[4] top-level scope
@ ~/.julia/packages/HDF5/pIJra/src/HDF5.jl:51
[5] include
@ ./Base.jl:420 [inlined]
[6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base ./loading.jl:1318
[7] top-level scope
@ none:1
[8] eval
@ ./boot.jl:373 [inlined]
[9] eval(x::Expr)
@ Base.MainInclude ./client.jl:453
[10] top-level scope
@ none:1
in expression starting at /Users/John/.julia/packages/HDF5/pIJra/src/api_types.jl:119
in expression starting at /Users/John/.julia/packages/HDF5/pIJra/src/HDF5.jl:1
ERROR: Failed to precompile HDF5 [f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f] to /Users/John/.julia/compiled/v1.7/HDF5/jl_Ku0anm.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
@ Base ./loading.jl:1466
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base ./loading.jl:1410
[4] _require(pkg::Base.PkgId)
@ Base ./loading.jl:1120
[5] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:1013
[6] require(into::Module, mod::Symbol)
@ Base ./loading.jl:997

1 Like

I have the same issue. I even try directly giving the path to libhdf5 but it still doesn’t work.

Edit - Got it to work. I removed the .julia folder in your home directory completely, upgraded to 1.7.0 rc-3, and in my terminal exported the path to libhdf5 like this export JULIA_HDF5_PATH=/opt/homebrew/Cellar/hdf5/1.12.1 which I installed with homebrew, obviously by the path. Then started Julia and ran these commands using Pkg; Pkd.add("HDF5"); Pkg.build("HDF5").