# When precompiling Package extensions no error information is printed

**URL:** <https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 22, 2023, 2:12pm UTC](https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575 "2023-11-22T14:12:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Post date:** [November 22, 2023, 2:12pm UTC](https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575/1 "2023-11-22T14:12:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 22, 2023, 3:11pm UTC](https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575/2 "2023-11-22T15:11:36Z")

</div>

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

> <https://github.com/JuliaLang/PrecompileTools.jl/issues/19>
>
> Inspired by https://github.com/julia-vscode/LanguageServer.jl/pull/1222, we may …need some specialized facilities to control log messages during precompilation.

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

[https://docs.julialang.org/en/v1/stdlib/Logging/](https://docs.julialang.org/en/v1/stdlib/Logging/)

> **[GitHub - JuliaLogging/LoggingExtras.jl: Composable Loggers for the Julia...](https://github.com/JuliaLogging/LoggingExtras.jl)**
>
> Composable Loggers for the Julia Logging StdLib. Contribute to JuliaLogging/LoggingExtras.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [December 19, 2023, 4:01pm UTC](https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575/3 "2023-12-19T16:01:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 19, 2023, 4:08pm UTC](https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575/4 "2023-12-19T16:08:31Z")

</div>

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

```julia
import Pkg; Pkg.precompile()

```

---

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [December 19, 2023, 4:08pm UTC](https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575/5 "2023-12-19T16:08:35Z")

</div>

Ah, I found a solution:

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

```

Using that I can see the actual error.

---

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [December 19, 2023, 4:10pm UTC](https://discourse.julialang.org/t/when-precompiling-package-extensions-no-error-information-is-printed/106575/6 "2023-12-19T16:10:59Z")

</div>

Compare the uninformative output without `strict=true`

```julia
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
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

```
