[Rd] .libPaths() on Windows may return duplicated paths

From: Henrik Bengtsson <hb_at_biostat.ucsf.edu>
Date: Tue, 15 Mar 2011 20:13:01 -0700


In R v2.12.2 patched (2011-03-13 r54787) and also in R v2.13.0 devel (2011-03-15 r54806), .libPaths() may return the multiple paths referring to the same "normalized" path name. Here is an example from Rterm --vanilla using R v2.12.2 patched:

> paths <- .libPaths(c("C:/", "C:\\"))
> paths

[1] "C:/"
[2] "C:\\"
[3] "C:/PROGRA~1/R/R-2.13.0dev/library"

The reason is that .libPaths() does not detect paths[1] and paths[2] to be "equal";

> .libPaths

function (new)
{

    if (!missing(new)) {

        new <- Sys.glob(path.expand(new))
        paths <- unique(path.expand(c(new, .Library.site, .Library)))
        .lib.loc <<- paths[file.info(paths)$isdir %in% TRUE]
    }
    else .lib.loc
}

One solution would be to replace:

  paths <- unique(path.expand(c(new, .Library.site, .Library)))

with

  paths <- path.expand(c(new, .Library.site, .Library))
  paths <- utils::normalizePath(paths)
  paths <- unique(paths)

This would obviously not work because this would make .libPaths() depend on the utils package as standing. Migrating normalizePath() to the 'base' package would be one solution.

Finally, this causes update.packages() to try to download and install the same package multiple times, e.g.

> .libPaths()

[1] "C:\\Users\\hb/R/win-library/2.12"
[2] "C:/PROGRA~1/R/R-2.12.2patched/library"
[3] "C:\\Users\\hb\\R\\win-library\\2.12"

> update.packages()

digest :
 Version 0.4.1 installed in C:\Users\hb/R/win-library/2.12  Version 0.4.2 available at http://cran.stat.ucla.edu Update (y/N/c)? y
digest :
 Version 0.4.1 installed in C:\Users\hb\R\win-library\2.12  Version 0.4.2 available at http://cran.stat.ucla.edu Update (y/N/c)? y
...

Obviously, I know how to fix/avoid this myself, but I figured it is more generic if .libPaths() does it for everyone.

/Henrik



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 16 Mar 2011 - 03:16:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Mar 2011 - 03:20:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive