How to check if a package is installed from startup.jl?

There are several old posts about this issue but according to me this issue has not been fully addressed.

I would like query if a package is installed, if not, install it and selectively make some additional calls to the package.

Pkg.installed() gives deprecated warnings at the startup, Pkg.status() returns “nothing” which can not be used programmatically.

How can I properly inspect if a package is installed at the startup.jl?

Thank in advance

just do a try block? It is imo a weird deprecation though:
https://github.com/JuliaLang/Pkg.jl/issues/1724

I stumbeled over what seems like a rather propper solution:

julia> using Pkg

julia> haskey(Pkg.dependencies(), Base.identify_package("Revise").uuid)
true

The only caveat is that the docstring of Pkg.dependencies states that “This feature is considered experimental.”, so I am not 100% sure that this is what things will look like forever. But given the stability of Pkg, I am certain that this will work for a long time.