Can the preexisting uuid for a package be calculated with Julia 1.4?

It seems that in Julia 1.4 that Pkg.METADATA_compatible_uuid is dropped in favor of just creating a UUID randomly with UUIDs.uuid4().

However, when creating a Project.toml file for a package, we need to know the uuid that has been already created for each of the package dependencies. Since METADATA_compatible_uuid is not available for this in Julia 1.4, is there a way, such as a magic RNG seed, other than searching the Julia directories or github for previous Project.toml files, to still calculate this from the module’s name?

You can use ]add PkgName and it will add entry to the Project.toml. It will just look it up in the local copy of the General registry and pull the UUID from it.

1 Like

Package UUIDs can indeed only be obtained from the packages’ Project.toml or from the registries, which collect such information. But the intention is that the tooling should rarely make it necessary for you to handle UUIDs manually. So the fact that you’re asking this question seems to indicate that you’re missing some tool or use them in an unusual way. What is it you want to achieve?

(Pkg.METADATA_compatible_uuid was only ever intended for transition purposes from the previous generation of the package manager. A fully deterministic mapping from package names to UUIDs would clash with the design goal of making it possible to handle multiple packages with the same name and also make the UUIDs rather pointless in the first place.)

1 Like

Or just trying to upgrade an old package to Project.toml format. I did this just the other day and ran into exactly the same issue. My solution was to do the upgrade in Julia 1.3.

1 Like

Yes, occasionally I have to use an older Github hosted package in Julia 1+. I have been manually adding the Project.toml to my Github hosted fork.

So if the project is already in the General registry, then just copy the UUID from the registry itself (https://github.com/juliaregistries/General). If this is a old project, but one that was never in METADATA or General Registry, just use a new, “random” UUID. The METADATA_compatiple_uuid function was useful only in the transition from the old METADATA, as the name suggests.

1 Like