How to use Pkg.dependencies() instead of Pkg.installed()

This code of mine works wonderfully and hopefully solves almost all the issues raised here:

# Make sure all needed Pkg's are ready to go
neededPackages = [:Gtk4, :Cairo] 
using Pkg;
for neededpackage in neededPackages
    (String(neededpackage) in keys(Pkg.project().dependencies)) || Pkg.add(String(neededpackage))
    @eval using $neededpackage
end
3 Likes