Skip to content

Commit

Permalink
Merge pull request #360 from r-lib/feature/ignore-missing
Browse files Browse the repository at this point in the history
Add ?ignore-unavailable for ignore missing soft deps
  • Loading branch information
gaborcsardi authored Apr 5, 2024
2 parents c6a7ac7 + 8808a9d commit 14c855c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
the `git-submodules` configuration option is set to `TRUE`. See
`?"pkgdepends-config"` (#354).

* The new `?ignore-unavailable` parameter makes it easy to ignore soft
dependencies that are unavailable
(https://github.com/r-lib/pak/issues/606).

* pkgdepends now automatically ignores soft dependencies that have an
incompatible OS type (`OS_type` entry in `DESCRIPTION`) when installing
packages.
Expand Down
11 changes: 9 additions & 2 deletions R/parse-remotes.R
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,15 @@ add_ref_params <- function(res, params) {
res
}

known_query_params <- c("ignore", "ignore-before-r", "ignore-build-errors",
"nocache", "reinstall", "source")
known_query_params <- c(
"ignore",
"ignore-before-r",
"ignore-build-errors",
"ignore-unavailable",
"nocache",
"reinstall",
"source"
)

parse_query <- function(ref) {
query <- sub("^[^?]*(\\?|$)", "", ref)
Expand Down
10 changes: 10 additions & 0 deletions R/solve.R
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ pkgplan_i_lp_dependencies <- function(lp, config) {
num_candidates <- lp$num_candidates
ruled_out <- lp$ruled_out
base <- base_packages()

ignored <- vlapply(pkgs$params, is_true_param, "ignore")
ignore_rver <- vcapply(pkgs$params, get_param_value, "ignore-before-r")
if (any(!is.na(ignore_rver))) {
Expand All @@ -629,12 +630,21 @@ pkgplan_i_lp_dependencies <- function(lp, config) {
ignored2 <- package_version(ignore_rver) > current
ignored <- ignored | ignored2
}
ignore_unavail <- vlapply(
pkgs$params,
is_true_param,
"ignore-unavailable"
)
failed <- pkgs$status == "FAILED"
ignored <- ignored | (ignore_unavail & failed)

# ignore packages with the wrong OS type
if (config$get("goal") == "install") {
os <- os_type()
bad <- which(!is.na(pkgs$os_type) & pkgs$os_type != os)
if (length(bad) > 0) ignored[bad] <- TRUE
}

soft_deps <- tolower(pkg_dep_types_soft())

## 4. Package dependencies must be satisfied
Expand Down
Binary file modified inst/docs/pkg-refs.rds
Binary file not shown.
4 changes: 4 additions & 0 deletions man/pkg_refs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tools/doc/pkg-refs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ it is already installed.
`Matrix=?ignore-before-r=4.1.2` will ignore the Matrix package on R versions
that are older than 4.1.2. This parameter really only makes sense in the
`packgename=?ignore` form.
- `ignore-unavailable` is a flag. It can only be specified for soft
dependencies. If specified and the package is not available, it will be
ignored. This parameter really only makes sense in the
`packagename=?ignore-unavailable` form.
- `source` is a flag parameter. If specified, then a source R package
is requested from a CRAN-like repository. For package installations
`source` always triggers a re-install. In other words, `source` implies the
Expand Down
4 changes: 4 additions & 0 deletions tools/doc/pkg-refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ ignored on R versions that are older than the specified one. E.g.
\verb{Matrix=?ignore-before-r=4.1.2} will ignore the Matrix package on R versions
that are older than 4.1.2. This parameter really only makes sense in the
\code{packgename=?ignore} form.
\item \code{ignore-unavailable} is a flag. It can only be specified for soft
dependencies. If specified and the package is not available, it will be
ignored. This parameter really only makes sense in the
\code{packagename=?ignore-unavailable} form.
\item \code{source} is a flag parameter. If specified, then a source R package
is requested from a CRAN-like repository. For package installations
\code{source} always triggers a re-install. In other words, \code{source} implies the
Expand Down

0 comments on commit 14c855c

Please sign in to comment.