[weakdeps] + [sources] in Project.toml

Is it allowed to have a weak dependency that is not registered and therefore listed under [sources] in Project.toml in Julia 1.12?

When I add a [weakdeps] section to my Project.toml (because I want these packages to only be loaded when an extension is called), then I get a complaint about the parsing the [sources].

(TMI.jl) pkg> st
ERROR: Sources for `GeoPythonPlot` not listed in `deps` or `extras` section at "/home/gebbie/projects/TMI.jl/Project.toml".

Can give more info but likely I am misunderstanding something basic in the docs.

Julia 1.12.2, Linux

Thanks!

You can’t provide sources for a weakdep, because the whole point of a weakdep is that it’s not installed by the current package, but it if it happens to be installed by some other package then you can use it in an extension. However, the error message could be better to make this explicit.

1 Like

Thanks a lot for the feedback. My issue here is that I’d like to run tests on my package extension that is triggered by using an unregistered package. When doing real work, you’re right that the unregistered package will be installed by some other code external to my main package. For running the tests, on the other hand, I think that my main package will need to know how to add the unregistered package. Right now, I’m providing the Manifest.toml to give this information (i.e., url) but it would be great to simply use the Project.toml with a [sources] section.

Put a Project.toml into your test folder that has a hard dep on the external package and use sources there.

Thanks for the tip. Sounds straightforward and a nice way to declare what’s going on.