Install a package (and its dependencies) at specific date instead of specific version

Is there any way to put Pkg in some sort of “time traveler mode” where I can tell it to install a package (and, more importantly, its dependencies) as if I had issued that command on a given date in the past?

My use case is the unfortunately all-too-familiar situation where I encountered an error with a specific package version in the past, but now I cannot reproduce it anymore because a) I forgot to keep the Manifest.toml around and b) some dependency has been updated since but still fits the [compat] section.

I guess it would be possible to clone the registry from that point in the past and then use it instead of the current registry to do the installations, but I thought maybe there is an easier way out of this.

4 Likes

I don’t think there is, but this would be awesome and we definitely should make it.

5 Likes

FWIW, this is a manual workaround I used and that worked for me:

# Change to temporary directory
mkdir timetravel
cd timetravel

# Clone General registry
git clone https://github.com/JuliaRegistries/General

# Checkout General registry at point in time that you're interested in
# Source: https://stackoverflow.com/a/6990682/1329844
cd General
# Pick date and time as desired
git checkout `git rev-list -n 1 --first-parent --before="2022-03-30 6:54" master`
cd ..

# Add cloned registry as a new registry
# Note: use a temporary depot to not screw up anything in the main depot
JULIA_DEPOT_PATH=$PWD/depot julia -e 'using Pkg; Pkg.Registry.add(RegistrySpec(url="General"))'

Now you can start Julia with the custom depot path JULIA_DEPOT_PATH=$PWD/depot julia and just add packages the way they did back in the days (in this case, on 30th March 2022).

Note that when you install a package, you will get an error that the registry failed to update since it is in a detached state:

(@v1.8) pkg> add Example
    Updating registry at `~/hackathon/main-Trixi.jl/utils/tmp/timetravel/depot/registries/General`
┌ Error: Some registries failed to update:
│     — `~/hackathon/main-Trixi.jl/utils/tmp/timetravel/depot/registries/General` — registry detached
└ @ Pkg.Registry /Users/administrator/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-1.0/build/default-macmini-aarch64-1-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:449
   Resolving package versions...
   Installed Example ─ v0.5.3
    Updating `~/hackathon/main-Trixi.jl/utils/tmp/timetravel/depot/environments/v1.8/Project.toml`
  [7876af07] + Example v0.5.3
    Updating `~/hackathon/main-Trixi.jl/utils/tmp/timetravel/depot/environments/v1.8/Manifest.toml`
  [7876af07] + Example v0.5.3
Precompiling project...
  1 dependency successfully precompiled in 0 seconds

In this case, it is a feature, not a bug, since you do want the registry to remain where it is, i.e., at this previous point in time.

While this provides an immediate solution to my current problem, it would be great if one could have this capability as a feature of Pkg.

2 Likes

The recommendation for reproducibility over time is to store the Manifest.toml. For this specific use case, I think checking it commits in the registry at some date is pretty reasonable.