Programmatically use dependency from alternate registry

I am writing a package MyPkg that has some dependencies from a third party registry. If I try to naively install MyPkg I get hit with an error of the following sort:

(@v1.9) pkg> add https://github.com/myusername/MyPkg.jl.git
     Cloning git-repo `https://github.com/myusername/MyPkg.jl.git`
    Updating git-repo `https://github.com/myusername/MyPkg.jl.git`
    Updating registry at `C:\Users\WDAGUtilityAccount\.julia\registries\General.toml`
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package ThirdPartyDependency [3c0dd727]:
 ThirdPartyDependency [3c0dd727] log:
 ├─ThirdPartyDependency [3c0dd727] has no known versions!
 └─restricted to versions * by MyPkg [04643c7a] — no versions left
   └─MyPkg [04643c7a] log:
     ├─possible versions are: 0.1.0 or uninstalled
     └─MyPkg [04643c7a] is fixed to version 0.1.0

Everything works okay if the third party registry is added (by hand) beforehand, but this is what I am trying to avoid, if possible.

Is there a way to have Pkg.add look for dependencies in third party registries, maybe by adding some directive in Project.toml? I guess I could just add the code that I need from those deps into MyPkg but that doesn’t seem like the correct thing to be doing here.

2 Likes