Closed HenrikBengtsson closed 1 year ago
My guess is that this has to with environment variables are not case-sensitive on MS Windows, e.g.
> grep("TEMP", names(Sys.getenv()), value = TRUE, ignore.case = TRUE)
[1] "TEMP"
> Sys.getenv("TEMP")
[1] "C:\\Users\\hb\\AppData\\Local\\Temp"
Now, because it's not case-sensitive, we can get TEMP
also as temp
, or Temp
, or tEmP
, e.g.
> Sys.getenv(c("temp", "Temp", "tEmP"))
temp Temp
"C:\\Users\\hb\\AppData\\Local\\Temp" "C:\\Users\\hb\\AppData\\Local\\Temp"
tEmP
"C:\\Users\\hb\\AppData\\Local\\Temp"
But, I'm not sure how we can have two different environment variables, TEMP
and temp
with different values, as in this report, e.g.
> old_envvars[["TEMP"]]
[1] "C:\\msys64\\tmp"
> old_envvars[["temp"]]
[1] "C:\\Users\\tomas\\AppData\\Local\\Temp"
I first thought it was because one of them is inherited from the host system and the other one is set by MS Windows. But don't know how that can happen, because:
$ temp=foo 2> /dev/null wine "C:\Program Files\R\R-4.1.2\bin\Rscript.exe" --vanilla -e "Sys.getenv()" | grep -E "^(TEMP|temp)"
TEMP C:\users\hb\Temp
With can have two environment variables on MS Windows named temp
and TEMP
when we run R via msys2, e.g.
$ env | grep -iE "^TEMP="
TEMP=/tmp
temp=C:\Users\hb\AppData\Local\Temp
which can be reproduced in a vanilla R session if we do:
$ Rscript --vanilla -e "Sys.getenv()[c('TEMP', 'temp')]"
TEMP C:\rtools42\tmp
temp C:\Users\hb\AppData\Local\Temp
Interestingly, we can only get the value of temp
via Sys.getenv()[["temp"]]
. If we attempt Sys.getenv("temp")
, we get the value of TEMP
, e.g.
if we do:
$ Rscript --vanilla -e "Sys.getenv(c('TEMP', 'temp'))"
TEMP temp
"C:\\rtools42\\tmp" "C:\\rtools42\\tmp"
Fixed and tested on msys2
Tomas Kalibera wrote on 2023-01-09:
... the future package has been failing on my Windows check server. The test failing is:
I've save the
old_envvars
andenvvars
just after they are set up fromSys.getenv()
.old_envvars
had only one empty variable, namedDEBUG
.old_envvars
had variablesTEMP
andTMP
, but these were no longer present inenvvars
, and this is probably why the check fails.See: