att_amend_desc() should not drop version constraints already set in DESCRIPTION
Nobody has claimed this yet.
- #141 by @VincentGuyader — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start in R/att_to_description.R at att_to_desc_from_is() and inspect how deps_new is merged with the existing DESCRIPTION dependencies. Reproduce the issue with a dependency used only in inst/main.R and a pinned Imports entry. Done means att_amend_desc() no longer silently removes that dependency or its existing version constraint, with tests covering the behavior.
Written by the indexing model from the issue text.
Description
Summary
att_amend_desc() should never drop a version constraint that was already set
by hand in DESCRIPTION. Today, a pinned package can lose its version (or be
removed entirely) when it is no longer detected by the code scan.
Current behaviour
In R/att_to_description.R, att_to_desc_from_is() rebuilds the dependency
list from the packages detected in the scanned code (R/, tests/,
vignettes/), then re-attaches versions with a left join on the previous
DESCRIPTION:
deps_new <- data.frame(type = ..., package = all_packages) %>%
merge(deps_orig[, c("package", "version")],
by = "package", all.x = TRUE, all.y = FALSE)
Consequence: the version is kept only for packages that the scan re-detects.
A package that is pinned in DESCRIPTION but not (or no longer) found by the
scan is not in all_packages, so it is removed from the output entirely, and
its version pin disappears with it, silently.
When it bites
Packages that are real runtime dependencies but live outside the scanned paths,
typically inst/ (which attachment does not scan). A common pattern:
- a deployment entry point
inst/main.RusespkgA (>= 1.2.0)viapkgA::fn(); pkgAis declared inImportswith the pin so it ends up in the built
image / lockfile;- running
att_amend_desc()(e.g. from adev/maintenance script) rewrites
DESCRIPTIONand dropspkgAand its>= 1.2.0, because the scan never saw
it.
More generally, any manually curated version constraint (build/CI-only deps,
packages referenced only by string, packages used only under inst/) is at
risk on the next att_amend_desc() run.
Minimal repro
# DESCRIPTION Imports: somedep (>= 2.0.0), where somedep is used only in inst/main.R
attachment::att_amend_desc()
# -> somedep is removed from Imports; the ">= 2.0.0" pin is lost, no warning
Expected behaviour
att_amend_desc() should not silently discard a version constraint that a
maintainer already set. Options, from least to most invasive:
- Warn when a previously pinned dependency is about to be removed or have
its version dropped, listing the affected packages. - Preserve the version string for any package that keeps an explicit
version in the currentDESCRIPTION, even if the scan did not re-detect it
(i.e. keep the pin rather than resetting to*or dropping the package). - An opt-in argument (e.g.
keep_versions = TRUE/keep_pinned = TRUE) to
guarantee that existing version constraints survive the amend, for teams that
pin on purpose and scan-detection is incomplete.
The key invariant: a hand-set version in DESCRIPTION should survive
att_amend_desc() unless the maintainer explicitly asks to remove it.
Context
Seen on R packages deployed through a shared factory, where the production
entry point is inst/main.R (outside the scan) and version pins on Imports
are load-bearing for the built image.
- Dominant language
- R
- Stars
- 111
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ThinkR-open/attachment
-
att_amend_desc() wipes nearly every dependency when a non-R Depends entry is no longer detectedPossibly taken @VincentGuyader claimed this 54 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ThinkR-open/attachment#146 ·
-
att_amend_desc() drops version constraints when a package appears under two types in DESCRIPTIONMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
ThinkR-open/attachment#140 ·
All issues in ThinkR-open/attachment
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
leppott/BioMonTools#162 ·
-
publications
Difficulty 1/5 Under an hour Newbie friendliness 85/100
epiforecasts/epiforecasts.github.io#161 ·
Maintainers usually reply within 1 day
-
Label `{sas}` chunk source as `sas` instead of `txt`, so it gets syntax highlightingPossibly taken @michaelmayer2 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microbiome/OMA#1031 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ThinkR-open/golem#1265 ·