r-lib / downlit

Syntax Highlighting and Automatic Linking
https://downlit.r-lib.org
Other
90 stars 22 forks source link

CRAN_urls() ignores pkgdown.internet = FALSE *and* overwrites default proxy #184

Open sergiocorreia opened 9 months ago

sergiocorreia commented 9 months ago

Got a very similar error to #177 when trying to build a package website from behind a firewall. Until maybe 3-6 months this worked:

options(pkgdown.internet = FALSE)
pkgdown::build_site()

Now we get an error from downlit which we traced to this (premature?) optimization:

CRAN_urls <- function() {
  # Substantially faster to use RStudio mirror: in my testing this reduced
  # download time from ~2s to 0.6s
  withr::local_envvar(R_CRAN_WEB = "https://cran.rstudio.com")
  tools::CRAN_package_db()
}

This overwrites the R_CRAN_WEB variable (thus disabling our internal proxy) and then fails ungracefully.

Maybe as a compromise, CRAN_urls() should only change R_CRAN_WEB if it has the default values? Or maybe there's a way to completely avoid relying on the web when pkgdown.internet = FALSE is set?

Thanks!