[Rd] system2() shortens R.home() to 8.3 form on windows

Dan Tenenbaum dtenenba at fredhutch.org
Wed Jun 24 22:31:01 CEST 2015


Hi,

So in an interactive R session, R.home() returns the following:

> R.home()
[1] "D:/biocbld/bbs-3.2-bioc/R"

However, if I call it from system2(), I get different results:

> system2("R", "-q -e R.home()")
> R.home()
[1] "D:/biocbld/BBS-3~1.2-B/R"

Similarly:

> system2("R", "-q -e Sys.getenv('R_HOME')")
> Sys.getenv('R_HOME')
[1] "D:/biocbld/BBS-3~1.2-B/R"

?R.home says:

"On Windows the values of 'R.home()' and 'R_HOME' are guaranteed
     not to contain spaces, switching to the 8.3 short form of path
     elements if required."

Not sure if this is relevant, but there are no spaces in my path to begin with, so not sure why the conversion to 8.3 form was thought to be required.

It's a problem because we are running R CMD check on a package that generates a tex file which ends up containing a ~ in the path to Sweave.sty, and MikTex ends up interpreting the ~ literally, so the unit test fails. 

If we run the unit tests manually they pass. But in the context of R CMD check they fail, apparently because system2() is invoked at some point.

R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=C
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

Thanks,
Dan



More information about the R-devel mailing list