# Reading versions of a package from unpacked registry tarball

**URL:** <https://discourse.julialang.org/t/reading-versions-of-a-package-from-unpacked-registry-tarball/76829>\
**Category:** General Usage\
**Tags:** general-registry\
**Created:** [February 21, 2022, 5:00am UTC](https://discourse.julialang.org/t/reading-versions-of-a-package-from-unpacked-registry-tarball/76829 "2022-02-21T05:00:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [February 21, 2022, 5:00am UTC](https://discourse.julialang.org/t/reading-versions-of-a-package-from-unpacked-registry-tarball/76829/1 "2022-02-21T05:00:16Z")

</div>

With the old-style git clone registry, I could find the latest version of a package by reading the `Versions.toml` file in the unpacked registry directory structure:

```julia
function latest_version(pkgname::AbstractString)
    path = joinpath(DEPOT_PATH[1], "registries", "General", first(pkgname,1), pkgname, "Versions.toml")
    return maximum(VersionNumber.(keys(Pkg.TOML.parse(read(path, String)))))
end

```

How would I extract the latest version of a package from a `tarball` registry?  
Is there an existing function for this? Do I need to unpack the registry first or can I read the tarball directly?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [February 21, 2022, 8:45am UTC](https://discourse.julialang.org/t/reading-versions-of-a-package-from-unpacked-registry-tarball/76829/2 "2022-02-21T08:45:54Z")

</div>

If you’re fine with depending on `Pkg` internals, this should do it:

```julia
using Pkg

function latest_version(pkgname::AbstractString)
    registry = only(filter(r -> r.name == "General", Pkg.Registry.reachable_registries()))
    pkg = only(filter(pkg -> pkg.name == pkgname, collect(values(registry.pkgs))))
    return maximum(keys(Pkg.Registry.registry_info(pkg).version_info))
end

```

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [February 21, 2022, 8:54pm UTC](https://discourse.julialang.org/t/reading-versions-of-a-package-from-unpacked-registry-tarball/76829/3 "2022-02-21T20:54:03Z")

</div>

Thanks Gunnar!
