`lockfile_install()` reinstalls source packages every time when CRAN is cran.r-universe.dev

Aperta
#486 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
r
Ambito
tooling

Direzione di ricerca

Start with installedok_remote_cran(), installedok_remote_standard(), add_metadata(), and pkgplan_update(), then run the minimal reproduction using cran.r-universe.dev and pak::lockfile_install(). Compare the installed metadata with the lockfile entry. Done means a second installation recognizes the source package as kept instead of rebuilding it.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I noticed this on cmdstanr's windows-11-arm GitHub Actions job, where setup-r-dependencies restores a 93 MB library from the cache and then pak::lockfile_install() rebuilds the whole thing from source anyway ("Will install 91 packages", "added 90, dld 90", about 26 minutes). The same workflow on windows-latest says "kept 86, added 3" and is done in 20 seconds. See https://github.com/stan-dev/cmdstanr/actions/runs/37052454400/job/110988918897 setup-r-dependencies step.

I did some digging (Claude assisted) and I think this is because the R build that setup-r installs on Windows ARM sets CRAN to https://cran.r-universe.dev. With pak 0.11.1 every entry in our lockfile is "platform": "source", "repotype": "cran", and installedok_remote_cran() requires

    identical(installed[["repository"]], "CRAN")

But source tarballs from r-universe use Repository: https://cran.r-universe.dev in DESCRIPTION, and add_metadata() writes the Remote* fields but doesn't touch Repository, so nothing pak installed from r-universe can pass the check and pkgplan_update() just reinstalls everything on every run.

I asked Claude to come up with this minimal reproducible example (I see the same thing with pak 0.9.2 and 0.11.1.9000):

    Sys.setenv(PKG_PLATFORMS = "source")
    options(repos = c(CRAN = "https://cran.r-universe.dev"))
    lib <- tempfile(); dir.create(lib)
    pak::lockfile_create("abind", lockfile = "pkg.lock", lib = NULL)
    pak::lockfile_install("pkg.lock", lib = lib)  # added 1
    pak::lockfile_install("pkg.lock", lib = lib)  # added 1 again
    packageDescription("abind", lib.loc = lib)$Repository
    #> "https://cran.r-universe.dev"

If repos is set to c(CRAN = "https://cloud.r-project.org") the second call says "kept 1" and Repository is "CRAN".

Would a solution be for the source branch to also accept a package whose RemoteRepos matches the lockfile entry, the way installedok_remote_standard() does for source packages from other repos? pak writes RemoteRepos at install time, so anything pak installed would pass.

Lingua principale
C
Stelle
135
Fork
47
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di r-lib/pkgdepends

Tutte le issue di r-lib/pkgdepends

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.