Can't compile sysimage in VSCode because of UndefRefError

I am trying to compile a sysimage using the VSCode Task:Build Task feature. This is for the OpticSim.jl package; it returns an UndefRefError, which I’ve never seen before. The error appears to occur somewhere in the GR package.

The OpticSim package loads without error but sysimage compilation doesn’t work.

Here is the error stacktrace:

error: UndefRefError: access to undefined reference"
Activating project at `~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/environments/sysimagecompile/v1.8`
[ Info: Now building a custom sysimage for the environment '/home/brian/repos/OpenSource/OpticSim.jl', excluding dev packages 'Symbol[]'.
┌ Info: Included packages: 
│       - Pkg
│       - ForwardDiff
│       - HTTP
│       - Luxor
│       - WGLMakie
│       - Zygote
│       - DataFrames
│       - SpecialFunctions
│       - Distributions
│       - ZipFile
│       - SHA
│       - LinearAlgebra
│       - Format
│       - ColorTypes
│       - LazySets
│       - Makie
│       - JSServe
│       - Polynomials
│       - GeometryBasics
│       - FileIO
│       - PackageCompiler
│       - GLMakie
│       - CSV
│       - Revise
│       - PlutoUI
│       - Random
│       - Libdl
│       - Optim
│       - Conda
│       - ColorSchemes
│       - ReverseDiff
│       - PyCall
│       - Images
│       - Plots
│       - Pluto
│       - Unitful
│       - StaticArrays
│       - ImageView
│       - Statistics
│       - MeshIO
│       - JuMP
│       - DelimitedFiles
│       - Roots
│       - Ipopt
│       - NLopt
│       - StringEncodings
│       - Colors
└       - InteractiveUtils
[ Info: Precompile statement files: String[]
[ Info: Precompile execution files: String[]
⡆ [01m:12s] PackageCompiler: compiling incremental system imageUndefRefError: access to undefined reference
Stacktrace:
  [1] getproperty
    @ ./Base.jl:38 [inlined]
  [2] getindex
    @ ./refvalue.jl:56 [inlined]
⠋ [01m:12s] PackageCompiler: compiling incremental system imageBool)
    @ GR ~/.julia/packages/GR/uzy0J/src/funcptrs.jl:33
  [4] get_func_ptr (repeats 2 times)
    @ ~/.julia/packages/GR/uzy0J/src/funcptrs.jl:50 [inlined]
  [5] libGR_ptr
    @ ~/.julia/packages/GR/uzy0J/src/funcptrs.jl:59 [inlined]
  [6] setcharheight(height::Float64)
    @ GR ~/.julia/packages/GR/uzy0J/src/GR.jl:1520
  [7] gr_set_font(f::Plots.Font, s::Plots.Subplot{Plots.GRBackend}; halign::Symbol, valign::Symbol, color::ColorTypes.RGB{FixedPointNumbers.N0f8}, rotation::Int64)
    @ Plots ~/.julia/packages/Plots/gzYVM/src/backends/gr.jl:424
  [8] gr_set_tickfont(sp::Plots.Subplot{Plots.GRBackend}, ax::Plots.Axis; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Plots ~/.julia/packages/Plots/gzYVM/src/backends/gr.jl:684
  [9] gr_set_tickfont(sp::Plots.Subplot{Plots.GRBackend}, ax::Plots.Axis)
    @ Plots ~/.julia/packages/Plots/gzYVM/src/backends/gr.jl:684
 [10] _update_min_padding!(sp::Plots.Subplot{Plots.GRBackend})
    @ Plots ~/.julia/packages/Plots/gzYVM/src/backends/gr.jl:860
 [11] iterate
    @ ./generator.jl:47 [inlined]
 [12] _collect(c::Matrix{RecipesBase.AbstractLayout}, itr::Base.Generator{Matrix{RecipesBase.AbstractLayout}, typeof(Plots._update_min_padding!)}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{2})
    @ Base ./array.jl:807
 [13] collect_similar
    @ ./array.jl:716 [inlined]
 [14] map
    @ ./abstractarray.jl:2933 [inlined]
 [15] _update_min_padding!(layout::Plots.GridLayout)
    @ Plots ~/.julia/packages/Plots/gzYVM/src/layouts.jl:268
 [16] prepare_output(plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~/.julia/packages/Plots/gzYVM/src/plot.jl:241
 [17] display
    @ ~/.julia/packages/Plots/gzYVM/src/output.jl:173 [inlined]
 [18] gui(plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~/.julia/packages/Plots/gzYVM/src/output.jl:163
 [19] var"##1#607"()
    @ Plots ~/.julia/packages/Plots/gzYVM/src/precompile.jl:20
 [20] top-level scope
    @ ~/.julia/packages/Plots/gzYVM/src/precompile.jl:26
 [21] eval
    @ ./boot.jl:368 [inlined]
 [22] eval
    @ ~/.julia/packages/Plots/gzYVM/src/Plots.jl:1 [inlined]
 [23] _broadcast_getindex_evalf
    @ ./broadcast.jl:670 [inlined]
 [24] _broadcast_getindex
    @ ./broadcast.jl:643 [inlined]
 [25] getindex
    @ ./broadcast.jl:597 [inlined]
 [26] copy(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(Plots.eval), Tuple{Vector{Expr}}})
    @ Base.Broadcast ./broadcast.jl:899
 [27] materialize
    @ ./broadcast.jl:860 [inlined]
 [28] macro expansion
    @ ~/.julia/packages/Plots/gzYVM/src/precompile.jl:33 [inlined]
 [29] macro expansion
    @ ~/.julia/packages/SnoopPrecompile/UWvXF/src/SnoopPrecompile.jl:51 [inlined]
 [30] (::Plots.var"#653#654")()
    @ Plots ~/.julia/packages/Plots/gzYVM/src/precompile.jl:30
 [31] withenv(f::Plots.var"#653#654", keyvals::Pair{String, String})
    @ Base ./env.jl:172
 [32] macro expansion
    @ ~/.julia/packages/Plots/gzYVM/src/precompile.jl:29 [inlined]
 [33] macro expansion
    @ ~/.julia/packages/SnoopPrecompile/UWvXF/src/SnoopPrecompile.jl:107 [inlined]
 [34] top-level scope
    @ ~/.julia/packages/Plots/gzYVM/src/precompile.jl:5
 [35] include(mod::Module, _path::String)
    @ Base ./Base.jl:419
 [36] include(x::String)
    @ Plots ~/.julia/packages/Plots/gzYVM/src/Plots.jl:1
 [37] top-level scope
    @ ~/.julia/packages/Plots/gzYVM/src/Plots.jl:205
 [38] include
    @ ./Base.jl:419 [inlined]
 [39] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1367
 [40] _require_prelocked(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1200
 [41] macro expansion
    @ ./lock.jl:223 [inlined]
 [42] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1195
 [43] top-level scope
    @ /tmp/jl_n45gl8f0xC:28
in expression starting at /home/brian/.julia/packages/Plots/gzYVM/src/precompile.jl:4
in expression starting at /home/brian/.julia/packages/Plots/gzYVM/src/Plots.jl:1
in expression starting at /tmp/jl_n45gl8f0xC:28
✖ [01m:12s] PackageCompiler: compiling incremental system image
ERROR: LoadError: failed process: Process(`/home/brian/.julia/juliaup/julia-1.8.2+0.x64/bin/julia --color=yes --startup-file=no --cpu-target=native -O3 --sysimage=/home/brian/.julia/juliaup/julia-1.8.2+0.x64/lib/julia/sys.so --project=/home/brian/repos/OpenSource/OpticSim.jl --output-o=/tmp/jl_riH8Jyb4ZG.o /tmp/jl_n45gl8f0xC`, ProcessExited(1)) [1]

Stacktrace:
 [1] pipeline_error
   @ ./process.jl:565 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base ./process.jl:480
 [3] run
   @ ./process.jl:477 [inlined]
 [4] #14
   @ ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/PackageCompiler/ext/TerminalSpinners.jl:157 [inlined]
 [5] spin(f::PackageCompiler.var"#14#15"{Cmd}, s::PackageCompiler.TerminalSpinners.Spinner{Base.TTY})
   @ PackageCompiler.TerminalSpinners ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/PackageCompiler/ext/TerminalSpinners.jl:164
 [6] macro expansion
   @ ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/PackageCompiler/ext/TerminalSpinners.jl:157 [inlined]
 [7] create_sysimg_object_file(object_file::String, packages::Vector{String}, packages_sysimg::Set{Base.PkgId}; project::String, base_sysimage::String, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, cpu_target::String, script::Nothing, sysimage_build_args::Cmd, extra_precompiles::String, incremental::Bool)
   @ PackageCompiler ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/PackageCompiler/src/PackageCompiler.jl:359
 [8] create_sysimage(packages::Vector{Symbol}; sysimage_path::String, project::String, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, incremental::Bool, filter_stdlibs::Bool, cpu_target::String, script::Nothing, sysimage_build_args::Cmd, include_transitive_dependencies::Bool, base_sysimage::Nothing, julia_init_c_file::Nothing, version::Nothing, soname::Nothing, compat_level::String, extra_precompiles::String)
   @ PackageCompiler ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/packages/PackageCompiler/src/PackageCompiler.jl:510
 [9] top-level scope
   @ ~/.vscode/extensions/julialang.language-julia-1.38.2/scripts/tasks/task_compileenv.jl:94
in expression starting at /home/brian/.vscode/extensions/julialang.language-julia-1.38.2/scripts/tasks/task_compileenv.jl:94

Here are the packages being used:

packages
(OpticSim) pkg> st
Project OpticSim v0.6.0
Status `~/repos/OpenSource/OpticSim.jl/Project.toml`
  [336ed68f] CSV v0.10.7
  [35d6a980] ColorSchemes v3.19.0
  [3da002f7] ColorTypes v0.11.4
  [5ae59095] Colors v0.12.8
  [8f4d0f93] Conda v1.7.0
  [a93c6f00] DataFrames v1.4.3
  [31c24e10] Distributions v0.25.77
  [5789e2e9] FileIO v1.16.0
  [1fa38f19] Format v1.3.2
  [f6369f11] ForwardDiff v0.10.33
  [e9467ef8] GLMakie v0.7.2
  [5c1252a2] GeometryBasics v0.4.4
⌅ [cd3eb016] HTTP v0.9.17
  [86fae568] ImageView v0.11.1
  [916415d5] Images v0.25.2
  [b6b21f68] Ipopt v1.1.0
  [824d6782] JSServe v1.2.9
  [4076af6c] JuMP v1.4.0
  [b4f0291d] LazySets v2.4.0
  [ae8d54c2] Luxor v3.5.0
  [ee78f7c6] Makie v0.18.2
  [7269a6da] MeshIO v0.4.10
  [76087f3c] NLopt v0.6.5
  [429524aa] Optim v1.7.3
  [9b87118b] PackageCompiler v2.1.0
  [91a5bcdd] Plots v1.36.1
⌃ [c3e4b0f8] Pluto v0.17.7
  [7f904dfe] PlutoUI v0.7.48
  [f27b6e38] Polynomials v3.2.0
  [438e738f] PyCall v1.94.1
  [37e2e3b7] ReverseDiff v1.14.4
  [295af30f] Revise v3.4.0
  [f2b01f46] Roots v2.0.8
  [276daf66] SpecialFunctions v2.1.7
  [90137ffa] StaticArrays v1.5.9
  [69024149] StringEncodings v0.3.5
  [1986cc42] Unitful v1.12.0
  [276b4fcb] WGLMakie v0.7.2
  [a5390f91] ZipFile v0.10.0
  [e88e6eb3] Zygote v0.6.49
  [8bb1440f] DelimitedFiles
  [b77e0a4c] InteractiveUtils
  [8f399da3] Libdl
  [37e2e46d] LinearAlgebra
  [44cfe95a] Pkg v1.8.0
  [9a3f8284] Random
  [ea8e919c] SHA v0.7.0
  [10745b16] Statistics

and here’s the version of Julia:

Julia version
julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 128 × AMD EPYC 7702P 64-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver2)
  Threads: 128 on 128 virtual cores
Environment:
  JULIA_NUM_THREADS = 64
  JULIA_EDITOR = code.cmd
  JULIA_STACKTRACE_ABBREVIATED = true

Anybody have a clue how to fix this?