[Rd] problem running test on a system without /etc/localtime
Martin Maechler
maechler at stat.math.ethz.ch
Wed May 17 11:29:16 CEST 2017
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
>>>>> on Tue, 16 May 2017 20:49:02 -0700 writes:
> On Tue, May 16, 2017 at 5:35 PM, Kirill Maslinsky <kirill at altlinux.org> wrote:
>> Hi all,
>>
>> A problem with tests while building R.
>>
>> I'm packaging R for Sisyphus repository and package build environment,
>> by design, doesn't have /etc/localtime file present. This causes failure
>> with Sys.timeone during test run:
>>
>> [builder at localhost tests]$ ../bin/R --vanilla < reg-tests-1d.R
>>
>>> ## PR#17186 - Sys.timezone() on some Debian-derived platforms
>>> (S.t <- Sys.timezone())
>> Error in normalizePath("/etc/localtime") :
>> (converted from warning) path[1]="/etc/localtime": No such file or
>> directory
>> Calls: Sys.timezone -> normalizePath
>> Execution halted
>>
>> This is caused by this code:
>>
>>> Sys.timezone
>> function (location = TRUE)
>> {
>> tz <- Sys.getenv("TZ", names = FALSE)
>> if (!location || nzchar(tz))
>> return(Sys.getenv("TZ", unset = NA_character_))
>>>> lt <- normalizePath("/etc/localtime")
>> [remainder of the code skkipped]
>>
>> File /etc/loclatime is optional and is not guaranteed to be present on
>> any platform. And anyway, it is a good idea to first check that file
>> exists before calling normalizePath.
> Looking at the code
> (https://github.com/wch/r-source/blob/R-3-4-branch/src/library/base/R/datetime.R#L26),
> could it be that mustWork = FALSE (instead of the default NA) avoids
> the warning causes this check error?
Good idea.
Kirill, could you apply the minimal patch to the sources and
report back ?
> Index: src/library/base/R/datetime.R
> ===================================================================
> --- src/library/base/R/datetime.R (revision 72684)
> +++ src/library/base/R/datetime.R (working copy)
> @@ -23,7 +23,7 @@
> {
> tz <- Sys.getenv("TZ", names = FALSE)
> if(!location || nzchar(tz)) return(Sys.getenv("TZ", unset = NA_character_))
> - lt <- normalizePath("/etc/localtime") # Linux, macOS, ...
> + lt <- normalizePath("/etc/localtime", mustWork = FALSE) # Linux, macOS, ...
> if (grepl(pat <- "^/usr/share/zoneinfo/", lt)) sub(pat, "", lt)
> else if (lt == "/etc/localtime" && file.exists("/etc/timezone") &&
> dir.exists("/usr/share/zoneinfo") &&
> /Henrik
>>
>> Sure, this can be worked around by setting TZ environment variable, but
>> that causes tests to fail in another place:
>>
>> [builder at localhost tests]$ TZ="GMT" ../bin/R --vanilla < reg-tests-1d.R
>>
>>> ## format()ing invalid hand-constructed POSIXlt objects
>>> d <- as.POSIXlt("2016-12-06"); d$zone <- 1
>>> tools::assertError(format(d))
>> Error: Failed to get error in evaluating format(d)
>> Execution halted
>>
>> It seems that the best solution will be to patch Sys.timezone.
>>
>> --
>> KM
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list