'Julia on M1: libhd5f not defined

I am encountering a bug in Julia v1.7.2.

I am trying to include a util.jl file that uses a Module.

Everything in that module works fine (I have put into a Pluto.jl notebook and everything runs).

However, when I try the following lines of code,

using Pkg
Pkg.activate(joinpath(@__DIR__, "../../dev/"))
using Module

I get this error

    Activating project at `~/Desktop/dev`
    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:418
  [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:418 [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::String)
    @ 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/me/.julia/packages/HDF5/pIJra/src/api_types.jl:119
in expression starting at /Users/me/.julia/packages/HDF5/pIJra/src/HDF5.jl:1
ERROR: LoadError: Failed to precompile HDF5 [f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f] to /Users/me/.julia/compiled/v1.7/HDF5/jl_m27neP.
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
  [7] include
    @ ./Base.jl:418 [inlined]
  [8] 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::String)
    @ Base ./loading.jl:1318
  [9] top-level scope
    @ none:1
 [10] eval
    @ ./boot.jl:373 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude ./client.jl:453
 [12] top-level scope
    @ none:1
in expression starting at /Users/me/Desktop/src/Module.jl:1

However, if I just try

using HDF5

I don't have any problem.

I don't understand why I can use using HDF5 just fine; I can run everything in the module just fine; but when I try to import the module, I get an error saying there is a problem with HDF5. Can anyone provide some additional insight into how Julia works that could make this problem make sense to me?



Solution 1:[1]

Are you running with Rosetta or the native build? If native, you should try 1.8rc3 since 1.7 has a lot of bugs with M1 native.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oscar Smith