pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

Prompted to install tidytemplate, but can't do it because it is GitHub only

Open DavisVaughan opened this issue 3 years ago • 5 comments
trafficstars

> 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

DavisVaughan avatar Apr 22 '22 14:04 DavisVaughan

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."

dmurdoch avatar Apr 22 '22 14:04 dmurdoch

Depending on your GHA workflow, this could work:

https://github.com/tidyverse/reprex/blob/318363cf7a911010ebb1593765cc21ec207d2d10/DESCRIPTION#L57-L59

maelle avatar Apr 25 '22 06:04 maelle

@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.

DavisVaughan avatar Apr 25 '22 12:04 DavisVaughan

Oh sorry, now I got it, thanks for the report & your patience!

maelle avatar Apr 25 '22 13:04 maelle

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.

maelle avatar Feb 16 '23 15:02 maelle

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.

hadley avatar Apr 24 '24 13:04 hadley