[GRASS-dev] changing %HOME% in winGRASS for a better R-winGRASS-integration - discussion

Helmut Kudrnovsky hellik at web.de
Fri Nov 18 08:29:58 PST 2016


Anna Petrášová wrote
> On Fri, Nov 18, 2016 at 9:14 AM, Helmut Kudrnovsky <

> hellik@

> > wrote:
>> hi devs,
>>
>> the subject question oroginates from
>>
>> [GRASS-stats] GRASS can't find R packages from personal library on
>> Windows
>> https://lists.osgeo.org/pipermail/grass-stats/2016-November/001690.html
>>
>> technical background on winGRASS side:
>>
>> %HOME% is defined in winGRASS by:
>>
>> 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'))
>>
>> both definitions turn out to be (on the most newer windows boxes) the
>> same
>> as %USERPROFILE% (e.g C:\Users\yourusername).
>>
>> technical background on R side:
>>
>> if %HOME% is _unset_ on windows, R looks for private libraries in
>> C:\Users\yourusername\Documents\R\win-library\3.3, etc)
>>
>> but if %HOME% is _set_ on windows, R looks for private libraries on the
>> wrong place (C:\Users\yourusername\R\win-library\3.3, etc.) <= see the
>> missing _Documents_ as opposite to above search path for private
>> libraries;
>>
>> thus R can't expand its search path to private libraries, as these are
>> installed by default in
>> C:\Users\yourusername\Documents\R\win-library\3.3,
>> etc.
>>
>> some ways to overcome this R-winGRASS-integration issue:
>>
>> (1) add some notes in the GRASS-wiki to add manually R_LIBS_USER (=path
>> to
>> private library in R) via the windows control panel permanently or
>> temporary
>> in the winGRASS-command console by e.g. set
>> R_LIBS_USER=path/to/your/private/
>>
>> (2) add some notes in the GRASS-wiki how to add R_LIBS_USER in a R
>> session.
>>
>> (3) add some logic in the windows-winGRASS-bat-start up scripts to add
>> R_LIBS_USER
> 
> Can we define R_LIBS_USER in R.bat?
> https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/external/rbatch/R.bat

R_LIBS_USER has to be set explicitely for a defined path to a private
library of a defined version and so on; the question is what to set. 

better is to let R decide where to search for default.


Anna Petrášová wrote
>>
>> (4) add some logic in the (win)GRASS-startup-GUI to define R_LIBS_USER
>>
>> (5) or see [1] to set %HOME% in windows to %USERPROFILE/Documents instead
>> of
>> %USERPROFILE%
>>
>> add following line
>> SET HOME=%USERPROFILE%\Documents
>> below
>> https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/env.bat#L23
>>
>> to catch the most common R private library installations.
>>
>> I couldn't find any hints in the source where %HOME% is used in winGRASS
>> modules/scripts.
> 
> what happens if we don't set it in grass.py? I can't try now.

tested in winGRASS7.0.5 by commenting out following line:

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

in C:\Program Files\GRASS GIS 7.0.5\etc\grass70.py

the wxGUI starts, displaying raster and vector works, tested some modules,
all worked.

but no idea if there may be some more side effect; further no idea if there
is probably more to do for the OSGeo4W-version.

anyone more insight, if %HOME% is needed in winGRASS?



-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/changing-HOME-in-winGRASS-for-a-better-R-winGRASS-integration-discussion-tp5296480p5296507.html
Sent from the Grass - Dev mailing list archive at Nabble.com.


More information about the grass-dev mailing list