Does a package extension need its deps installed directly?

I was trying out writing a package extension to use with Makie. GitHub - jkrumbiegel/MakiePkgExtTest

In my testing, it appeared that the extension did not load when I had only CairoMakie and SomePackage installed in the main environment. The dependency of the extension is Makie, which is also always a dependency of CairoMakie (and GLMakie, etc.). But the users usually don’t install Makie directly. So I wonder if this is on purpose, or if I configured something incorrectly, etc.

Extensions definitely load whenever their weakdep is loaded, even indirectly by some other package. That’s the only sane approach, so that extensions are basically transparent to the user.

You mention the “main environment”, maybe the issue is that your package and Makie are installed in different envs? Never tried this scenario.

You can clone GitHub - jkrumbiegel/MakiePkgExtTest and activate the outer environment. It currently has both CairoMakie and Makie installed. In that mode, I can access the extension. If I rm Makie, I can’t, even though it is still installed via CairoMakie.

That’s what I get (after ~7 minutes of Makie+ installing…), seems like the extension does load:

(@v1.9) pkg> activate --temp

(jl_Eiu18E) pkg> add https://github.com/jkrumbiegel/MakiePkgExtTest/SomePackage CairoMakie

julia> using SomePackage

julia> methods(someplot)
# 0 methods for generic function "someplot" from SomePackage

julia> using CairoMakie

julia> methods(someplot)
# 2 methods for generic function "someplot" from SomePackage:
 [1] someplot()
     @ MakieExtension ~/.julia/packages/MakieCore/6sckc/src/recipes.jl:173
 [2] someplot(args...; attributes...)
     @ MakieExtension ~/.julia/packages/MakieCore/6sckc/src/recipes.jl:33

julia> someplot()
ERROR: Not implemented for someplot. You might want to put:  `using Makie` into your code!
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] not_implemented_for(x::Function)
   @ MakieCore ~/.julia/packages/MakieCore/6sckc/src/recipes.jl:1
 [3] someplot()
   @ MakieExtension ~/.julia/packages/MakieCore/6sckc/src/recipes.jl:173
 [4] top-level scope
   @ REPL[9]:1

The latest error come from Makie itself, so the package extension did call into it.