Skip to content

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

@arcresu

Description

@arcresu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions