Skip to content

Commit 41a0ecb

Browse files
workaround autoprecompilation warning about instantiating with julia_version
1 parent 3b444f5 commit 41a0ecb

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Prefix.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,20 @@ end
604604

605605
# Helper function to install packages also in Julia v1.8
606606
function Pkg_add(args...; kwargs...)
607-
@static if VERSION < v"1.8.0"
608-
Pkg.add(args...; kwargs...)
609-
else
610-
try
611-
Pkg.respect_sysimage_versions(false)
607+
# auto-precompilation calls `instantiate` which creates `julia_version` related warnings (nothing, or mismatch)
608+
# so manually call precompile after adding the packages with `already_instantiated=true` to avoid warnings
609+
withenv("JULIA_PKG_AUTO_PRECOMPILE" => "false") do
610+
@static if VERSION < v"1.8.0"
612611
Pkg.add(args...; kwargs...)
613-
finally
614-
Pkg.respect_sysimage_versions(true)
612+
else
613+
try
614+
Pkg.respect_sysimage_versions(false)
615+
Pkg.add(args...; kwargs...)
616+
finally
617+
Pkg.respect_sysimage_versions(true)
618+
end
615619
end
620+
Pkg.precompile(;already_instantiated=true)
616621
end
617622
end
618623

0 commit comments

Comments
 (0)