I’m trying to create a package extension (see 5. Creating Packages · Pkg.jl) for a package I’ve created, triggered by the Plots
package.
I have the following in my package’s Project.toml
file:
[extensions]
Plotting = "Plots"
and a file ext/Plotting.jl
with the following:
module Plotting
using Plots
... functions
end # module
But then if I just try to launch a Julia session in this project, I get an error:
% julia --project=.
ERROR: LoadError: Trigger Plots for extension Plotting not found in project
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] Pkg.API.Precompilation.ExplicitEnv(envpath::String)
@ Pkg.API.Precompilation ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/precompilation.jl:91
[3] Pkg.API.Precompilation.ExplicitEnv()
@ Pkg.API.Precompilation ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/precompilation.jl:33
[4] _precompilepkgs(pkgs::Vector{String}, internal_call::Bool, strict::Bool, warn_loaded::Bool, timing::Bool, _from_loading::Bool, configs::Vector{Pair{Cmd, Base.CacheFlags}}, io::IOContext{IO}, fancyprint::Bool, manifest::Bool)
@ Pkg.API.Precompilation ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/precompilation.jl:352
[5] #precompilepkgs#5
@ ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/precompilation.jl:333 [inlined]
[6] (::Pkg.API.var"#225#226"{Bool, Bool, Bool, Bool, Bool, Vector{Pkg.Types.PackageSpec}})()
@ Pkg.API ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:1090
[7] activate(f::Pkg.API.var"#225#226"{Bool, Bool, Bool, Bool, Bool, Vector{Pkg.Types.PackageSpec}}, new_project::String)
@ Pkg.API ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:1315
[8] precompile(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{io::Base.TTY})
@ Pkg.API ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:1088
[9] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool})
@ Pkg.API ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:159
[10] precompile
@ ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:147 [inlined]
[11] #precompile#114
@ ~/.julia/juliaup/julia-1.10.8+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:146 [inlined]
[12] #invokelatest#2
@ ./essentials.jl:894 [inlined]
[13] invokelatest
@ ./essentials.jl:889 [inlined]
[14] _require(pkg::Base.PkgId, env::String)
@ Base ./loading.jl:2033
[15] __require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:1882
[16] #invoke_in_world#3
@ ./essentials.jl:926 [inlined]
[17] invoke_in_world
@ ./essentials.jl:923 [inlined]
[18] _require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:1873
[19] macro expansion
@ ./loading.jl:1860 [inlined]
[20] macro expansion
@ ./lock.jl:267 [inlined]
[21] __require(into::Module, mod::Symbol)
@ Base ./loading.jl:1823
[22] #invoke_in_world#3
@ ./essentials.jl:926 [inlined]
[23] invoke_in_world
@ ./essentials.jl:923 [inlined]
[24] require(into::Module, mod::Symbol)
@ Base ./loading.jl:1816
in expression starting at /Users/kwilliams/.julia/config/startup.jl:2
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.10.8 (2025-01-22)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
I’m confused by this - I don’t want to add Plots
to this project, because it’s an optional dependency, right? What’s the proper way to deal with this?