I realized that this is not a VScode issue: it is an environment issue. CairoMakie fails to precompile in a specific package’s environment, whereas it doesn’t in the base environment. The reason I have been having the precompilation error in a REPL started in VScode seems that VScode starts a REPL by default in the environment of the package I am developing in VScode. On the other hand, the reason I haven’t had this error in a REPL started in a standalone terminal program seems that the terminal program starts a REPL in the home (base?) environment.
Here is a concrete scenario. I start a REPL fresh, either in a standalone terminal program or in VScode. I make sure that I am in the home environment by performing pkg> activate
and checking the prompt of the package manager mode is (@v1.8) pkg>
:
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.8.0 (2022-08-17)
_/ |\__'_|_|_|\__'_| |
|__/ |
(@v1.8) pkg> activate
Activating project at `~/.julia/environments/v1.8`
(@v1.8) pkg>
Now, I exit the package manager mode and import CairoMakie. I don’t get the precompilation error:
julia> using CairoMakie
[ Info: Precompiling CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0]
julia>
Next, I start a REPL fresh again, either in a standalone terminal program or in VScode, but I do so in the directory of a package I am developing. Then, make sure that I am in the package’s environment by performing pkg> activate .
and checking the prompt of the package manager mode is (MY_PKG_NAME) pkg>:
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.8.0 (2022-08-17)
_/ |\__'_|_|_|\__'_| |
|__/ |
(@v1.8) pkg> activate .
Activating project at `<my package's directory>`
(MY_PKG_NAME) pkg>
I exit the package manager mode, and import CairoMakie. This time I get the precompilation error:
julia> using CairoMakie
[ Info: Precompiling CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0]
WARNING: could not import StaticArraysCore.FieldArray into StructArrays
ERROR: LoadError: UndefVarError: FieldArray not defined
Stacktrace:
[1] top-level scope
@ ~/.julia/packages/StructArrays/w2GaP/src/staticarrays_support.jl:25
[2] include(mod::Module, _path::String)
@ Base ./Base.jl:419
[3] include(x::String)
@ StructArrays ~/.julia/packages/StructArrays/w2GaP/src/StructArrays.jl:1
[4] top-level scope
@ ~/.julia/packages/StructArrays/w2GaP/src/StructArrays.jl:16
[5] include
@ ./Base.jl:419 [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:1554
[7] top-level scope
@ stdin:1
in expression starting at ~/.julia/packages/StructArrays/w2GaP/src/staticarrays_support.jl:25
in expression starting at ~/.julia/packages/StructArrays/w2GaP/src/StructArrays.jl:1
in expression starting at stdin:1
ERROR: LoadError: Failed to precompile StructArrays [09ab397b-f2b6-538f-b94a-2f83cf4a842a] to ~/.julia/compiled/v1.8/StructArrays/jl_2HyVPg.
Stacktrace:
...
ERROR: LoadError: Failed to precompile GeometryBasics [5c1252a2-5f33-56bf-86c9-59e7332b4326] to ~/.julia/compiled/v1.8/GeometryBasics/jl_SuDD7I.
Stacktrace:
...
ERROR: LoadError: Failed to precompile FreeTypeAbstraction [663a7486-cb36-511b-a19d-713bb74d65c9] to ~/.julia/compiled/v1.8/FreeTypeAbstraction/jl_nN8aUQ.
Stacktrace:
...
ERROR: LoadError: Failed to precompile MathTeXEngine [0a4f8689-d25c-4efe-a92b-7142dfc1aa53] to ~/.julia/compiled/v1.8/MathTeXEngine/jl_DhKl6k.
Stacktrace:
...
ERROR: LoadError: Failed to precompile Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a] to ~/.julia/compiled/v1.8/Makie/jl_bniyEV.
Stacktrace:
...
ERROR: Failed to precompile CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0] to ~/.julia/compiled/v1.8/CairoMakie/jl_Y4wmWC.
Stacktrace:
...
I am glad that I’ve found a method to reproduce the precompilation error reliably. Hope that this information is useful for other people to figure out a solution to the precompilation error.