att_amend_desc() drops version constraints when a package appears under two types in DESCRIPTION
Nessuno ha ancora preso questa issue.
- #141 di @VincentGuyader — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Start in R/att_to_description.R at att_to_desc_from_is(), especially the duplicate-collapse pipeline around lines 367-374. Reproduce the issue with inst/dummypackage and att_amend_desc(), then inspect the resulting dependencies with desc::desc_get_deps(). Done means duplicate package rows resolve Imports over Suggests, preserve any written version constraint using the most restrictive constraint, and produce the same result regardless of row order.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The invariant
A version constraint written in DESCRIPTION must never disappear from an att_amend_desc() run. If a maintainer wrote pkg (>= 1.2.0), that constraint is load-bearing and attachment has no basis to silently reset it to *.
That invariant is violated today whenever a package appears under two types in DESCRIPTION (for example Imports: pkg (>= 1.2.0) and Suggests: pkg). The two rows are collapsed by row position rather than by a rule, so the constraint survives or is silently replaced by * depending on where the rows happen to sit in the frame.
The type conflict has a correct answer too: a package present in both Imports and Suggests should resolve to Imports, the stronger requirement. That is a semantic precedence, not an ordering question. But the version is the part that must not be lost.
Where
R/att_to_description.R, lines 367-374, in att_to_desc_from_is():
deps_new <- data.frame(
type = c(rep("Imports", length(imports)), rep("Suggests", length(suggests))),
package = all_packages, stringsAsFactors = FALSE) %>%
merge(deps_orig[,c("package", "version")],
by = "package", sort = TRUE, all.x = TRUE, all.y = FALSE) %>%
.[,c("type", "package", "version")] %>%
.[order(.$type, .$package), , drop = FALSE] %>%
.[!duplicated(.$package),]
deps_orig may hold several rows for the same package (one per type). The merge() is on package only, so it multiplies the row: one output row per original type, all carrying the type assigned by the scan but different version values. order(.$type, .$package) cannot separate them, since those duplicate rows share the same type and the same package. !duplicated() therefore keeps whichever row merge() happened to emit first.
Evidence: the outcome flips on row position alone
Traced on a copy of inst/dummypackage with glue pinned in Imports, glue also being listed in Suggests:
### deps_orig (glue rows) ###
type package version
2 Imports glue >= 1.2.0
5 Suggests glue *
### scan result ###
imports contains glue: FALSE
suggests contains glue: TRUE
### deps_new (glue rows) ###
type package version
11 Suggests glue *
Result: Imports: glue (>= 1.2.0) becomes Suggests: glue. The pin is gone and no message is emitted, because glue is still present in the output, so it never enters the removed set reported at lines 416-420.
Running the identical merge / order / !duplicated pipeline on a minimal two-row deps_orig keeps >= 1.2.0 instead. Same code, opposite result, decided purely by the position of the rows in the full frame.
Expected behaviour
When collapsing several DESCRIPTION rows for one package:
- Preserve the version constraint through the collapse. A constraint present on any of the collapsed rows must appear on the result. If several rows carry constraints, keep the most restrictive one rather than the first encountered. A constraint is only ever dropped when the maintainer removes it from
DESCRIPTION. - Resolve the type by precedence,
Importswinning overSuggests, rather than by position. - Never let the row order in
deps_origchange the result.
Point 1 is the invariant; points 2 and 3 are how it is achieved. Note that 1 is independent of the type: even if the package legitimately ends up in Suggests, a version written by hand in DESCRIPTION should still be carried over rather than reset to *.
Note on scope
Scan-level precedence already behaves correctly: a package detected in both R/ and tests/ lands in Imports, verified on dummypackage. That path works because order(.$type, ...) sorts "Imports" before "Suggests" alphabetically, so the dedup keeps the right row. It is worth making that precedence explicit rather than relying on the alphabetical accident, since it silently stops working if a type is ever renamed or a third type is introduced.
This is distinct from #139: there is no scan coverage problem here. The package is correctly detected. The defect is entirely in how duplicate DESCRIPTION rows are collapsed, and it reproduces without involving inst/ or any unscanned directory.
Repro
pkg <- <copy of inst/dummypackage>
d <- desc::desc(file = file.path(pkg, "DESCRIPTION"))
d$set_dep("glue", type = "Imports", version = ">= 1.2.0")
d$write()
attachment::att_amend_desc(path = pkg, document = FALSE, use.config = FALSE)
desc::desc_get_deps(file.path(pkg, "DESCRIPTION"))
#> glue is now "Suggests" with version "*"; the ">= 1.2.0" pin is lost, silently
- Lingua principale
- R
- Stelle
- 111
- Fork
- 14
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ThinkR-open/attachment
-
att_amend_desc() wipes nearly every dependency when a non-R Depends entry is no longer detectedForse già presa @VincentGuyader l’ha presa 54 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
ThinkR-open/attachment#146 ·
-
att_amend_desc() should not drop version constraints already set in DESCRIPTIONForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
ThinkR-open/attachment#139 ·
Tutte le issue di ThinkR-open/attachment
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
leppott/BioMonTools#162 ·
-
publications
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
epiforecasts/epiforecasts.github.io#161 ·
I maintainer di solito rispondono entro 1 giorno
-
Label `{sas}` chunk source as `sas` instead of `txt`, so it gets syntax highlightingForse già presa @michaelmayer2 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
microbiome/OMA#1031 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ThinkR-open/golem#1265 ·