[R] Errors in R package installation
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Fri Dec 13 09:46:04 CET 2019
On Thu, 12 Dec 2019 15:48:13 +0000
David Stevens <david.stevens using usu.edu> wrote:
> Certain R packages will not install properly on my Windows 10
> computer.
Certain, but not all? Which packages are you able to install on that
computer?
> Warning: invalid package 'C:\Users\David'
> Warning: invalid package
> 'Stevens\AppData\Local\Temp\Rtmpk5NqrI/downloaded_packages/callr_3.4.0.tar.gz'
This looks like a command line argument quoting issue.
I wonder why doesn't install.packages use shQuote to quote the file
name when calling system2(c("R", "CMD", "INSTALL", file)) to install a
downloaded source package:
https://github.com/wch/r-source/blob/e554f7f12b22868bdae51aadaeea4d56c9f87a32/src/library/utils/R/packages2.R#L833
Maybe there should be shQuote(fil) instead, especially since R does
quote the file name when installing from local source tarballs:
https://github.com/wch/r-source/blob/e554f7f12b22868bdae51aadaeea4d56c9f87a32/src/library/utils/R/packages2.R#L676
> This happens on only a subset of packages I install or update.
I have a hypothesis: perhaps this only happens for packages with no
pre-built Windows binary available yet, since "win.binary" packages may
be installed by unpacking a zip file, without calling a command line
with potential space quoting issues:
https://github.com/wch/r-source/blob/e554f7f12b22868bdae51aadaeea4d56c9f87a32/src/library/utils/R/packages2.R#L491
->
https://github.com/wch/r-source/blob/e554f7f12b22868bdae51aadaeea4d56c9f87a32/src/library/utils/R/windows/install.packages.R#L263
Calling install.packages(..., verbose = TRUE) for both a succeeding and
a failing package might help to verify whether this is the case.
> This is a relatively recent issue (i.e. I never saw it before
> November - I've used R for ~15 years).
Just to confirm it: you had no problems on the same Windows 10 computer
with the same user name and %USERPROFILE% path as before? Apparently,
tempdir() used to return a 8.3 directory path on your computer, but now
doesn't - but that should not happen, since R_reInitTempDir()
explicitly asks for a 8.3 path:
https://github.com/wch/r-source/blob/e554f7f12b22868bdae51aadaeea4d56c9f87a32/src/main/sysutils.c#L1810
Microsoft Docs page for GetShortPathName() says:
>> If you call GetShortPathName on a path that doesn't have any short
>> names on-disk, the call will succeed, but will return the long-name
>> path instead. This outcome is also possible with NTFS volumes
>> because there's no guarantee that a short name will exist for a
>> given long name.
Some newer Windows 10 installations may have
NtfsDisable8dot3NameCreation enabled, thus preventing R from getting a
8.3 path to the temp directory.
I am taking the liberty of Cc-ing R-devel because this might warrant
adding a shQuote() call to install.packages().
--
Best regards,
Ivan
More information about the R-help
mailing list