When precompiling Package extensions no error information is printed

Hi there,

I am surprised by no error info when I instantiate a project of mine where one dependency uses PackageExtensions.

even redoing import Pkg; Pkg.precompile() or import Pkg; Pkg.build("MyPackage") don’t print anything, while precompilation clearly states that it errored

1 Like

I wrote about thr need for better logging facilities in PrecompileTools.jl.

For now I suggest that you look into Julia’s logging infrastructure.

https://docs.julialang.org/en/v1/stdlib/Logging/

1 Like

I have what is, I think, the same issue as the original post. When precompiling a project, a red cross indicates that a package extension caused some error, but there is no error message.

@mkitti I do not understand how your answer helps. Could you please expand on it, e.g. what am I supposed to log?

Run the code below and report the error in a new post.

import Pkg; Pkg.precompile()

Ah, I found a solution:

julia> using Pkg
julia> Pkg.precompile(strict=True)

Using that I can see the actual error.

2 Likes

Compare the uninformative output without strict=true

julia> using Pkg; Pkg.precompile()
Precompiling project...
  ✗ moment_kinetics → file_io_netcdf
  0 dependencies successfully precompiled in 7 seconds. 183 already precompiled.

To a useful error message with strict=true (which I will now go and fix!)

julia> using Pkg; Pkg.precompile(strict=true)
Precompiling project...
  ✗ moment_kinetics → file_io_netcdf
  0 dependencies successfully precompiled in 7 seconds. 183 already precompiled.

ERROR: The following 1 dependency failed to precompile:

file_io_netcdf [7585edc2-0df8-5eac-b160-bce4a439309f]

Failed to precompile file_io_netcdf [7585edc2-0df8-5eac-b160-bce4a439309f] to "/home/john/.julia/compiled/v1.9/file_io_netcdf/jl_BwAz2w".
WARNING: could not import file_io.open_output_file_netcdf_implementation into file_io_netcdf
ERROR: LoadError: UndefVarError: `coordinate` not defined
Stacktrace:
 [1] top-level scope
   @ ~/physics/moment_kinetics-master/moment_kinetics/ext/file_io_netcdf.jl:156
 [2] include
   @ ./Base.jl:457 [inlined]
 [3] 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, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2049
 [4] top-level scope
   @ stdin:3
in expression starting at /home/john/physics/moment_kinetics-master/moment_kinetics/ext/file_io_netcdf.jl:3
in expression starting at stdin:3
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types ~/pkg/julia-1.9.3/share/julia/stdlib/v1.9/Pkg/src/Types.jl:69
 [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
   @ Pkg.API ~/pkg/julia-1.9.3/share/julia/stdlib/v1.9/Pkg/src/API.jl:1581
 [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:strict,), Tuple{Bool}}})
   @ Pkg.API ~/pkg/julia-1.9.3/share/julia/stdlib/v1.9/Pkg/src/API.jl:156
 [4] precompile(; name::Nothing, uuid::Nothing, version::Nothing, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:strict,), Tuple{Bool}}})
   @ Pkg.API ~/pkg/julia-1.9.3/share/julia/stdlib/v1.9/Pkg/src/API.jl:171
 [5] top-level scope
   @ REPL[8]:1
1 Like