[R] Errors in R package installation

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Dec 13 15:43:29 CET 2019


On Fri, 13 Dec 2019 14:21:06 +0000
David Stevens <david.stevens using usu.edu> wrote:

> ** byte-compile and prepare package for lazy loading
> Fatal error: cannot open file 'C:\Users\David': No such file or
> directory
> 
> ERROR: lazy loading failed for package 'rmarkdown'

Oh. Sorry, that seems to be yet another place where R is not able to
handle temporary files with spaces in their paths.

What happens is:

1. R CMD INSTALL wants to run tools:::makeLazyLoading(...) in a
   sub-process.
2. An internal function creates a temporary file (using tempfile()),
   writes all the required commands inside it and tries to run Rterm.exe
   -f <path to the temporary file>.
3. That path is also unquoted and it also contains spaces because
   that's what GetShortPathName() returned to R.
4. C:\Users\David
   Stevens\AppData\Local\Temp\Rtmpblablabla/Rinblablablabla becomes two
   separate arguments to Rterm.exe -f.

Solution: use shQuote(Rin) in [*] instead of just Rin. I will try to
report this and the previous problem as a bug.

Workaround: try setting the TMPDIR environment variable to something
without spaces (for example, the same c:/myRLib) before launching R.
(Use Sys.getenv('TMPDIR') and tempdir() to verify that it's
working.) This should help us sidestep any remaining bugs related to
temp paths containing spaces.

-- 
Best regards,
Ivan

[*]
https://github.com/wch/r-source/blob/e554f7f12b22868bdae51aadaeea4d56c9f87a32/src/library/tools/R/check.R#L125



More information about the R-help mailing list