Discussion:
[GRASS-stats] GRASS can't find R packages from personal library on Windows
Anna Petrášová
2016-11-15 04:12:07 UTC
Permalink
Hi,

I installed latest R on fresh Windows 10, then I installed several
packages into my personal library, then I installed standalone GRASS
GIS 7.3, and when I run R from GRASS session, it does not see the
installed packages. .libPaths() called from GRASS session indeed does
not show the path to the personal library. I installed the packages
again in GRASS session and then it's OK. Any idea why this happens and
how to avoid that?

Thank you,

Anna
Roger Bivand
2016-11-15 09:04:06 UTC
Permalink
Post by Anna Petrášová
Hi,
I installed latest R on fresh Windows 10, then I installed several
packages into my personal library, then I installed standalone GRASS
GIS 7.3, and when I run R from GRASS session, it does not see the
installed packages. .libPaths() called from GRASS session indeed does
not show the path to the personal library. I installed the packages
again in GRASS session and then it's OK. Any idea why this happens and
how to avoid that?
No idea, only you can reproduce what you are doing. Do you mean 7.3, the
development version? Try the 7.0 and 7.2 versions, and compare to see
which environment variables may not be being transferred (R_LIBS probably)
in GRASS 7.3. Are you running R in a Windows terminal (if such
exists in Windows 10) inside GRASS, or in the command line in the
GRASS GUI? If the latter, has this changed?

Roger
Post by Anna Petrášová
Thank you,
Anna
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Helmut Kudrnovsky
2016-11-16 13:31:48 UTC
Permalink
Post by Roger Bivand
Post by Anna Petrášová
Hi,
I installed latest R on fresh Windows 10, then I installed several
packages into my personal library, then I installed standalone GRASS
GIS 7.3, and when I run R from GRASS session, it does not see the
installed packages. .libPaths() called from GRASS session indeed does
not show the path to the personal library. I installed the packages
again in GRASS session and then it's OK. Any idea why this happens and
how to avoid that?
No idea, only you can reproduce what you are doing. Do you mean 7.3, the
development version? Try the 7.0 and 7.2 versions, and compare to see
which environment variables may not be being transferred (R_LIBS probably)
in GRASS 7.3. Are you running R in a Windows terminal (if such
exists in Windows 10) inside GRASS, or in the command line in the
GRASS GUI? If the latter, has this changed?
tested with winGRASS7.2.svn standalone installer

System Info
GRASS version: 7.2.svn
GRASS SVN revision: r69794
Build date: 2016-11-13
Build platform: x86_64-w64-mingw32
GDAL: 2.1.2
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.14.1
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-8-6.2.9200

in the winGRASS-provided windows console:

Cleaning up temporary files...
Starting GRASS GIS...
WARNING: Concurrent mapset locking is not supported on Windows

__________ ___ __________ _______________
/ ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
/ / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
/ /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
\____/_/ |_/_/ |_/____/____/ \____/___//____/

Welcome to GRASS GIS 7.2.svn (r69794)
GRASS GIS homepage: http://grass.osgeo.org
This version running through: Command Shell
(C:\WINDOWS\system32\cmd.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Launching <wxpython> GUI in the background, please wait...
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\test>R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Post by Roger Bivand
q()
Save workspace image? [y/n/c]: n

C:\Users\test>echo %R_LIBS%
%R_LIBS%

I've implemented the R-winGRASS-connecting for the standalone installer by

https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch
https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch/R.bat

%R_LIBS% isn't listed there.




-----
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-tp5295771p5296042.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Roger Bivand
2016-11-16 14:01:53 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
Post by Anna Petrášová
Hi,
I installed latest R on fresh Windows 10, then I installed several
packages into my personal library, then I installed standalone GRASS
GIS 7.3, and when I run R from GRASS session, it does not see the
installed packages. .libPaths() called from GRASS session indeed does
not show the path to the personal library. I installed the packages
again in GRASS session and then it's OK. Any idea why this happens and
how to avoid that?
No idea, only you can reproduce what you are doing. Do you mean 7.3, the
development version? Try the 7.0 and 7.2 versions, and compare to see
which environment variables may not be being transferred (R_LIBS probably)
in GRASS 7.3. Are you running R in a Windows terminal (if such
exists in Windows 10) inside GRASS, or in the command line in the
GRASS GUI? If the latter, has this changed?
tested with winGRASS7.2.svn standalone installer
System Info
GRASS version: 7.2.svn
GRASS SVN revision: r69794
Build date: 2016-11-13
Build platform: x86_64-w64-mingw32
GDAL: 2.1.2
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.14.1
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-8-6.2.9200
Cleaning up temporary files...
Starting GRASS GIS...
WARNING: Concurrent mapset locking is not supported on Windows
__________ ___ __________ _______________
/ ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
/ / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
/ /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
\____/_/ |_/_/ |_/____/____/ \____/___//____/
Welcome to GRASS GIS 7.2.svn (r69794)
GRASS GIS homepage: http://grass.osgeo.org
This version running through: Command Shell
(C:\WINDOWS\system32\cmd.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit
Launching <wxpython> GUI in the background, please wait...
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\test>R
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
You would need to try to load a package from your personal library, so:

.libPaths()
library()
installed.packages()

should show whether anything is found, and to install within the GRASS
session:

install.packages("rgrass7")
library(rgrass7)

and see what happens.

For me on Linux, R_LIBS is set by me and works, but on Windows the default
is (possibly) set in the Registry anyway, which would/should be used if
R_LIBS is not set. Within R, .libPaths() should be the same inside GRASS
and outside GRASS. In Linux I have chosen to set R_LIBS, in Windows 7,
GRASS standalone 7.0.4, I can start R GUI in the GRASS GUI console command
line, and my personal library is found (no R_LIBS set, .libPaths() returns
the default). I haven't tried with GRASS 7.2 on Windows.

Roger
Post by Helmut Kudrnovsky
Post by Roger Bivand
q()
Save workspace image? [y/n/c]: n
C:\Users\test>echo %R_LIBS%
%R_LIBS%
I've implemented the R-winGRASS-connecting for the standalone installer by
https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch
https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch/R.bat
%R_LIBS% isn't listed there.
-----
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-tp5295771p5296042.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Helmut Kudrnovsky
2016-11-16 14:19:56 UTC
Permalink
Post by Anna Petrášová
.libPaths()
library()
installed.packages()
should show whether anything is found, and to install within the GRASS
install.packages("rgrass7")
library(rgrass7)
and see what happens.
For me on Linux, R_LIBS is set by me and works, but on Windows the default
is (possibly) set in the Registry anyway, which would/should be used if
R_LIBS is not set. Within R, .libPaths() should be the same inside GRASS
and outside GRASS. In Linux I have chosen to set R_LIBS, in Windows 7,
GRASS standalone 7.0.4, I can start R GUI in the GRASS GUI console command
line, and my personal library is found (no R_LIBS set, .libPaths() returns
the default). I haven't tried with GRASS 7.2 on Windows.
Cleaning up temporary files...
Starting GRASS GIS...
WARNING: Concurrent mapset locking is not supported on Windows

__________ ___ __________ _______________
/ ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
/ / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
/ /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
\____/_/ |_/_/ |_/____/____/ \____/___//____/

Welcome to GRASS GIS 7.2.svn (r69794)
GRASS GIS homepage: http://grass.osgeo.org
This version running through: Command Shell
(C:\WINDOWS\system32\cmd.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Launching <wxpython> GUI in the background, please wait...
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\test>R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Post by Anna Petrášová
.libPaths()
[1] "C:/Program Files/R/R-3.3.1/library"
Post by Anna Petrášová
library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.2.svn (2016)
and location: nc_spm_08_grass7
.libPaths() works here the same outside an inside a winGRASS session.
everything works.

I've installed all my libraries system wide here, not to any personal folder
like Anna.

so I'll test later by adding some libraries to a personal folder like Anna.



-----
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-tp5295771p5296059.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-17 10:25:51 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
For me on Linux, R_LIBS is set by me and works, but on Windows the default
is (possibly) set in the Registry anyway, which would/should be used if
R_LIBS is not set. Within R, .libPaths() should be the same inside GRASS
and outside GRASS. In Linux I have chosen to set R_LIBS, in Windows 7,
GRASS standalone 7.0.4, I can start R GUI in the GRASS GUI console command
line, and my personal library is found (no R_LIBS set, .libPaths() returns
the default). I haven't tried with GRASS 7.2 on Windows.
.libPaths() works here the same outside an inside a winGRASS session.
everything works.
I've installed all my libraries system wide here, not to any personal
folder like Anna.
so I'll test later by adding some libraries to a personal folder like Anna.
now tested by intalling some libraries into my personal library.

outside a winGRASS7.2.svn session
Post by Helmut Kudrnovsky
.libPaths()
[1] "C:/Users/test/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"
inside a winGRASS7.2.svn session
Post by Helmut Kudrnovsky
.libPaths()
[1] "C:/Program Files/R/R-3.3.1/library"

there is a diffference between inside and outside a winGRASS7.2.svn session



-----
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-tp5295771p5296217.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-17 10:40:31 UTC
Permalink
Post by Helmut Kudrnovsky
now tested by intalling some libraries into my personal library.
outside a winGRASS7.2.svn session
Post by Anna Petrášová
.libPaths()
[1] "C:/Users/test/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"
inside a winGRASS7.2.svn session
Post by Anna Petrášová
.libPaths()
[1] "C:/Program Files/R/R-3.3.1/library"
there is a diffference between inside and outside a winGRASS7.2.svn session
now tested with standalone winGRASS7.0.5; same behaviour; inside a
winGRASS-session the personal library seems not to be found.

any idea?



-----
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-tp5295771p5296219.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-17 10:49:12 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
now tested by intalling some libraries into my personal library.
outside a winGRASS7.2.svn session
Post by Anna Petrášová
.libPaths()
[1] "C:/Users/test/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"
inside a winGRASS7.2.svn session
Post by Anna Petrášová
.libPaths()
[1] "C:/Program Files/R/R-3.3.1/library"
there is a diffference between inside and outside a winGRASS7.2.svn session
now tested with standalone winGRASS7.0.5; same behaviour; inside a
winGRASS-session the personal library seems not to be found.
any idea?
now changing into the locally GRASS source code where R-batch files lives
(D:\software_source\grass_trunk\mswindows\external\rbatch) and start R form
there (same mechanism as implemented in the standalone winGRASS):

D:\software_source\grass_trunk\mswindows\external\rbatch>R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
Tippen Sie 'license()' or 'licence()' für Details dazu.

R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
Tippen Sie 'contributors()' für mehr Information und 'citation()',
um zu erfahren, wie R oder R packages in Publikationen zitiert werden
können.

Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
Tippen Sie 'q()', um R zu verlassen.
Post by Helmut Kudrnovsky
.libPaths()
[1] "C:/Users/test/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"
here R finds both, the standard and the personal library.

so it seems winGRASS seems to hide the path to the personal library.




-----
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-tp5295771p5296225.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Roger Bivand
2016-11-17 11:04:20 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
now tested by intalling some libraries into my personal library.
outside a winGRASS7.2.svn session
Post by Anna Petrášová
.libPaths()
[1] "C:/Users/test/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"
inside a winGRASS7.2.svn session
Post by Anna Petrášová
.libPaths()
[1] "C:/Program Files/R/R-3.3.1/library"
there is a diffference between inside and outside a winGRASS7.2.svn session
now tested with standalone winGRASS7.0.5; same behaviour; inside a
winGRASS-session the personal library seems not to be found.
any idea?
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")

gives a template, so maybe it isn't in the registry? Some documentation
here:

https://cran.r-project.org/bin/windows/base/rw-FAQ.html#I-don_0027t-have-permission-to-write-to-the-R_002d3_002e3_002e2_005clibrary-directory
https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Windows-packages

Users can have one or more libraries, normally specified by the
environment variable R_LIBS_USER. This has a default value (to see it, use
‘Sys.getenv("R_LIBS_USER")’ within an R session), but that is only used if
the corresponding directory actually exists (which by default it will not)

https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Managing-libraries

Best wishes,

Roger
Post by Helmut Kudrnovsky
-----
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-tp5295771p5296219.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Helmut Kudrnovsky
2016-11-17 11:14:17 UTC
Permalink
Post by Roger Bivand
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
Sys.getenv("R_LIBS_USER")
Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\test/R/win-library/3.3"
Post by Roger Bivand
.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.

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.
Roger Bivand
2016-11-17 19:57:21 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
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
Sys.getenv("R_LIBS_USER")
Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\test/R/win-library/3.3"
Post by Roger Bivand
.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.

Best wishes,

Roger
Post by Helmut Kudrnovsky
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
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Roger Bivand
2016-11-18 07:53:47 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
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
Sys.getenv("R_LIBS_USER")
Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\test/R/win-library/3.3"
Post by Roger Bivand
.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.
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
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"
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
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
Post by Helmut Kudrnovsky
outside a winGRASS7.0.5/7.2.svn session, everthing is ok with these
variables (see above).
-----
best regards
Helmut
--
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
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Helmut Kudrnovsky
2016-11-18 08:22:16 UTC
Permalink
Post by Roger Bivand
Post by Roger Bivand
Post by Roger Bivand
My Windows 7, GRASS 7.0.4 shows identical .libPaths() values both
inside
Post by Roger Bivand
and out with RGui. I don't know how the location of the personal
library
Post by Roger Bivand
folder is recorded - is it in the registry? How might one know? It
looks
Post by Roger Bivand
Sys.getenv("R_LIBS_USER")
Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\test/R/win-library/3.3"
Post by Roger Bivand
.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.
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
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"
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
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.
could you download the files from
https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch,
copy these to an arbitrary folder e.g. C:\wd\testfolder, open a windows
console within this folder and type R in the console, then try your test
with Sys.getenv("R_LIBS_USER") and .libPaths()?

for me it works that the general and private library is found by R.

I'll have a look if /where winGRASS changes %HOME%




-----
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-tp5295771p5296409.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Roger Bivand
2016-11-18 09:37:07 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
Post by Roger Bivand
Post by Roger Bivand
My Windows 7, GRASS 7.0.4 shows identical .libPaths() values both
inside
Post by Roger Bivand
and out with RGui. I don't know how the location of the personal
library
Post by Roger Bivand
folder is recorded - is it in the registry? How might one know? It
looks
Post by Roger Bivand
Sys.getenv("R_LIBS_USER")
Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\test/R/win-library/3.3"
Post by Roger Bivand
.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.
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
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"
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
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.
could you download the files from
https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch,
copy these to an arbitrary folder e.g. C:\wd\testfolder, open a windows
console within this folder and type R in the console, then try your test
with Sys.getenv("R_LIBS_USER") and .libPaths()?
for me it works that the general and private library is found by R.
Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\rsb\\Documents/R/win-library/3.3"
Post by Helmut Kudrnovsky
.libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.2/library"
Post by Helmut Kudrnovsky
any(match(installed.packages()[,"Package"], "rgrass7"))
[1] TRUE

But I don't see any recent revisions in that directory?

Roger
Post by Helmut Kudrnovsky
I'll have a look if /where winGRASS changes %HOME%
-----
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-tp5295771p5296409.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Helmut Kudrnovsky
2016-11-18 10:39:40 UTC
Permalink
Post by Roger Bivand
Post by Helmut Kudrnovsky
could you download the files from
https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch,
copy these to an arbitrary folder e.g. C:\wd\testfolder, open a windows
console within this folder and type R in the console, then try your test
with Sys.getenv("R_LIBS_USER") and .libPaths()?
for me it works that the general and private library is found by R.
Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\rsb\\Documents/R/win-library/3.3"
Post by Helmut Kudrnovsky
.libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.2/library"
Post by Helmut Kudrnovsky
any(match(installed.packages()[,"Package"], "rgrass7"))
[1] TRUE
But I don't see any recent revisions in that directory?
it is taken from https://github.com/ggrothendieck/batchfiles by author`s
permission.

so the script works outside a winGRASS session also for you.

but the same script doesn't work inside a winGRASS session. so it's maybe
related to some %HOME% issues as mentioned before.



-----
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-tp5295771p5296444.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-18 11:43:48 UTC
Permalink
Post by Roger Bivand
In a context with Windows 7 without setting the R_LIBS_USER environment
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"
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
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.
I had a look into the sources; I can't find a line of code where winGRASS
changes %HOME% at the moment; but it obvious uses %USERPROFILE% as %HOME%.

and %USERPROFILE% points to in (at least newer) windows versions to

e.g.
echo %USERPROFILE%
C:\Users\hkmyr
C:\Users\\rsb
etc.

in a vanilla windows console, %HOME% isn't defined:

echo %HOME%
%HOME%

within a winGRASS session

echo %HOME%
C:\Users\hkmyr

it points to the folder defined under %USERPROFILE%

add following line

SET HOME=%USERPROFILE%\Documents

below

https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/env.bat#L23

has following effect within a winGRASS session:

Cleaning up temporary files...
Starting GRASS GIS...
WARNING: Concurrent mapset locking is not supported on Windows

__________ ___ __________ _______________
/ ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
/ / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
/ /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
\____/_/ |_/_/ |_/____/____/ \____/___//____/

Welcome to GRASS GIS 7.0.5
GRASS GIS homepage: http://grass.osgeo.org
This version running through: Command Shell
(C:\WINDOWS\system32\cmd.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Launching <wxpython> GUI in the background, please wait...
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\hkmyr>
C:\Users\hkmyr>echo %HOME%
C:\Users\hkmyr\Documents

C:\Users\hkmyr>R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Post by Roger Bivand
.libpaths()
Error: could not find function ".libpaths"
Post by Roger Bivand
.libPaths()
[1] "C:/Users/hkmyr/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"
now also the private library is detected within a winGRASS session.

no idea at the moment if this change in env.bat has a side effect to the
winGRASS installation; further tests are needed.



-----
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-tp5295771p5296449.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Roger Bivand
2016-11-18 12:11:52 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
In a context with Windows 7 without setting the R_LIBS_USER environment
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"
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
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.
I had a look into the sources; I can't find a line of code where winGRASS
changes %HOME% at the moment; but it obvious uses %USERPROFILE% as %HOME%.
and %USERPROFILE% points to in (at least newer) windows versions to
e.g.
echo %USERPROFILE%
C:\Users\hkmyr
C:\Users\\rsb
etc.
echo %HOME%
%HOME%
within a winGRASS session
echo %HOME%
C:\Users\hkmyr
it points to the folder defined under %USERPROFILE%
add following line
SET HOME=%USERPROFILE%\Documents
below
https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/env.bat#L23
Cleaning up temporary files...
Starting GRASS GIS...
WARNING: Concurrent mapset locking is not supported on Windows
__________ ___ __________ _______________
/ ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
/ / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
/ /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
\____/_/ |_/_/ |_/____/____/ \____/___//____/
Welcome to GRASS GIS 7.0.5
GRASS GIS homepage: http://grass.osgeo.org
This version running through: Command Shell
(C:\WINDOWS\system32\cmd.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit
Launching <wxpython> GUI in the background, please wait...
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\hkmyr>
C:\Users\hkmyr>echo %HOME%
C:\Users\hkmyr\Documents
C:\Users\hkmyr>R
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Post by Roger Bivand
.libpaths()
Error: could not find function ".libpaths"
Post by Roger Bivand
.libPaths()
[1] "C:/Users/hkmyr/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"
now also the private library is detected within a winGRASS session.
no idea at the moment if this change in env.bat has a side effect to the
winGRASS installation; further tests are needed.
See also
Post by Helmut Kudrnovsky
?"environment variables"
which on a Windows installation shows "R_USER" in the Windows specific
section at foot, this also loses /Documents within GRASS.

Roger
Post by Helmut Kudrnovsky
-----
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-tp5295771p5296449.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Helmut Kudrnovsky
2016-11-18 12:27:33 UTC
Permalink
Post by Roger Bivand
Post by Helmut Kudrnovsky
no idea at the moment if this change in env.bat has a side effect to the
winGRASS installation; further tests are needed.
See also
Post by Helmut Kudrnovsky
?"environment variables"
which on a Windows installation shows "R_USER" in the Windows specific
section at foot, this also loses /Documents within GRASS.
see my other mail where %HOME% is set by winGRASS-grass7xx.py

so it seems to be some kind of a "design mismatch" where eg. windows (via
%USERPROFILE) and python

C:\>python
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
Post by Roger Bivand
Post by Helmut Kudrnovsky
import os
os.getenv('HOME')
'C:\\Users\\hkmyr'
Post by Roger Bivand
Post by Helmut Kudrnovsky
os.getenv('HOMEPATH')
'\\Users\\hkmyr'
Post by Roger Bivand
Post by Helmut Kudrnovsky
os.getenv('HOMEDRIVE')
'C:'
and R looks for %HOME%.




-----
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-tp5295771p5296461.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Roger Bivand
2016-11-18 12:48:28 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
Post by Helmut Kudrnovsky
no idea at the moment if this change in env.bat has a side effect to the
winGRASS installation; further tests are needed.
See also
Post by Helmut Kudrnovsky
?"environment variables"
which on a Windows installation shows "R_USER" in the Windows specific
section at foot, this also loses /Documents within GRASS.
see my other mail where %HOME% is set by winGRASS-grass7xx.py
so it seems to be some kind of a "design mismatch" where eg. windows (via
%USERPROFILE) and python
C:\>python
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
Post by Roger Bivand
Post by Helmut Kudrnovsky
import os
os.getenv('HOME')
'C:\\Users\\hkmyr'
Post by Roger Bivand
Post by Helmut Kudrnovsky
os.getenv('HOMEPATH')
'\\Users\\hkmyr'
Post by Roger Bivand
Post by Helmut Kudrnovsky
os.getenv('HOMEDRIVE')
'C:'
and R looks for %HOME%.
Right. Both R and Python seem to use %USERPROFILE% which is predictably
present in modern Windows. In winGRASS this is used to set %HOME%, which R
uses instead of %USERPROFILE%. R believes a set %HOME%, leading to the
difficulties.

Could the winGRASS startup set R_LIBS_USER itself, and free it on exit? If
the user had multiple /x.y library directories, the advice would be to set
manually in the control panel, if one, use that?

Roger
Post by Helmut Kudrnovsky
-----
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-tp5295771p5296461.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Helmut Kudrnovsky
2016-11-18 13:11:39 UTC
Permalink
Post by Roger Bivand
Right. Both R and Python seem to use %USERPROFILE% which is predictably
present in modern Windows. In winGRASS this is used to set %HOME%, which R
uses instead of %USERPROFILE%. R believes a set %HOME%, leading to the
difficulties.
a list of available windows variables:

http://ss64.com/nt/syntax-variables.html

USERPROFILE:

%SystemDrive%\Users\{username}
This is equivalent to the $HOME environment variable in Unix/Linux
Post by Roger Bivand
Could the winGRASS startup set R_LIBS_USER itself, and free it on exit? If
the user had multiple /x.y library directories, the advice would be to set
manually in the control panel, if one, use that?
theoretically it would be possible to set R_LIBS_USER during installation; a
new logic has to be added to the nsis installer script.

the other way around may be to set %HOME% in winGRASS as
%USERPROFILE%\Documents.

both changes should be discussed on the dev ML.

before such changes are implemented, the workaround to manage this issue
manually via the control panel should go to the wiki.

Anna, any suggestions?




-----
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-tp5295771p5296469.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-18 14:17:12 UTC
Permalink
Post by Helmut Kudrnovsky
both changes should be discussed on the dev ML.
before such changes are implemented, the workaround to manage this issue
manually via the control panel should go to the wiki.
Anna, any suggestions?
just opened a discussion on the dev ML:

https://lists.osgeo.org/pipermail/grass-dev/2016-November/083122.html




-----
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-tp5295771p5296481.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-23 20:36:50 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
both changes should be discussed on the dev ML.
before such changes are implemented, the workaround to manage this issue
manually via the control panel should go to the wiki.
Anna, any suggestions?
https://lists.osgeo.org/pipermail/grass-dev/2016-November/083122.html
some insights regarding %HOME% in winGRASS:

https://lists.osgeo.org/pipermail/grass-dev/2016-November/083159.html

----------------------------------------------------------------------------------------------
[GRASS-dev] does GRASS need HOME to be defined?
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
anyone more insight, if %HOME% is needed in winGRASS?
https://trac.osgeo.org/grass/changeset/37873
does GRASS need HOME to be defined?
any hints?
It's used G__home() on Unix (and as a fallback on Windows) and it's
used for G_rc_path() on Windows (for some reason, the Unix version
uses getpwuid(), which is probably incorrect in this context).

It may also be used implicitly by library functions or external
programs looking for configuration files.
----------------------------------------------------------------------------------------------

https://lists.osgeo.org/pipermail/grass-stats/2016-November/001708.html
----------------------------------------------------------------------------------------------
OK, so the extension would be to look in %HOME%/Documents to see if there
is %HOME%/Documents/R, and if so do what? If R_LIBS_USER is set, do
nothing, if not, set R_USER, or guess which win-library is the relevant
one and set R_LIBS_USER? Even if this is redundant for non-R users?
----------------------------------------------------------------------------------------------

so it's still to discuss what would be the best option to overcome this
issue.




-----
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-tp5295771p5297179.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-23 21:07:20 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
both changes should be discussed on the dev ML.
before such changes are implemented, the workaround to manage this issue
manually via the control panel should go to the wiki.
Anna, any suggestions?
https://lists.osgeo.org/pipermail/grass-dev/2016-November/083122.html
https://lists.osgeo.org/pipermail/grass-dev/2016-November/083159.html
----------------------------------------------------------------------------------------------
[GRASS-dev] does GRASS need HOME to be defined?
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
anyone more insight, if %HOME% is needed in winGRASS?
https://trac.osgeo.org/grass/changeset/37873
does GRASS need HOME to be defined?
any hints?
It's used G__home() on Unix (and as a fallback on Windows) and it's
used for G_rc_path() on Windows (for some reason, the Unix version
uses getpwuid(), which is probably incorrect in this context).
It may also be used implicitly by library functions or external
programs looking for configuration files.
----------------------------------------------------------------------------------------------
https://lists.osgeo.org/pipermail/grass-stats/2016-November/001708.html
----------------------------------------------------------------------------------------------
OK, so the extension would be to look in %HOME%/Documents to see if there
is %HOME%/Documents/R, and if so do what? If R_LIBS_USER is set, do
nothing, if not, set R_USER, or guess which win-library is the relevant
one and set R_LIBS_USER? Even if this is redundant for non-R users?
----------------------------------------------------------------------------------------------
so it's still to discuss what would be the best option to overcome this
issue.
tested here within a winGRASS session:

D:\software_source\grass_trunk\mswindows\external\rbatch>set
R_USER=C:\Users\hkmyr\Documents

D:\software_source\grass_trunk\mswindows\external\rbatch>R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
Tippen Sie 'license()' or 'licence()' für Details dazu.

R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
Tippen Sie 'contributors()' für mehr Information und 'citation()',
um zu erfahren, wie R oder R packages in Publikationen zitiert werden
können.

Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
Tippen Sie 'q()', um R zu verlassen.
Post by Helmut Kudrnovsky
.libPaths()
[1] "C:/Users/hkmyr/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.1/library"

------------------

if we let %HOME% untouched, the easiest way may be
(similar as we already do it with Rstudio:
IF EXIST "%ProgramFiles%\RStudio\bin\rstudio.exe" set
PATH=%PATH%;%ProgramFiles%\RStudio\bin)

- check if there is C:\Users\yourusername\Documents\R
- if yes, set R_USER=C:\Users\hkmyr\Documents

so the most common cases of private R libraries should be covered.

any comments/objections for this change?



-----
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-tp5295771p5297192.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-11-23 21:56:03 UTC
Permalink
Post by Helmut Kudrnovsky
if we let %HOME% untouched, the easiest way may be
IF EXIST "%ProgramFiles%\RStudio\bin\rstudio.exe" set
PATH=%PATH%;%ProgramFiles%\RStudio\bin)
- check if there is C:\Users\yourusername\Documents\R
- if yes, set R_USER=C:\Users\hkmyr\Documents
so the most common cases of private R libraries should be covered.
any comments/objections for this change?
after some testing on win7, win8, win10, I've committed:
https://lists.osgeo.org/pipermail/grass-commit/2016-November/040769.html

New Revision: 69883

Modified:
grass/trunk/mswindows/env.bat
Log:
set R_USER if %USERPROFILE%\Documents\R\ exists to catch most common cases
of private R libraries in windows

it should catch at least the common cases where personal libraries are
located in %USERPROFILE%\Documents\R\

please test the next standalone winGRASS7.3.svn daily builds
(https://wingrass.fsv.cvut.cz/grass73/x86_64/ or
https://wingrass.fsv.cvut.cz/grass73/x86/).

if it works, it should be backported to the standalone winGRASS7.0.x and the
upcoming winGRASS7.2.



-----
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-tp5295771p5297203.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Markus Neteler
2016-11-24 09:34:45 UTC
Permalink
On Wed, Nov 23, 2016 at 10:56 PM, Helmut Kudrnovsky <***@web.de> wrote:
...
Post by Helmut Kudrnovsky
New Revision: 69883
grass/trunk/mswindows/env.bat
set R_USER if %USERPROFILE%\Documents\R\ exists to catch most common cases
of private R libraries in windows
it should catch at least the common cases where personal libraries are
located in %USERPROFILE%\Documents\R\
please test the next standalone winGRASS7.3.svn daily builds
(https://wingrass.fsv.cvut.cz/grass73/x86_64/ or
https://wingrass.fsv.cvut.cz/grass73/x86/).
The new installer is available now:

https://wingrass.fsv.cvut.cz/grass73/x86_64/WinGRASS-7.3.svn-r69883-73-Setup-x86_64.exe
(or later)
Post by Helmut Kudrnovsky
if it works, it should be backported to the standalone winGRASS7.0.x and the
upcoming winGRASS7.2.
If possible, please timely test. I am holding RC2 for this at time.

thanks
Markus
Roger Bivand
2016-11-24 10:16:14 UTC
Permalink
Post by Markus Neteler
...
Post by Helmut Kudrnovsky
New Revision: 69883
grass/trunk/mswindows/env.bat
set R_USER if %USERPROFILE%\Documents\R\ exists to catch most common cases
of private R libraries in windows
it should catch at least the common cases where personal libraries are
located in %USERPROFILE%\Documents\R\
please test the next standalone winGRASS7.3.svn daily builds
(https://wingrass.fsv.cvut.cz/grass73/x86_64/ or
https://wingrass.fsv.cvut.cz/grass73/x86/).
https://wingrass.fsv.cvut.cz/grass73/x86_64/WinGRASS-7.3.svn-r69883-73-Setup-x86_64.exe
(or later)
Post by Helmut Kudrnovsky
if it works, it should be backported to the standalone winGRASS7.0.x and the
upcoming winGRASS7.2.
If possible, please timely test. I am holding RC2 for this at time.
.libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "c:/Program Files/R/R-3.3.2/library"
Post by Markus Neteler
library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.3.svn (2016)
and location: nc_basic_spm_grass7

With the fix, R for Windows picks up the default personal library
location. This is both with Rgui started in the GRASS Layer Manager
console, and in the Windows GRASS terminal.

Thanks very much!

Roger
Post by Markus Neteler
thanks
Markus
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Markus Neteler
2016-11-24 10:48:08 UTC
Permalink
...
Post by Roger Bivand
Post by Markus Neteler
https://wingrass.fsv.cvut.cz/grass73/x86_64/WinGRASS-7.3.svn-r69883-73-Setup-x86_64.exe
(or later)
...
Post by Roger Bivand
Post by Markus Neteler
.libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "c:/Program Files/R/R-3.3.2/library"
Post by Markus Neteler
library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.3.svn (2016)
and location: nc_basic_spm_grass7
With the fix, R for Windows picks up the default personal library location.
This is both with Rgui started in the GRASS Layer Manager console, and in
the Windows GRASS terminal.
Thanks very much!
Excellent, thanks for the rapid test! Hence I'll backport the fix.

Markus
Anna Petrášová
2016-11-24 14:16:23 UTC
Permalink
Post by Markus Neteler
...
Post by Roger Bivand
Post by Markus Neteler
https://wingrass.fsv.cvut.cz/grass73/x86_64/WinGRASS-7.3.svn-r69883-73-Setup-x86_64.exe
(or later)
...
Post by Roger Bivand
Post by Markus Neteler
.libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "c:/Program Files/R/R-3.3.2/library"
Post by Markus Neteler
library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.3.svn (2016)
and location: nc_basic_spm_grass7
With the fix, R for Windows picks up the default personal library location.
This is both with Rgui started in the GRASS Layer Manager console, and in
the Windows GRASS terminal.
Thanks very much!
Excellent, thanks for the rapid test! Hence I'll backport the fix.
Markus
Works for me as well, thank you for solving this!

Anna
Post by Markus Neteler
_______________________________________________
grass-stats mailing list
http://lists.osgeo.org/mailman/listinfo/grass-stats
Helmut Kudrnovsky
2016-11-24 20:35:49 UTC
Permalink
Post by Markus Neteler
Post by Roger Bivand
With the fix, R for Windows picks up the default personal library location.
This is both with Rgui started in the GRASS Layer Manager console, and in
the Windows GRASS terminal.
Thanks very much!
Excellent, thanks for the rapid test! Hence I'll backport the fix.
thanks for testing and backporting.

locally already working, I hope to find some time soon to implement that the
R-GRASS coupling in OSGEO4W-winGRASS works the same as in standalone
winGRASS.



-----
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-tp5295771p5297335.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Helmut Kudrnovsky
2016-12-12 20:04:44 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Roger Bivand
Post by Roger Bivand
With the fix, R for Windows picks up the default personal library
location.
Post by Roger Bivand
This is both with Rgui started in the GRASS Layer Manager console, and in
the Windows GRASS terminal.
Thanks very much!
Excellent, thanks for the rapid test! Hence I'll backport the fix.
thanks for testing and backporting.
locally already working, I hope to find some time soon to implement that
the R-GRASS coupling in OSGEO4W-winGRASS works the same as in standalone
winGRASS.
found some time now:

R-GRASS coupling in OSGEO4W-winGRASS works the same as in standalone
winGRASS - done by:

r70067 - trunk
r70068 - grass/branches/releasebranch_7_2
r70069 - grass/branches/releasebranch_7_0

testing welcome of one the upcoming OSGeo4W-winGRASS dailys.





-----
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-tp5295771p5299619.html
Sent from the Grass - Stats mailing list archive at Nabble.com.

Helmut Kudrnovsky
2016-11-18 12:16:08 UTC
Permalink
Post by Helmut Kudrnovsky
I had a look into the sources; I can't find a line of code where winGRASS
changes %HOME% at the moment; but it obvious uses %USERPROFILE% as %HOME%.
maybe just found it:

for trunk

https://trac.osgeo.org/grass/browser/grass/trunk/lib/init/grass.py#L712

712 def ensure_home():
713 """Set HOME if not set on MS Windows"""
714 if windows and not os.getenv('HOME'):
715 os.environ['HOME'] = os.path.join(os.getenv('HOMEDRIVE'),
716 os.getenv('HOMEPATH'))

and for the 7.0.x-line

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/lib/init/grass.py#L1338

1338 # set HOME
1339 if windows and not os.getenv('HOME'):
1340 os.environ['HOME'] = os.path.join(os.getenv('HOMEDRIVE'),
1341 os.getenv('HOMEPATH'))




-----
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-tp5295771p5296458.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
Roger Bivand
2016-11-18 12:22:20 UTC
Permalink
Post by Helmut Kudrnovsky
Post by Helmut Kudrnovsky
I had a look into the sources; I can't find a line of code where winGRASS
changes %HOME% at the moment; but it obvious uses %USERPROFILE% as %HOME%.
for trunk
https://trac.osgeo.org/grass/browser/grass/trunk/lib/init/grass.py#L712
713 """Set HOME if not set on MS Windows"""
715 os.environ['HOME'] = os.path.join(os.getenv('HOMEDRIVE'),
716 os.getenv('HOMEPATH'))
and for the 7.0.x-line
https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/lib/init/grass.py#L1338
1338 # set HOME
1340 os.environ['HOME'] = os.path.join(os.getenv('HOMEDRIVE'),
1341 os.getenv('HOMEPATH'))
OK, so the extension would be to look in %HOME%/Documents to see if there
is %HOME%/Documents/R, and if so do what? If R_LIBS_USER is set, do
nothing, if not, set R_USER, or guess which win-library is the relevant
one and set R_LIBS_USER? Even if this is redundant for non-R users?

Roger
Post by Helmut Kudrnovsky
-----
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-tp5295771p5296458.html
Sent from the Grass - Stats mailing list archive at Nabble.com.
_______________________________________________
grass-stats mailing list
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: ***@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
Loading...