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

HTTPUserAgent is set to empty character vector on Debian testing/unstable #196

Open
arcresu opened this issue Jan 9, 2024 · 0 comments
Open

Comments

@arcresu
Copy link

arcresu commented Jan 9, 2024

I am using some of the deb packages built through this repo on Debian unstable. I believe that this is not an officially supported OS, so you might not want to act on this, however the fix looks to be straightforward.

The underlying issue is related to /etc/os-release: in Debian unstable and testing, the VERSION and VERSION_ID variables (which are optional) are removed until close to the next release date.

The result when using the R package on such a system is:

> getOption("HTTPUserAgent")
character(0)

which violates expectations of downstream packages such as renv which assume that HTTPUserAgent is either NULL or a nonempty character vector. (renv is rendered completely unable to install packages, which is how I noticed this issue.)

This is related to the following lines inserted by the build script into Rprofile (as of #34):

r-builds/builder/build.sh

Lines 183 to 195 in 5532edb

## Set the default HTTP user agent
local({
os_identifier <- if (file.exists("/etc/os-release")) {
os <- readLines("/etc/os-release")
id <- gsub('^ID=|"', "", grep("^ID=", os, value = TRUE))
version <- gsub('^VERSION_ID=|"', "", grep("^VERSION_ID=", os, value = TRUE))
sprintf("%s-%s", id, version)
} else {
"${OS_IDENTIFIER}"
}
options(HTTPUserAgent = sprintf("R/%s (%s) R (%s)", getRversion(), os_identifier,
paste(getRversion(), R.version\$platform, R.version\$arch, R.version\$os)))
})

When the VERSION_ID is missing from /etc/os-release, grep("^VERSION_ID=", os, value = TRUE) returns character(0), which then "infects" the rest of this section including HTTPUserAgent:

> os <- readLines("/etc/os-release")
> os
[1] "PRETTY_NAME=\"Debian GNU/Linux trixie/sid\""   
[2] "NAME=\"Debian GNU/Linux\""                     
[3] "VERSION_CODENAME=trixie"                       
[4] "ID=debian"                                     
[5] "HOME_URL=\"https://www.debian.org/\""          
[6] "SUPPORT_URL=\"https://www.debian.org/support\""
[7] "BUG_REPORT_URL=\"https://bugs.debian.org/\""   
> id <- gsub('^ID=|"', "", grep("^ID=", os, value = TRUE))
> id
[1] "debian"
> version <- gsub('^VERSION_ID=|"', "", grep("^VERSION_ID=", os, value = TRUE))
> version
character(0)
> sprintf("%s-%s", id, version) 
character(0)

Proposed fix: in the above lines, if version is equal to character(0), either set it to some dummy value (e.g. "0"), or make sure that HTTPUserAgent is set to NULL in this case.

@arcresu arcresu changed the title HTTPUserAgent is set to empty character vector on future Debian releases HTTPUserAgent is set to empty character vector on Debian testing/unstable Jan 9, 2024
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

1 participant