Skip to content

Commit

Permalink
add fallback check for base / recommended packages (#1948)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Jul 23, 2024
1 parent 5125714 commit c1666ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
17 changes: 17 additions & 0 deletions R/snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,23 @@ renv_snapshot_description_source <- function(dcf) {
if (the$project_synchronized_check_running)
return(list(Source = "unknown"))

# check to see if this is a base / recommended package; if so, assume that
# the package was installed from CRAN at this point
#
# normally these would be caught by the 'Repository' check above, but it
# seems like, in some cases, base / recommended packages might be installed
# without those available
#
# https://github.com/rstudio/renv/issues/1948#issuecomment-2245134768
pkgs <- installed_packages(
lib.loc = c(.Library, .Library.site),
priority = c("base", "recommended"),
field = "Package"
)

if (package %in% pkgs)
return(list(Source = "Repository", Repository = "CRAN"))

# NOTE: this is sort of a hack that allows renv to declare packages which
# appear to be installed from sources, but are actually available on the
# active R package repositories, as though they were retrieved from that
Expand Down
11 changes: 6 additions & 5 deletions inst/resources/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,17 @@ local({

renv_ansify_enhanced <- function(text) {

# R help links
pattern <- "`\\?(renv::(?:[^`])+)`"
replacement <- "`\033]8;;ide:help:\\1\a?\\1\033]8;;\a`"
text <- gsub(pattern, replacement, text, perl = TRUE)

# runnable code
pattern <- "`(renv::(?:[^`])+)`"
replacement <- "`\033]8;;ide:run:\\1\a\\1\033]8;;\a`"
text <- gsub(pattern, replacement, text, perl = TRUE)

# R help links
pattern <- "`(\\?renv::(?:[^`])+)`"
replacement <- "`\033]8;;ide:help:\\1\a\\1\033]8;;\a`"
text <- gsub(pattern, replacement, text, perl = TRUE)

# return ansified text
text

}
Expand Down

0 comments on commit c1666ae

Please sign in to comment.