GRASS can't find R packages from personal library on Windows

classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|

GRASS can't find R packages from personal library on Windows

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?

Thank you,

Anna
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
On Tue, 15 Nov 2016, Anna Petrášová wrote:

> 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

>
> Thank you,
>
> Anna
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> 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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
Roger Bivand wrote
On Tue, 15 Nov 2016, Anna Petrášová wrote:

> 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.

> 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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
On Wed, 16 Nov 2016, Helmut Kudrnovsky wrote:

> Roger Bivand wrote
>> On Tue, 15 Nov 2016, Anna Petrášová wrote:
>>
>>> 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.
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

>
>> 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
> [hidden email]
> 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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
Roger Bivand wrote
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.
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.

> .libPaths()
[1] "C:/Program Files/R/R-3.3.1/library"
> 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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
Helmut Kudrnovsky wrote
Roger Bivand wrote
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

> .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

> .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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
Helmut Kudrnovsky wrote
now tested by intalling some libraries into my personal library.

outside a winGRASS7.2.svn session

> .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

> .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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
Helmut Kudrnovsky wrote
Helmut Kudrnovsky wrote
now tested by intalling some libraries into my personal library.

outside a winGRASS7.2.svn session

> .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

> .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.

> .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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
In reply to this post by Helmut Kudrnovsky
On Thu, 17 Nov 2016, Helmut Kudrnovsky wrote:

> Helmut Kudrnovsky wrote
>> now tested by intalling some libraries into my personal library.
>>
>> outside a winGRASS7.2.svn session
>>
>>> .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
>>
>>> .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

>
>
>
> -----
> 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
> [hidden email]
> 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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
>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.

outside a winGRASS7.0.5/7.2.svn session, everthing is ok with these variables (see above).
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
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.

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
> [hidden email]
> 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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
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
>>  [hidden email]
>>  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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
Roger Bivand wrote
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.
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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
On Fri, 18 Nov 2016, Helmut Kudrnovsky wrote:

> Roger Bivand wrote
>> 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.
>
> 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.
OK, looks like this:

> Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\rsb\\Documents/R/win-library/3.3"
> .libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.2/library"
> any(match(installed.packages()[,"Package"], "rgrass7"))
[1] TRUE

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

Roger

>
> 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
> [hidden email]
> 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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
Roger Bivand wrote
> 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.

OK, looks like this:

> Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\rsb\\Documents/R/win-library/3.3"
> .libPaths()
[1] "C:/Users/rsb/Documents/R/win-library/3.3"
[2] "C:/Program Files/R/R-3.3.2/library"
> 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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
In reply to this post by Roger Bivand
Roger Bivand wrote
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.
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.

> .libpaths()
Error: could not find function ".libpaths"
> .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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
On Fri, 18 Nov 2016, Helmut Kudrnovsky wrote:

> Roger Bivand wrote
>> 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.
>
> 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.
>
>> .libpaths()
> Error: could not find function ".libpaths"
>> .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

> ?"environment variables"

which on a Windows installation shows "R_USER" in the Windows specific
section at foot, this also loses /Documents within GRASS.

Roger

>
>
> -----
> 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
> [hidden email]
> 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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
In reply to this post by Helmut Kudrnovsky
Helmut Kudrnovsky wrote
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
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Roger Bivand
On Fri, 18 Nov 2016, Helmut Kudrnovsky wrote:

> Helmut Kudrnovsky wrote
>> 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'))
>
>

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

>
>
> -----
> 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
> [hidden email]
> 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: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: GRASS can't find R packages from personal library on Windows

Helmut Kudrnovsky
In reply to this post by Roger Bivand
Roger Bivand wrote
>
> 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

> ?"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.
>>> import os
>>> os.getenv('HOME')
'C:\\Users\\hkmyr'
>>> os.getenv('HOMEPATH')
'\\Users\\hkmyr'
>>> os.getenv('HOMEDRIVE')
'C:'
>>>

and R looks for %HOME%.
best regards
Helmut
12