This is quite possibly too naive a thought but:
Could you try activating the Project.toml
for that given project or package (let’s say the name is YourPackage
) and then run the following snippet:
try
using YourPackage
using Pkg
pkg_name = "YourPackage"
m = Pkg.Operations.Context().env.manifest
v_key = findfirst(v->v.name == pkg_name, m)
if isnothing(v_key)
error("Version not found! Is this a valid Julia package?")
else
v = m[v_key].version
println("Package version is $v")
end
catch e
println("$e: Is this a valid Julia package?")
end
This solution was inspired by a stack overflow post here: julia - Determine version of a specific package - Stack Overflow
It does assume a manifest exists for the environment however so that may derail this solution potentially. To my understanding, this would at least solve b), for a) maybe see this discourse post for more: How to test if package is installed - #4 by Tamas_Papp and this one: Test for existence of a variable - #39 by Tamas_Papp for c) I would say that the checks may have to be up to more how you structure or want to administrate your local registry… I would say that could be sufficient personally, but I haven’t run a registry myself yet.