CairoMakie with Julia 1.8 on VScode

I just installed Julia 1.8 and am trying to use it in VScode. When I try to import CairoMakie in the REPL in VScode, it generates the following series of errors. I wonder if anyone is experiencing the same issue and knows how to resolve it.

julia> VERSION

(@v1.8) pkg> st CairoMakie
Status `~/.julia/environments/v1.8/Project.toml`
  [13f3f980] CairoMakie v0.8.13

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
ERROR: LoadError: Failed to precompile StructArrays [09ab397b-f2b6-538f-b94a-2f83cf4a842a] to /Users/wo28768/.julia/compiled/v1.8/StructArrays/jl_wxC5j6.
ERROR: LoadError: Failed to precompile GeometryBasics [5c1252a2-5f33-56bf-86c9-59e7332b4326] to /Users/wo28768/.julia/compiled/v1.8/GeometryBasics/jl_wEHwRT.
ERROR: LoadError: Failed to precompile FreeTypeAbstraction [663a7486-cb36-511b-a19d-713bb74d65c9] to /Users/wo28768/.julia/compiled/v1.8/FreeTypeAbstraction/jl_kbOqJS.
ERROR: LoadError: Failed to precompile MathTeXEngine [0a4f8689-d25c-4efe-a92b-7142dfc1aa53] to /Users/wo28768/.julia/compiled/v1.8/MathTeXEngine/jl_nJyW8Z.
ERROR: LoadError: Failed to precompile Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a] to /Users/wo28768/.julia/compiled/v1.8/Makie/jl_SH9aGz.
ERROR: Failed to precompile CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0] to /Users/wo28768/.julia/compiled/v1.8/CairoMakie/jl_w8sV5y.

Here are the steps I followed to resolve this issue:

  • Reinstall VScode.
  • pkg> add Makie#master
  • pkg> add CairoMakie#master
  • pkg> rm Makie
  • pkg> rm CairoMakie
  • pkg> add CairoMakie

Not sure which steps were important, but after the above steps, the issues are gone.

Note that I had the errors only in the REPL inside VScode. In the REPL started in a standalone terminal app, using CairoMakie did not generate any errors. So I think probably reinstalling VScode was the crucial step, though I was using the up-to-date version already before reinstallation.

Hi thanks for your suggestions but I failed to compile CairoMakie with version 1.8 after following your steps. I got the following error message:

Precompiling CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0]
ERROR: LoadError: Failed to precompile CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0] to C:\Users\pollaccoj.julia\compiled\v1.8\CairoMakie\jl_82C2.tmp.

Many thanks for suggesting any fix

What is the actual error why it fails the precompile? Should be below the part you posted.

Thanks for your answer. The installation of CairoMakie is fine, it is when you execute the code that it fails.

[ Info: Precompiling CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0]
ERROR: LoadError: Failed to precompile CairoMakie [13f3f980-e62b-5c42-98c6-ff1f3baf88f0] to C:\Users\pollaccoj\.julia\compiled\v1.8\CairoMakie\jl_884B.tmp.
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base .\loading.jl:1705
  [3] compilecache
    @ .\loading.jl:1649 [inlined]
  [4] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1337
  [5] _require_prelocked(uuidkey::Base.PkgId)
    @ Base .\loading.jl:1200
  [6] macro expansion
    @ .\loading.jl:1180 [inlined]
  [7] macro expansion
    @ .\lock.jl:223 [inlined]
  [8] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1144
  [9] include(fname::String)
    @ Base.MainInclude .\client.jl:476
 [10] top-level scope
    @ D:\Main\MODELS\SoilWater_ToolBox\src\HyPix\IncludeHypix.jl:48
in expression starting at D:\Main\MODELS\SoilWater_ToolBox\src\HyPix\OutputHypix\PlotHypix.jl:4
in expression starting at D:\Main\MODELS\SoilWater_ToolBox\src\HyPix\IncludeHypix.jl:48


Hm okay that’s not helpful… Can you delete the CairoMakie folder (or all folders) in .julia/compiled in case those files are corrupted?

I was able to reproduce the same issue on a different computer, and I was able to resolve the issue by following a simplified version of my previous solution, which is

  1. Reinstall VScode.
  2. (@v1.8) pkg> rm CairoMakie
  3. (@v1.8) pkg> add CairoMakie#master
  4. julia> using CairoMakie
  5. (@v1.8) pkg> rm CairoMakie
  6. (@v1.8) pkg> add CairoMakie

Step 4 does not generate any error, but we usually want to use a released version, so Steps 5 and 6. I think installing and using the master of CairoMakie effectively does the deletion of CairoMakie as @jules suggested above.

I am using macOS, though I don’t think this is relevant to the present problem.

1 Like

I think something is wrong about the combination of CairoMakie, Julia 1.8, and VScode. I had eliminated the errors (reported in OP) during using CairoMakie in VScode terminal once, but suddenly the same errors started showing up again. I did

(@v1.8) pkg> rm CairoMakie
(@v1.8) pkg> add CairoMakie
julia> using CairoMakie

but the errors didn’t go away. Then I tried to restart VScode between rm CairoMakie and add CairoMakie:

(@v1.8) pkg> rm CairoMakie
# restart VScode here
(@v1.8) pkg> add CairoMakie
julia> using CairoMakie

and the errors disappeared.

Reinstalling CairoMakie takes quite a while, so having to repeat the above procedure occasionally will hurt my productivity significantly. I think the Makie developers need to take this issue seriously.

UPDATE. A similar error occurred again today, and I tried restarting REPL instead of restarting VScode. It didn’t solve the error. I had to restart VScode between rm CairoMakie and add CairoMakie.

Another similar issue, which I think is reproducible. I installed CairoMakie and GLMakie, and I plotted using GLMakie in the VScode terminal on macOS. This opened up a separate plot window. I didn’t know a GLMakie function that closes this window from REPL, I force-quitted the window using macOS’s Force Quit. This closed VScode REPL. When I restarted REPL, both using CairoMakie and using GLMakie generated errors similar to those reported in OP.

I had to rm and add both packages to resolve the issue. Not sure if I restarted VScode or not between rm and add.

I can’t reproduce this issue on my Mac, also with VSCode. Not sure what could be going on there but reinstallation should not be necessary for most problems. If compilation cache files are corrupted for example, one can delete those manually. But even that seems kind of unlikely to me.

I was having the same issue in VSCode with Plots.jl and Julia 1.7.3. I got the following error

julia> VERSION

julia> using Plots
[ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]
WARNING: could not import StaticArraysCore.FieldArray into StructArrays
ERROR: LoadError: UndefVarError: FieldArray not defined
ERROR: LoadError: Failed to precompile StructArrays [09ab397b-f2b6-538f-b94a-2f83cf4a842a] to C:\Users\prana\.julia\compiled\v1.7\StructArrays\jl_1CA4.tmp.
ERROR: LoadError: Failed to precompile GeometryBasics [5c1252a2-5f33-56bf-86c9-59e7332b4326] to C:\Users\prana\.julia\compiled\v1.7\GeometryBasics\jl_15AF.tmp.
ERROR: Failed to precompile Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] to C:\Users\prana\.julia\compiled\v1.7\Plots\jl_13E9.tmp.

However, if I use plots in a Julia REPL outside of VSCode I don’t get this error and everything works fine.
I have the following version of Plots.jl

  [91a5bcdd] Plots v1.31.7

I was able to resolve this using the process mentioned above by @wsshin

(@v1.7) pkg> rm Plots
# close and reopen VSCode
(@v1.7) pkg> add Plots
julia> using Plots

Yes I have seen this warning for a while using VS-code, the insiders extension, julia v1.8 and v1.7.1. It seems to work despite all the warnings, though.

I keep having this issue occasionally. Having to reinstall CairoMakie.jl and restart VScode every time this happened was quite painful, so I tried to find a simpler solution.

And the following is the simplest solution I have found so far (and may indicate the cause of the problem to someone who is more knowledgeable). First of all, I realized that when this error happened I was in the environment of the package I was developing at the moment. In other words, when I have this error during using CairoMakie, if I enter the package manager mode, the prompt is shown as

(PKG_NAME) pkg>

where PKG_NAME is the name of the package I am developing. Now, to resolve the error, go into the home environment by

(PKG_NAME) pkg> activate
  Activating project at `~/.julia/environments/v1.8`

(@v1.8) pkg>

Notice the prompt has changed to show the Julia version. Exit the package manager mode, and import CairoMakie again:

julia> using CairoMakie

This time, the error does not happen. Note that you don’t have to reinstall CairoMakie or restart VScode.

So, the error seems related to the environment issue. Hope that this additional information helps someone more knowledgeable to come up with a solution.

OK, I’m giving up using CairoMakie.jl and GLMakie.jl in VScode. This problem happens at least once a day, and I cannot figure out how to eliminate it. Reinstalling these packages every time the problem happens is too time-consuming.

I don’t have any issue using these two packages in REPL in the standalone terminal program, so I believe the issue is a VScode issue. Hope the VScode developers figure out a solution.

This is very strange, @pfitzseb have you seen anything like this before? I don’t think it has anything to do with Makie packages per se, at least I don’t understand how we would influence StaticArraysCore, and it seems some people observed the problem with Plots as well.

I have not, no. I also don’t think the extension does anything sufficiently bad to cause an error like this. This does feel like some weird environment switching is causing mismatched package versions to be loaded though.

Now I am eager to know whether someone can reproduce this at using Image Julia (jupyterlab/julia/pubtools:latest) + code-server or not (login with GitHub account).
:information_source: I was not able to reproduce it.


  • Debian 11 (bullseye)
  • code-server v4.7.0
    • with Code v1.71.0
  • Julia v1.8.1
  • VS Code Julia extension v1.7.12

See also GitHub - b-data/jupyterlab-julia-docker-stack: Multi-arch (linux/amd64, linux/arm64/v8) docker images. Please submit Pull Requests to the GitLab repository..