pkgdown
pkgdown copied to clipboard
Prompted to install tidytemplate, but can't do it because it is GitHub only
> pkgdown::build_site()
ℹ The package `tidytemplate` is required.
✖ Would you like to install it?
1: Yes
2: No
Selection: 1
Error: Cannot install packages:
* tidytemplate: Can't find package called tidytemplate.
Type .Last.error.trace to see where the error occurred
Eventually occurs right here https://github.com/r-lib/pkgdown/blob/d1a64f28518dc83905c6dc36ce68eeaaa80d3505/R/utils-fs.R#L86
Goes through as_pkgdown() -> find_template_config() to get there
This is in my _pkgdown.yml, of course:
template:
package: tidytemplate
You can install it using remotes::install_github("tidyverse/tidytemplate"), but do note this on its main web page: "Please don’t use it for your own package."
Depending on your GHA workflow, this could work:
https://github.com/tidyverse/reprex/blob/318363cf7a911010ebb1593765cc21ec207d2d10/DESCRIPTION#L57-L59
@maelle this isn't in a GHA workflow, I was building the site locally
I think my main point is that if part of the point of find_template_config() is to ensure that the package you are using to template with is installed (here tidytemplate), then in an ideal world the prompt to install it wouldn't fail.
Since tidytemplate is a GitHub only package, and that is the primary use case of this feature AFAIK, it may make sense to not use check_installed() here, since it seems like that is going to always fail if you don't have the package installed.
Oh sorry, now I got it, thanks for the report & your patience!
I experienced this error today (I agree it's annoying!) so was reminded of this.
I wonder whether instead of just check_installed() pkgdown should query the info from DESCRIPTION Config/Needs/website in case the template package is listed there, and use that to trigger an installation in interactive sessions.
It looks like it's going to be a decent amount of work to look up the full package remote from the DESCRIPTION, so I think it's best just to throw a different error here, as @DavisVaughan suggested.