JuliaLang / Pkg.jl

Pkg - Package manager for the Julia programming language
https://pkgdocs.julialang.org
Other
613 stars 251 forks source link

Avoid re-cloning registries with `Pkg.Registry.add` #3753

Open omus opened 6 months ago

omus commented 6 months ago

If you use Pkg.Registry.add to add an already existing registry the entire registry will be downloaded first before the conflict is noticed:

$ mkdir -p /tmp/julia-depot
$ export JULIA_DEPOT_PATH=/tmp/julia-depot JULIA_PKG_SERVER=""
$ time julia -e 'using Pkg; Pkg.Registry.add("General")'
     Cloning registry from "https://github.com/JuliaRegistries/General.git"
       Added registry `General` to `/tmp/julia-depot/registries/General`
julia -e 'using Pkg; Pkg.Registry.add("General")'  26.10s user 7.72s system 80% cpu 41.826 total

$ time julia -e 'using Pkg; Pkg.Registry.add("General")'
     Cloning registry from "https://github.com/JuliaRegistries/General.git"
Registry `General` already exists in `/tmp/julia-depot/registries/General`.
julia -e 'using Pkg; Pkg.Registry.add("General")'  26.37s user 11.05s system 86% cpu 43.262 total
omus commented 6 months ago

Mainly this is an issue for CI. Specifically if you were to use julia-actions/cache with registry caching and later use julia-actions/julia-buildpkg the Pkg.Registry.add("General") call in that action can result in wasting time cloning a repository that is already present on disk.