List of packages in a registry Julia 1.7+

Previously, I could just run TOML.parsefile("General/Registry.toml")["packages"] to get the list of all the packages registered in the General registry.

However, with Julia 1.7, the General directory has been replaced with General.tar.gz and General.toml.
How can I efficiently get the list of packages in the registry with a setup like this? Is there a function that Pkg implements (I’m assuming there is) that can help me out here?

1 Like

Can’t you still do that, after downloading Registry.toml?

Pkg.Types.Context().registries

has all the available registries loaded in-memory. Note: this is an internal functionality, so may break in the future

You could, but my question is in the context of registries that already exist locally.
When you do ] registry add General, with Julia 1.7+ and get the General.toml and General.tar.gz — my question is, how can I extract the list of packages from that (without having to source a Registry.toml elsewhere)? For instance, how does Pkg do it?

This lists the registries I have loaded in memory, but not the packages registered in a particular registry, which is what I’m interested in extracting. :slightly_smiling_face:

The registry contains the packages, by definition of registry :slightly_smiling_face:

Assuming the registry you’re interested in is the first one, Pkg.Types.Context().registries[1].pkgs is the list of packages in that registry

2 Likes

Ah, yes. I was just unsure if there was some other “formal” API that Pkg uses.
Anyways, this is what I was looking for, thanks! :smile:

You can get the same information with Pkg.Registry.reachable_registries()[1].pkgs, which is also relying on Pkg internals.

1 Like