The code in src/library/utils/all.R for installed.packages() assumes that :
nchar(URLencode(large path of size PATH_MAX)) + 99 < NAME_MAX
which is not true on any platform.
Specifically, it creates a temporary cache file by URL encoding a directory name and replacing path separating '/' characters to make one long filename, and adding up to 99 other characters ("libloc_" prefix, .instPkgFields, and ".rds")
On my Linux system with NAME_MAX==255 and PATH_MAX==4096, this leaves only 156 characters for a URLencoded path name for every R library path in use, when in fact those URL encoded path names may be over 8000 characters long for a 4096 character path.
This seems limiting even on a desktop, where something like /usr/lib/R would normally fit easily, but it is way too small for large datacenter installations where nodes running R may be scheduled in different VMs with long directory names.
Most long file name issues were addressed with R ~2.10 in the C code, but this one has come up also at my employer.
To reproduce, try something like :
long.dir<- paste("/home", Sys.getenv("USER"), paste(rep("a", 2000), collapse="/"), sep="/")
system(paste("mkdir -p", long.dir))
This should work regardless of how long the directory names from .libPaths() are. A different cache filename should be created. Instead of URLencode a more succinct hash could be used, for example.
Created attachment 1226 [details]
Patch to utils/R/packages.R to support longer libPaths in installed.packages()
Patch against r56973 / r-devel as of 7 Sept 2011
changed in trunk.
But not that the patch supplied did not work on Windows, and the
implemented solution is to hash file names.