Opened 5 years ago

Closed 5 years ago

#3688 closed defect (wontfix)

impossible to start grass from Rstudio in Windows

Reported by: veroandreo Owned by: grass-dev@…
Priority: normal Milestone: 7.4.3
Component: Default Version: 7.4.2
Keywords: Cc:
CPU: Unspecified Platform: MSWindows

Description

Currently it is impossible to start GRASS from R in Windows (I tested with GRASS installed from OSGeo4W). It worked perfectly a month ago or so when Roger Bivand fixed some issues. Apparently it is due to an incompatibility in dependencies after GRASS was compiled against new GDAL and PROJ.

Here's the R command (paths must be adapted):

initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass-7.4.2RC2",
          gisDbase = "C:/Users/RETA/Documents/grassdata",
          location = "nc_spm_08_grass7",
          mapset = "user1",
          SG = "elevation")

The pop-up error is a missing iconv.dll. All locales were in Spanish as well as the laptop I tested on. After many attempts to try to close the pop-up error, we got the following in the Rstudio console:

Error in if (!compatible) { : argument is of length zero
In addition: Warning messages:
1: In system(paste("g.dirseps.exe -g", shQuote(Sys.getenv("GISRC"))),  :
  running command 'g.dirseps.exe -g "junk"' had status 309
2: In system(paste("g.dirseps.exe -g", shQuote(gisDbase)), intern = TRUE) :
  running command 'g.dirseps.exe -g "C:/Users/RETA/Documents/grassdata"' had status 309
3: In dir.create(loc_path) :
  cannot create dir 'NA\nc_spm_08_grass7', reason 'No such file or directory'
4: In dir.create(paste(loc_path, "PERMANENT", sep = "/")) :
  cannot create dir 'NA\nc_spm_08_grass7\PERMANENT', reason 'No such file or directory'
5: In dir.create(paste(loc_path, mapset, sep = "/")) :
  cannot create dir 'NA\nc_spm_08_grass7\user1', reason 'No such file or directory'
6: In system(paste("g.version", get("addEXE", envir = .GRASS_CACHE),  :
  running command 'g.version.exe' had status 309

See mailing list http://osgeo-org.1560.x6.nabble.com/error-when-trying-to-start-GRASS-from-Rstudio-in-Windows-td5383381.html for further details.

Attachments (1)

initGRASS_error_windows.png (102.4 KB ) - added by veroandreo 5 years ago.
Error when trying to start GRASS from Rstudio in Windows - message in Spanish as mentioned earlier

Download all attachments as: .zip

Change History (12)

by veroandreo, 5 years ago

Attachment: initGRASS_error_windows.png added

Error when trying to start GRASS from Rstudio in Windows - message in Spanish as mentioned earlier

comment:1 by veroandreo, 5 years ago

The pop-up error says: "The code execution cannot continue because iconv.dll is missing. The problem can be solved re-installing the software".

comment:2 by rsbivand, 5 years ago

Can you grab a screen dump of the pop-up? Can you report OSGeo4W component versions as well as R/rgrass7 versions?

comment:3 by veroandreo, 5 years ago

I do not have the laptop with me now, I can only report back in 10 days or so that I go back home.

In any case, what's a screen dump? I also attached the screenshot with the error above if that's what you mean. I just translated the message because it is in Spanish.

comment:4 by rsbivand, 5 years ago

OK, see it now, sorry. Looks like an OSGeo4W packaging blunder (or path blunder).

in reply to:  2 ; comment:5 by hellik, 5 years ago

Replying to rsbivand:

Can you grab a screen dump of the pop-up? Can you report OSGeo4W component versions as well as R/rgrass7 versions?

System Info                                                                     
GRASS version: 7.4.2                                                            
GRASS SVN revision: r73591                                                      
Build date: 2018-10-23                                                          
Build platform: x86_64-w64-mingw32                                              
GDAL: 2.3.2                                                                     
PROJ.4: 5.2.0                                                                   
GEOS: 3.7.0                                                                     
SQLite: 3.17.0                                                                  
Python: 2.7.14                                                                  
wxPython: 2.8.12.1                                                              
Platform: Windows-10-10.0.17134 (OSGeo4W)   
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Ru

Matrix products: default

locale:
[1] LC_COLLATE=German_Austria.1252  LC_CTYPE=German_Austria.1252   
[3] LC_MONETARY=German_Austria.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Austria.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rgrass7_0.1-10 XML_3.98-1.11  sp_1.3-1      

loaded via a namespace (and not attached):
[1] compiler_3.4.4  grid_3.4.4      lattice_0.20-35

first missing dll is iconv.dll, then other missing dlls pops up.

step by step adding the missing dlls, a list of them

iconv.dll 
proj_5_2.dll 
gdal203.dll 
geos_c.dll 
LIBPQ.dll 
ogdi.dll 
xerces-c_3_2.dll
expat.dll 
jpeg.dll
netcdf.dll
sqlite3.dll
spatialite.dll
[...]

all of them are living in C:\OSGeo4W64\bin

in reply to:  5 ; comment:6 by hellik, 5 years ago

Replying to hellik:

first missing dll is iconv.dll, then other missing dlls pops up.

ok, found it now; started here R/RGUi/RStudio outside of the OSGeo4W-console, then the dll's are missing.

all of them are living in C:\OSGeo4W64\bin

starting R/RGUi/RStudio from the OSGeo4W-console, then it works.

@Veronica, started your students R/RGUi/RStudio outside of the OSGeo4W-console?

maybe wiki/manuals should be updated?

in reply to:  6 ; comment:7 by hellik, 5 years ago

Replying to hellik:

Replying to hellik:

first missing dll is iconv.dll, then other missing dlls pops up.

ok, found it now; started here R/RGUi/RStudio outside of the OSGeo4W-console, then the dll's are missing.

all of them are living in C:\OSGeo4W64\bin

starting R/RGUi/RStudio from the OSGeo4W-console, then it works.

@Veronica, started your students R/RGUi/RStudio outside of the OSGeo4W-console?

maybe wiki/manuals should be updated?

I think we can close the ticket.

comment:8 by rsbivand, 5 years ago

This is correct, I can replicate that RStudio started by clicking on its icon, or by clicking on for example an Rmd file, cannot know where OSGeo4W now keeps its extra dll files. From the latest upgrade of OSGeo4W, you need to start RStudio from the command line in the OSGeo4W console, say using "C:/Program Files/RStudio/bin/rstudio.exe" - with the quotation marks because of the space in the path. The underlying causes are OSGeo4W arguably messing up path variables, and generally rstudio getting between the user and file system reality.

in reply to:  8 comment:9 by hellik, 5 years ago

Replying to rsbivand:

From the latest upgrade of OSGeo4W, you need to start RStudio from the command line in the OSGeo4W console, say using "C:/Program Files/RStudio/bin/rstudio.exe" - with the quotation marks because of the space in the path.

I don't think that starting Rstudio changed with the latest upgrade of OSGeo4W.

It's implemented to start RStudio within the winGRASS-standalone-console as well as in the OSgeo4W-winGRASS-console (within a GRASS session) for many years now:

https://trac.osgeo.org/grass/browser/grass/trunk/mswindows/osgeo4w/env.bat.tmpl#L22

22	REM set RStudio temporarily to %PATH% if it exists
23	
24	IF EXIST "%ProgramFiles%\RStudio\bin\rstudio.exe" set PATH=%PATH%;%ProgramFiles%\RStudio\bin 

but it isn't yet implemented in the OSGeo4W-console itself to start it there outside a GRASS session.

OTOH it's implemented now for a year or so to start R/RGui in the OSGeo4W-console itself outside of a GRASS session by

https://download.osgeo.org/osgeo4w/x86_64/release/grass/grass/setup.hint

sdesc: "GRASS GIS"
ldesc: "Geographic Resources Analysis Support System (GRASS GIS)"
category: Desktop
requires: liblas avce00 gpsbabel gs gdal-python matplotlib msvcrt msvcrt2012 msvcrt2013 msvcrt2015 iconv libtiff gdal proj pdcurses zlib fftw libpng python-wx python-numpy python-pil pyopengl cairo psycopg2 rbatch
maintainer: MartinLanda
curr: 7.4.2-1
prev: 7.4.1-3

via rbatch.

if

comment:10 by veroandreo, 5 years ago

Sorry for the delay, only now I have a windows machine to test... No, my students did not start R nor RStudio from OSGeo4W Shell (I forgot that detail). So, it works, but only if I move to Documents folder, for example. If I try to start GRASS from R in C disk, I get the following:

> library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: (GRASS not running)
> initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass-7.4.2", gisDbase = "C:/Users/RETA/Documents/grassdata", location = "nc_spm_08_grass7", mapset = "user1", SG = "elevation", override=TRUE)
Error in file(file, ifelse(append, "a", "w")) :
  no se puede abrir la conexión
Además: Warning message:
In file(file, ifelse(append, "a", "w")) :
  no fue posible abrir el archivo 'junk': Permission denied

Seems Windows does not grant me permission to write on my own C... how great :( During the course, the students hit this issue many times.

in reply to:  7 comment:11 by veroandreo, 5 years ago

Resolution: wontfix
Status: newclosed

Replying to hellik:

Replying to hellik:

Replying to hellik:

first missing dll is iconv.dll, then other missing dlls pops up.

ok, found it now; started here R/RGUi/RStudio outside of the OSGeo4W-console, then the dll's are missing.

all of them are living in C:\OSGeo4W64\bin

starting R/RGUi/RStudio from the OSGeo4W-console, then it works.

@Veronica, started your students R/RGUi/RStudio outside of the OSGeo4W-console?

maybe wiki/manuals should be updated?

Will add this detail to wiki

I think we can close the ticket.

I´m closing as wontfix since it is indeed impossible to start GRASS from R in Windows unless one opens R from within OSGeo4W shell and move to a folder with writing permission. Feel free to modify or reopen

Note: See TracTickets for help on using tickets.