Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renv fails when HTTPUserAgent is improperly set #1787

Closed
arcresu opened this issue Jan 9, 2024 · 1 comment
Closed

renv fails when HTTPUserAgent is improperly set #1787

arcresu opened this issue Jan 9, 2024 · 1 comment

Comments

@arcresu
Copy link

arcresu commented Jan 9, 2024

I encountered this issue when using the rstudio binary builds of R on Debian unstable, which is not an officially supported platform. As such this is a bit niche and might not be worth addressing.

The result is the equivalent of running options(HTTPUserAgent = character(0)) (see rstudio/r-builds#196 for background).

In this case, every attempt to run install() with renv 1.0.3 fails with:

options(HTTPUserAgent = character(0))
renv::install("tidyverse")
#> Error in if (!grepl("renv", agent)) {: argument is of length zero

Created on 2024-01-09 with reprex v2.0.2

This is because of this internal function:

renv/R/http.R

Lines 2 to 5 in de3af61

renv_http_useragent <- function() {
agent <- getOption("renv.http.useragent", default = getOption("HTTPUserAgent"))
agent %||% renv_http_useragent_default()
}

The fix could be to set agent to NULL if it is equal to character(0). However, feel free to close this since it's probably not a likely scenario that others will run into unless they are using the rstudio R binaries on Debian testing or unstable.

@kevinushey
Copy link
Collaborator

In the places where the user agent is used internally, R seems to expect it to be either NULL or a length one character vector, e.g.

https://github.com/wch/r-source/blob/e13caf6d43653e2b3fbc513bbaf6fdd6ee93b455/src/library/utils/R/readhttp.R#L39-L48

We could make renv robust against this, but I think this needs to be changed upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants