carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
41 stars 25 forks source link

Describe/develop process for using github packages #221

Open zkamvar opened 2 years ago

zkamvar commented 2 years ago

Right now, it's not clear how to auto-detect GitHub-only packages in {renv} outside of a DESCRIPTION file. I would like to not add a description file to the mix because that will add more confusion for lesson authors.

Right now, if there is a lesson with the https://github.com/weecology/ratdat package being used, it will give the following error:

sandpaper::build_lesson()
ℹ No schedule set, using Rmd files in episodes/ directory.
→ To remove this message, define your schedule in config.yaml or use `set_episodes()` to generate it.
ℹ Consent to use package cache provided
→ Searching for and installing available dependencies
Done!ng R package dependencies ... 
→ Restoring any dependency versions
* The library is already synchronized with the lockfile.
→ Recording changes in lockfile
The following package(s) were installed from an unknown source:
         _
  ratdat   [0.1.0]

renv may be unable to restore these packages in the future.
Consider reinstalling these packages from a known source (e.g. CRAN).

Error: callr subprocess failed: aborting snapshot due to pre-flight validation failure
Type .Last.error.trace to see where the error occurred
|> .Last.error.trace

 Stack trace:

 Process 15025:
 1. sandpaper::build_lesson()
 2. sandpaper:::build_markdown(path = path, rebuild = rebuild, quiet = quiet,  ...
 3. sandpaper:::renv_check_consent(path, quiet, sources)
 4. sandpaper:::manage_deps(path, snapshot = TRUE, quiet = quiet)
 5. callr::r(func = callr_manage_deps, args = args, show = !quiet,  ...
 6. callr:::get_result(output = out, options)
 7. throw(newerr, parent = remerr[[2]])

 x callr subprocess failed: aborting snapshot due to pre-flight validation failure 

 Process 15092:
 19. (function (path, repos, snapshot, lockfile_exists)  ...
 20. renv::snapshot(project = path, lockfile = renv_lock, prompt = FALSE)
 21. base:::stop("aborting snapshot due to pre-flight validation failure")
 22. base:::.handleSimpleError(function (e)  ...
 23. h(simpleError(msg, call))

 x aborting snapshot due to pre-flight validation failure

The solution is to use sandpaper::pin_version("weecology/ratdat"), but there should be a better way to include this.

zkamvar commented 10 months ago

There is currently another wrinkle to this saga:

If a GitHub package does not exist on a system, then it cannot be provisioned by {sandpaper} (see https://github.com/carpentries/actions/issues/32#issuecomment-1777883411)

This is because when we search for packages that need to be hydrated, we use renv::dependencies(), which just reports package names, not provenance:

https://github.com/carpentries/sandpaper/blob/fbf1fa2f2e55ef8fb3fee05e13fce7db60ab1065/R/utils-renv.R#L245-L252

The solution would be to exclude packages that already exist in the lockfile for hydration.