When specifying UNC paths to .libPaths(), it doesn't handle them correctly.
> .libPaths(c("\\\\server\\dir\\lib", .libPaths()))
As you can see, the path was not added to the search path, however the path exists.
I looked into the source, and I realized that the problem caused by the following line in .libPaths():
new <- Sys.glob(path.expand(new))
...as Sys.glob removes the path entries starting with double-backslash (it might be also true for paths starting with single backslash).
I tried to add a path having forward slashes at the beginning. At first look it seems ok:
> .libPaths(c("//server\\dir\\lib", .libPaths()))
But it changes the slashes (the first two forward-slashes become backslashes, and the backslashes in the path become forward-slashes).
It's due to a line which was introduced recently (in 2.13):
paths <- unique(normalizePath(c(new, .Library.site, .Library), '/'))
Prior 2.13 it was:
paths <- unique(path.expand(c(new, .Library.site, .Library)))
As normalizePath changes the first slashes, it become impossible to add new path entries to .libPaths() while keeping the old entries:
> .libPaths(c("//server\\dir2\\lib", .libPaths()))
Note that the path which was added before ("\\\\server/dir/lib") was removed by Sys.glob.
Currently we use R 2.12 and it works correctly (adding path entries starting with forward slashes), but with R 2.14 it fails.
IMHO there could be two possible solutions:
- fixing Sys.glob to properly handle paths starting with backslash
- fixing .libPaths() by removing the normalizePath call
The bug was in Sys.glob, which I think I have fixed. (It shouldn't remove paths with the double backslash.)
There may also be a bug in file.info or normalizePath, but I don't have the energy to go after those. For the record: after my fix, I can set .libPaths as
and it is fine, but
both fail, because file.info() doesn't think the first is a directory, and normalizePath() changes the second into the first.
The Sys.glob() fix will be committed soon. It only affects Windows systems.