On Thu, 17 Nov 2016, Roger Bivand wrote:

On Thu, 17 Nov 2016, Helmut Kudrnovsky wrote:

>  My Windows 7, GRASS 7.0.4 shows identical .libPaths() values both inside
>  and out with RGui. I don't know how the location of the personal library
>  folder is recorded - is it in the registry? How might one know? It looks
>  like:
> > Sys.getenv("R_LIBS_USER")
 tested within a winGRASS7.0.5 session:

>  Sys.getenv("R_LIBS_USER")
 [1] "C:\\Users\\test/R/win-library/3.3"
>  .libPaths()
 [1] "C:/Program Files/R/R-3.3.1/library"

 R_LIBS_USER is listed there within the winGRASS session, but the path
 itself
 looks odd.

Unfortunately, I couldn't reproduce this with stand-alone GRASS 7.0.5 or 7.2, Windows 7 Pro, R 3.3.2. I see the same .libPaths() values inside and outside. But see below - I found out how to reproduce the problem predictably.

The reason was (of course) that I'd forgotten that I had set R_LIBS_USER in Control Panel -> System and Security -> System -> Advanced system settings -> Environment Variables. I'd done this as a response to the extra work caused at each annual change of the default address as R's version was incremented. See also:

https://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html

So a workaround might to use the R_LIBS_USER environment variable in that setting, checking that the directory exists. R uses it internally as generated, but doesn't export it. I don't know how this plays cross-platform.

In a context with Windows 7 without setting the R_LIBS_USER environment variable, R outside GRASS reports:

Sys.getenv("HOME")
[1] "C:\\Users\\rsb\\Documents"
.libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.2/library"

but inside GRASS %HOME% is re-defined, so:

Sys.getenv("HOME")
[1] "C:\\Users\\rsb"
.libPaths()
[1] "c:/Program Files/R/R-3.3.2/library"

as R cannot construct: subdirectory ‘R/win-library/x.y’ of the home directory, for R x.y.z, because "C:\\Users\\rsb/R/win-library/x.y" does not exist, and that is where R is looking (here in GRASS):

Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\rsb/R/win-library/3.3"

(the different dirseps do not matter).

Does WinGRASS need to change the HOME environment variable? If it does, users of R in GRASS need to set R_LIBS or R_LIBS_USER, easiest once via Control Panel.

Roger


Best wishes,

Roger


 outside a winGRASS7.0.5/7.2.svn session, everthing is ok with these
 variables (see above).



 -----
 best regards
 Helmut
 --
 View this message in context:
 
http://osgeo-org.1560.x6.nabble.com/GRASS-can-t-find-R-packages-from-personal-library-on-Windows-tp5295771p5296239.html
 Sent from the Grass - Stats mailing list archive at Nabble.com.
 _______________________________________________
 grass-stats mailing list
 grass-stats@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-stats



--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: roger.biv...@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
grass-stats@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-stats

Reply via email to