[R-sig-Geo] can't initiate Grass with initGRASS()
William McCoy
wdmccoy at geo.umass.edu
Sat Aug 28 20:09:02 CEST 2010
On 08/28/2010 01:57 PM, Roger Bivand wrote:
> On Sat, 28 Aug 2010, William McCoy wrote:
>
>> On 08/28/2010 01:15 PM, Roger Bivand wrote:
>>> On Sat, 28 Aug 2010, William McCoy wrote:
>>>
>>>> Roger,
>>>>
>>>> I think your suspicions are correct. Here is the output from debug
>>>> after the PATH setting if():
>>>>
>>>> Browse[2]> Sys.getenv("PATH")
>>>>
>>>>
>>>>
>>>> PATH
>>>> "/usr/local/texlive/2009/bin/i386-linux:/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wdmccoy/bin:/usr/local/grass-6.4.0svn/bin:/usr/local/grass-6.4.0svn/scripts"
>>>>
>>>> Browse[2]> list.files(Sys.getenv("PATH"))
>>>> character(0)
>>>> Browse[2]> Sys.getenv("LD_LIBRARY_PATH")
>>>>
>>>>
>>>> LD_LIBRARY_PATH
>>>> "/usr/lib/R/lib:/usr/local/lib:/usr/lib/jvm/jre/lib/i386/server:/usr/lib/jvm/jre/lib/i386:/usr/lib/jvm/java/lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib:/usr/local/grass-6.4.0svn/lib"
>>>>
>>>> Browse[2]> list.files(Sys.getenv("LD_LIBRARY_PATH"))
>>>> character(0)
>>>>
>>>>
>>>> Since I last used spgrass6 many months ago, I have installed
>>>> grass64svn along with grass63, which was long ago installed as a
>>>> fedora rpm. So my PATH looks like this:
>>>>
>>>>
>>>> [wdmccoy at boreas ~]$ echo $PATH
>>>> /usr/local/texlive/2009/bin/i386-linux:/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wdmccoy/bin
>>>>
>>>>
>>>>
>>>>
>>>> But my LD_LIBRARY_PATH looks like this:
>>>>
>>>> [wdmccoy at boreas ~]$ echo $LD_LIBRARY_PATH
>>>>
>>>>
>>>> I.e., there is nothing in LD_LIBRARY_PATH. The reason grass64 works by
>>>> itself (outside of R) is because I have a grass64.conf file in
>>>> /etc/ld.so.conf.d and that .conf file contains:
>>>>
>>>> /usr/local/grass-6.4.0svn/lib
>>>>
>>>>
>>>> What do you recommend?
>>>
>>> This is a bit difficult to say, but trying to set LD_LIBRARY_PATH before
>>> starting R to the correct value:
>>>
>>> export LD_LIBRARY_PATH=/usr/local/grass-6.4.0svn/lib
>>>
>>> and/or ensuring that ldconfig was run, might help.
>>>
>>> Have you tried using gisBase = "/usr/local/grass-6.4.0svn" without the
>>> terminating "/"?
>>>
>>> Hope this goes in the right direction,
>>>
>>> Roger
>>>
>>
>> Yes, I had already tried gisBase = "/usr/local/grass-6.4.0svn" without
>> the terminating "/". In fact, that's what I had used when I did the
>> debugging on initGRASS(). So that doesn't seem to help.
>>
>> I think ldconfig is always run on startup, but I ran it again just now
>> and it made no difference. And setting and exporting LD_LIBRARY_PATH
>> doesn't help either.
>>
>> I should also mention that I had tried to use my grass63 installation
>> for gisBase a couple of times and that gave me the same results.
>>
>> In case I didn't mention it, this is all being done on Fedora 13. The
>> last time that I used spgrass6 successfully was on Fedora 12 on the
>> same computer.
>>
>> Any other ideas?
>
> Trying ldd on GRASS modules when running GRASS outside R to work out
> which shared object library they are using. I run Fedora 13 (among
> others) so I doubt that it is the system, rather some changes in your
> installed software that occurred at around the same time. Using ldd may
> help. When I type:
>
>> ldd /home/rsb/topics/grass/g64_rc6/grass-6.4.0RC6/bin/g.region
>
> I see an extra directory level before the /bin, /lib, etc., both in the
> input and the output, but your mileage may vary.
>
> Roger
>
> PS: Could I suggest moving this thread to statsgrass, which is
> specifically for the R/GRASS interface? Could you summarise there to
> attract attention from GRASS people (who are not too busy with FOSS4G in
> Barcelona)?
>
I will try summarizing this issue in a message to statsgrass this afternoon.
With regard to ldd, I don't see the extra directory level:
[wdmccoy at boreas ~]$ ldd /usr/local/grass-6.4.0svn/bin/g.region
linux-gate.so.1 => (0x0036c000)
libgrass_vect.so =>
/usr/local/grass-6.4.0svn/lib/libgrass_vect.so (0x00110000)
libgrass_dbmibase.so =>
/usr/local/grass-6.4.0svn/lib/libgrass_dbmibase.so (0x00f52000)
...
Thanks, Bill
>>
>>
>> Thanks, Bill
>>
>>
>>>>
>>>>
>>>> Thanks, Bill
>>>>
>>>>
>>>> On 08/28/2010 05:41 AM, Roger Bivand wrote:
>>>>> On Fri, 27 Aug 2010, William McCoy wrote:
>>>>>
>>>>>> I am using spgrass6, but I can't seem to initiate a grass session. I
>>>>>> managed to do this correctly months ago, but can't seem to now. Here
>>>>>> is my code and sessionInfo:
>>>>>
>>>>> Something has happened to your GRASS installation and/or the
>>>>> LD_LIBRARY_PATH environment variable. The GRASS binary modules are
>>>>> being
>>>>> found, but the libraries (shared objects) they call are not. Try to
>>>>> set
>>>>> debug(initGRASS), then step through looking at what is in environment
>>>>> variables, etc. After the if () for conditionally setting the PATH,
>>>>> look
>>>>> at:
>>>>>
>>>>> Sys.getenv("PATH")
>>>>> list.files(Sys.getenv("PATH"))
>>>>>
>>>>> and similarly for LD_LIBRARY_PATH:
>>>>>
>>>>> Sys.getenv("LD_LIBRARY_PATH")
>>>>> list.files(Sys.getenv("LD_LIBRARY_PATH"))
>>>>>
>>>>> I suspect that the test:
>>>>>
>>>>> eLDPATH <- Sys.getenv("LD_LIBRARY_PATH")
>>>>> grep(basename(Sys.getenv("GISBASE")), eLDPATH)
>>>>>
>>>>> is not empty, so the LD_LIBRARY_PATH does not get edited to include
>>>>> the
>>>>> actual locations of the *.so files.
>>>>>
>>>>> Have you changed the definitions of these environment variables in a
>>>>> .bashrc or similar between this working and no longer working? Before
>>>>> starting R, say:
>>>>>
>>>>> echo $PATH
>>>>> echo $LD_LIBRARY_PATH
>>>>>
>>>>> to see if that sheds any light on things.
>>>>>
>>>>> Hope this helps,
>>>>>
>>>>> Roger
>>>>>
>>>>>
>>>>>>
>>>>>>> library(spgrass6)
>>>>>> Loading required package: sp
>>>>>> Loading required package: rgdal
>>>>>> Geospatial Data Abstraction Library extensions to R successfully
>>>>>> loaded
>>>>>> Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23
>>>>>> Path to GDAL shared files: /usr/local/share/gdal
>>>>>> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
>>>>>> Path to PROJ.4 shared files: (autodetected)
>>>>>> Loading required package: XML
>>>>>> GRASS GIS interface loaded with GRASS version: (GRASS not running)
>>>>>>> loc <- initGRASS(gisBase = "/usr/local/grass-6.4.0svn/", home =
>>>>>>> tempdir())
>>>>>> g.gisenv: symbol lookup error: g.gisenv: undefined symbol:
>>>>>> G__no_gisinit
>>>>>> g.gisenv: symbol lookup error: g.gisenv: undefined symbol:
>>>>>> G__no_gisinit
>>>>>> g.gisenv: symbol lookup error: g.gisenv: undefined symbol:
>>>>>> G__no_gisinit
>>>>>> g.gisenv: symbol lookup error: g.gisenv: undefined symbol:
>>>>>> G__no_gisinit
>>>>>> g.gisenv: symbol lookup error: g.gisenv: undefined symbol:
>>>>>> G__no_gisinit
>>>>>> g.region: symbol lookup error: g.region: undefined symbol: G__gisinit
>>>>>> Error in if (file.exists(file) == FALSE) if (!missing(asText) &&
>>>>>> asText == :
>>>>>> argument is of length zero
>>>>>> Error in parseGRASS(cmd) : g.region not parsed
>>>>>>
>>>>>>> sessionInfo()
>>>>>> R version 2.11.1 (2010-05-31)
>>>>>> i386-redhat-linux-gnu
>>>>>>
>>>>>> locale:
>>>>>> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
>>>>>> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
>>>>>> [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
>>>>>> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
>>>>>> [9] LC_ADDRESS=C LC_TELEPHONE=C
>>>>>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>>>>>
>>>>>> attached base packages:
>>>>>> [1] stats graphics grDevices utils datasets methods base
>>>>>>
>>>>>> other attached packages:
>>>>>> [1] spgrass6_0.6-19 XML_3.1-1 rgdal_0.6-28 sp_0.9-66
>>>>>>
>>>>>> loaded via a namespace (and not attached):
>>>>>> [1] grid_2.11.1 lattice_0.18-8 tools_2.11.1
>>>>>>
>>>>>>
>>>>>> Any ideas about what I am doing wrong?
>>>>>>
>>>>>> Thanks, Bill
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>
--
William D. McCoy
Geosciences
University of Massachusetts
Amherst, MA 01003
More information about the R-sig-Geo
mailing list