App using Makie.jl or Plots.jl compiled with PackageCompiler.jl does not work

Hello,

I have a program that I programmed with Julia using DataFrames, ODBC, TOML any some other packages. I had been compiling it to a Windows App (.EXE-file) by using PackageCompiler.jl many times and everything is OK. I can relocate and execute the app on any of my other Windows 10 x64 PCs and it works stable and fast.

Now I extended my program by a few lines to create a barplot-diagram. It works in REPL, but when I compile it to an app with PackageCompiler.jl, then the resulting .EXE file throws various errors when trying to execute it. The compilation process reports no errors, but the .EXE file does not work.

I tried it with both, Plots.jl and CairoMakie.jl, and in both cases dependencies related error messages occur. Here is one example in case of CairoMakie.jl:

Warning: Error requiring `GPUArraysCore` from `ArrayInterface`
│   exception =
│    LoadError: ArgumentError: Package ArrayInterface does not have Adapt in its dependencies:
│    - You may have a partially installed environment. Try `Pkg.instantiate()`
│      to ensure all packages in the environment are installed.
│    - Or, if you have ArrayInterface checked out for development and have
│      added Adapt as a dependency but haven't updated your primary
│      environment's manifest file, try `Pkg.resolve()`.
│    - Otherwise you may need to report an issue with ArrayInterface
│    Stacktrace:
│      [1] macro expansion
│        @ .\loading.jl:1167 [inlined]
│      [2] macro expansion
│        @ .\lock.jl:223 [inlined]
│      [3] require(into::Module, mod::Symbol)
│        @ Base .\loading.jl:1144
│      [4] top-level scope
│        @ C:\Users\miro\.julia\packages\ArrayInterface\a4Wwt\ext\ArrayInterfaceGPUArraysCoreExt.jl:10
│      [5] include(mod::Module, _path::String)
│        @ Base .\Base.jl:419
│      [6] include(x::String)
│        @ ArrayInterface C:\Users\miro\.julia\packages\ArrayInterface\a4Wwt\src\ArrayInterface.jl:1
...

I tried to solve the problem by adding ArrayInterface.jl and also MKL.jl (because after the error message the package manager tries to download and install this library automatically) in my Project.toml, installing both packages with Pkg.jl and creating a new Manifest.toml and compiling a new .EXE-file with PackageCompiler.jl, but it does not help. The same error message occurs!
Of course, I tried instantiate() and resolve(), but it did not help, too.

When using Plots.jl instead of CairoMakie.jl, similar errors occur, just other library dependecies are reported. I also tried to update my Project.toml, creating a new Manifest.toml and compiling a new .EXE-file with PackageCompiler.jl, but it does not help.

I even do not understand why the error messages mentions the folder C:\Users\miro.julia\packages\ because my project environment is located in another, separate project folder with separate Project.toml and Manifest.toml and, as I mentioned at the beginning of my post, the .EXE-App works if not using Plots.jl and Makie.jl. I can even copy the resulting folder containing the compiled systemimage and the .EXE file to another computer where Julia is not installed and the .EXE-App works without any problems!

What is the problem?
Are CairoMakie.jl and Plots.jl not compatible with PackageCompiler.jl?

My system:

  • Windows 10 x64
  • Julia Version 1.8.5
  • CairoMakie v0.10.10
  • PackageCompiler v2.1.9
  • Plots v1.39.0

Thanks for any advices in advance!

Kind regards,
Miroslav Stimac

What does your PackageCompiler.jl build script look like?

I do this:

using PackageCompiler
cd("C:\\MyJuliaProjects\\MyProjectX")
create_app("MyProjectX", "MyProjectXCompiled"; precompile_execution_file = "MyProjectX/precompile_app.jl")

In precompile_app.jl I have this content:

using MyProjectX

MyProjectX.julia_main()

As I mentioned, everything is OK if I do not use Plots.jl or CairoMakie.jl in my program.

Well, Plots.jl is known not to work with PackageCompiler, but Makie.jl should…

If it doesn’t, file a bug report…

The ugly thing is that it is hard to say if this would be a bug in PackageCompiler or in Makie.jl …

Why should CairoMakie.jl be compatible with PackageCompiler.jl?
Had you done in it in past?

Well, GLMakie works with PackageCompiler… Not sure about CairoMakie…

I tried GLMakie with a barplot and I get similar error messages as when using CairoMakie.

# Header
module MyProgram

	using GLMakie
	using DataFrames

...

	# Code in my Julia-function for PackageCompiler.jl:
	GLMakie.activate!()
	fig = Figure(resolution = (700, 300))

	fig[1,1] = ax = Axis(fig, xlabel = "My x-label", ylabel = "My y-label",
                         xlabelsize = 12, ylabelsize = 12)

	cm = cgrad([:aliceblue, :blue])

	# Maximum size of vector color_range has to be 64
	# because vertices of color-map created with cgrad() have a size of 64.
	color_range = 0:min(maximum(df.x), 63)

	barplot!(df.x, df.y, colormap = cm,
	         color = color_range)

	# Reverse the scale of the horizonzal axis.
	ax.xreversed = true

	if isfile(TMP_PATH * "TestImage.png")
		rm(TMP_PATH * "TestImage.png"; force = true)
	end
	save(TMP_PATH * "TestImage.png", fig)

end

The compilation process completes without error messages, but when starting the compiled .EXE app then there are various errors regarding dependencies.
What OS are you using?
I am using Windows 10 64 Bits.

Which command or script are you using to run package compiler?

You created the project in Julia using generate, right? Additionally, it’s necessary to have the julia_main function in the main file.

Is there a way to resolve the conflict between plots and PackageCompiler?