Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the initialisation of a grass session in R #88

Open
amelinevallet opened this issue Jun 7, 2024 · 19 comments
Open

Problem with the initialisation of a grass session in R #88

amelinevallet opened this issue Jun 7, 2024 · 19 comments

Comments

@amelinevallet
Copy link

Dear all,
Since I updated GRASS (8.2 -> 8.3.2) and rgrass (?-> 0.4-2), the installation seems broken and I can't start a GRASS session from R anymore. The error message I receive is the following:

Error in read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html,  : 
  Premature end of data in tag guisection line 1 [77]
De plus : Message d'avis :
Dans readLines(outFile) :
  ligne finale incomplète trouvée dans '/tmp/Rtmp9qeL4f/file36b3e2cdcc8ad'
Erreur dans parseGRASS(cmd, legacyExec = legacyExec) : g.region not parsed

Here below an example which I hope is reproducible:

Sys.setenv("GRASS_INSTALLATION"="/usr/lib/grass83")
library(rgrass)
library(unixtools)
set.tempdir("/my_path/temporary_files")

GRASS_INSTALLATION <- Sys.getenv("GRASS_INSTALLATION")
loc <- initGRASS(gisBase=GRASS_INSTALLATION, home=tempdir(), SG=r, override=TRUE, remove_GISRC = TRUE) #return error message
loc2 <- initGRASS() #return error message

I receive the same error message whether I use a custom path for temp files or not, and when I manually indicate within the initGRASS function custom entry parameters.

We are using GRASS 8.3.2 and R version 4.4.0 in a linux environment (Ubuntu 22.04.4 LTS). GRASS works well (I can use all applications from a GRASS session started in the terminal).

print(version)
                      
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          4.0                         
year           2024                        
month          04                          
day            24                          
svn rev        86474                       
language       R                           
version.string R version 4.4.0 (2024-04-24)
nickname       Puppy Cup 

The environment variables seem all correct:

_R_CHECK_COMPILATION_FLAGS_KNOWN_
                                 -Wformat -Werror=format-security -Wdate-time
BROWSER                          /usr/lib/rstudio-server/bin/postback/rpostback-browser
CLICOLOR_FORCE                   1
DISPLAY                          :0
EDITOR                           vi
GIS_LOCK                         817
GISBASE                          /usr/lib/grass83
GISDBASE                         /home/avallet/grassdata
GISRC                            /home/avallet/.grassrc8
GIT_ASKPASS                      rpostback-askpass
GRASS_ADDON_BASE                 /home/avallet/.grass8/addons
GRASS_INSTALLATION               /usr/lib/grass83
GRASS_MESSAGE_FORMAT             text
GRASS_PAGER                      cat
GRASS_PYTHON                     python3
HOME                             /home/avallet
LANG                             fr_FR.UTF-8
LD_LIBRARY_PATH                  /usr/lib/grass83/lib::/usr/lib/R/lib:/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/default-java/lib/server
LN_S                             ln -s
LOCATION_NAME                    file36b3e68712934
LOGNAME                          avallet
MAKE                             make
MAPSET                           file36b3e656a1ed9
MPLENGINE                        tkAgg
PAGER                            /usr/bin/pager
PATH                             /usr/lib/grass83/bin:/usr/lib/grass83/scripts:/home/avallet/.grass8/addons/bin:/home/avallet/.grass8/addons/scripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/lib/rstudio-server/bin/quarto/bin:/usr/lib/rstudio-server/bin/postback
PYTHONPATH                       /usr/lib/grass83/etc/python
R_BROWSER                        xdg-open
R_BZIPCMD                        /bin/bzip2
R_CLI_HAS_HYPERLINK_IDE_HELP     true
R_CLI_HAS_HYPERLINK_IDE_RUN      true
R_CLI_HAS_HYPERLINK_IDE_VIGNETTE
                                 true
R_DOC_DIR                        /usr/share/R/doc
R_GZIPCMD                        /bin/gzip -n
R_HOME                           /usr/lib/R
R_INCLUDE_DIR                    /usr/share/R/include
R_LIBS_SITE                      /usr/local/lib/R/site-library/:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
R_LIBS_USER                      /home/avallet/R/x86_64-pc-linux-gnu-library/4.4
R_PAPERSIZE                      letter
R_PAPERSIZE_USER                 letter
R_PDFVIEWER                      /usr/bin/xdg-open
R_PLATFORM                       x86_64-pc-linux-gnu
R_PRINTCMD                       /usr/bin/lpr
R_RD4PDF                         times,inconsolata,hyper
R_SESSION_TMPDIR                 /tmp/Rtmp9qeL4f
R_SHARE_DIR                      /usr/share/R/share
R_STRIP_SHARED_LIB               strip --strip-unneeded
R_STRIP_STATIC_LIB               strip --strip-debug
R_TEXI2DVICMD                    /usr/bin/texi2dvi
R_UNZIPCMD                       /usr/bin/unzip
R_ZIPCMD                         /usr/bin/zip
RMARKDOWN_MATHJAX_PATH           /usr/lib/rstudio-server/resources/mathjax-27
RS_PORT_TOKEN                    1be40ec3f539
RS_RPOSTBACK_PATH                /usr/lib/rstudio-server/bin/rpostback
RS_SERVER_RPC_SOCKET_PATH        /var/run/rstudio-server/rstudio-rserver/session-server-rpc.socket
RS_SERVER_URL                    http://134.158.74.74:8080/
RS_SESSION_TMP_DIR               /var/run/rstudio-server/rstudio-rsession
RS_SESSION_URL                   
RSTUDIO                          1
RSTUDIO_CLI_HYPERLINKS           true
RSTUDIO_CONSOLE_COLOR            256
RSTUDIO_CONSOLE_WIDTH            112
RSTUDIO_HTTP_REFERER             http://134.158.74.74:8080/
RSTUDIO_PANDOC                   /usr/lib/rstudio-server/bin/quarto/bin/tools/x86_64
RSTUDIO_PROGRAM_MODE             server
RSTUDIO_R_MODULE                 
RSTUDIO_R_PRELAUNCH_SCRIPT       
RSTUDIO_R_REPO                   
RSTUDIO_R_VERSION_LABEL          
RSTUDIO_SESSION_PID              224062
RSTUDIO_SESSION_STREAM           avallet-d
RSTUDIO_USER_IDENTITY            avallet
RSTUDIO_USER_IDENTITY_DISPLAY    avallet
SED                              /bin/sed
SSH_ASKPASS                      rpostback-askpass
TAR                              /bin/tar
TERM                             xterm-256color
USER                             avallet

Anyone knows what might be the problem?
Best regards,
Améline

@amelinevallet
Copy link
Author

Downgrading rgrass to version 0.3-9 did not solve the issue.

@rsbivand
Copy link
Owner

rsbivand commented Jun 7, 2024

@amelinevallet Could you run traceback() after the failing initGRASS() command for both versions of rgrass, reporting back here with the output of sessionInfo() again for both cases?

@amelinevallet
Copy link
Author

@rsbivand here is what I obtain with rgrass_0.4-2

> sessionInfo(
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8   
 [6] LC_MESSAGES=fr_FR.UTF-8    LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Paris
tzcode source: system (glibc)

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

other attached packages:
[1] rgrass_0.4-2

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        R6_2.5.1          codetools_0.2-20  cellranger_1.1.0  tidyselect_1.2.1  readxl_1.4.3      e1071_1.7-14      magrittr_2.0.3   
 [9] glue_1.7.0        tibble_3.2.1      pkgconfig_2.0.3   dplyr_1.1.4       generics_0.1.3    lifecycle_1.0.4   xml2_1.3.6        cli_3.6.2        
[17] fansi_1.0.6       terra_1.7-78      vctrs_0.6.5       proxy_0.4-27      class_7.3-22      compiler_4.4.0    rstudioapi_0.16.0 tools_4.4.0      
[25] pillar_1.9.0      Rcpp_1.0.12       rlang_1.1.3 

> loc2 <- initGRASS() #return error message
No gisBase set. Trying to detect from the GRASS_INSTALLATION environment variable.
Taking gisBase value from GRASS_INSTALLATION: /usr/lib/grass83
A GISRC file /home/avallet/.grassrc8 already exists.
Do you want to override ('no' will abort)? (y/n) y
Overriding. Avoid this question by setting override = TRUE
Error in read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html,  : 
  Premature end of data in tag guisection line 1 [77]
De plus : Message d'avis :
Dans readLines(outFile) :
  ligne finale incomplète trouvée dans '/tmp/RtmpoKhL2k/file3b32eaff9ed7'
Erreur dans parseGRASS(cmd, legacyExec = legacyExec) : g.region not parsed
> traceback()
5: stop(paste(cmd, "not parsed"))
4: parseGRASS(cmd, legacyExec = legacyExec)
3: doGRASS(cmd, flags = flags, ..., parameters = parameters, echoCmd = echoCmd, 
       legacyExec = legacyExec)
2: execGRASS("g.region", save = "input", flags = "overwrite", ignore.stderr = ignore.stderr)
1: initGRASS()

I thought I managed to downgrade rgrass to version 0.3-9 in my previous message, but indeed, not : when I uninstall the package and force the installation of version 0.3-9, version 0.4-2 is automatically installed (see bellow). I have to figure out how I can install correctly this previous version before being able to make the required test with version 0.3-9. Sorry for that.

> remove.packages("rgrass", lib="~/R/x86_64-pc-linux-gnu-library/4.4")
> install.packages("rgrass", version='0.3-9')
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("rgrass", version = "0.3-9")
Installation du package dans ‘/home/avallet/R/x86_64-pc-linux-gnu-library/4.4’
(car ‘lib’ n'est pas spécifié)
essai de l'URL 'https://cloud.r-project.org/src/contrib/rgrass_0.4-2.tar.gz'
Content type 'application/x-gzip' length 925918 bytes (904 KB)
==================================================
downloaded 904 KB

* installing *source* package ‘rgrass’ ...
** package ‘rgrass’ correctement décompressé et sommes MD5 vérifiées
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rgrass)

Les packages source téléchargés sont dans
	‘/tmp/RtmpS0RABV/downloaded_packages’

@rsbivand
Copy link
Owner

rsbivand commented Jun 7, 2024

Get 0.3-9 from https://cran.r-project.org/src/contrib/Archive/rgrass/rgrass_0.3-9.tar.gz and use:
install.packges("rgrass_0.3-9.tar.gz") assuming you downloaded to your working directory.

@amelinevallet
Copy link
Author

amelinevallet commented Jun 7, 2024

I have managed to install rgrass 0.3-9, here is session and traceback info:

> remove.packages("rgrass", lib="~/R/x86_64-pc-linux-gnu-library/4.4")
> library(devtools)
Le chargement a nécessité le package : usethis
> 
> # Install the specific version of rgrass
> install_version("rgrass", version = "0.3-9", repos = "http://cran.us.r-project.org")
Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/rgrass/rgrass_0.3-9.tar.gz
Installation du package dans ‘/home/avallet/R/x86_64-pc-linux-gnu-library/4.4’
(car ‘lib’ n'est pas spécifié)
* installing *source* package ‘rgrass’ ...
** package ‘rgrass’ correctement décompressé et sommes MD5 vérifiées
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rgrass)
> Sys.setenv("GRASS_INSTALLATION"="/usr/lib/grass83")
> library(rgrass)
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8       
 [4] LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Paris
tzcode source: system (glibc)

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

other attached packages:
[1] devtools_2.4.5 usethis_2.2.3  rgrass_0.3-9  

loaded via a namespace (and not attached):
 [1] miniUI_0.1.1.1    dplyr_1.1.4       compiler_4.4.0    promises_1.3.0    tidyselect_1.2.1 
 [6] Rcpp_1.0.12       xml2_1.3.6        stringr_1.5.1     later_1.3.2       readxl_1.4.3     
[11] fastmap_1.2.0     mime_0.12         R6_2.5.1          generics_0.1.3    htmlwidgets_1.6.4
[16] tibble_3.2.1      profvis_0.3.8     shiny_1.8.1.1     pillar_1.9.0      rlang_1.1.3      
[21] utf8_1.2.4        cachem_1.1.0      stringi_1.8.4     httpuv_1.6.15     fs_1.6.4         
[26] pkgload_1.3.4     memoise_2.0.1     cli_3.6.2         magrittr_2.0.3    class_7.3-22     
[31] digest_0.6.35     rstudioapi_0.16.0 xtable_1.8-4      remotes_2.5.0     lifecycle_1.0.4  
[36] vctrs_0.6.5       proxy_0.4-27      glue_1.7.0        cellranger_1.1.0  urlchecker_1.0.1 
[41] sessioninfo_1.2.2 pkgbuild_1.4.4    e1071_1.7-14      fansi_1.0.6       purrr_1.0.2      
[46] pkgconfig_2.0.3   tools_4.4.0       ellipsis_0.3.2    htmltools_0.5.8.1
> loc2 <- initGRASS() #return error message
A GRASS location (defined by /home/avallet/.grassrc8) is already in use.
Do you want to override ('no' will abort)? (y/n) y
Overriding. Avoid this question by setting override = TRUE
No gisBase set. Trying to detect from the GRASS_INSTALLATION environment variable.
Taking gisBase value from GRASS_INSTALLATION: /usr/lib/grass83
Error in read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html,  : 
  Premature end of data in tag guisection line 1 [77]
De plus : Message d'avis :
Dans readLines(outFile) :
  ligne finale incomplète trouvée dans '/tmp/RtmpS0RABV/file3b3cdd27650a'
Erreur dans parseGRASS(cmd, legacyExec = legacyExec) : g.region not parsed
> traceback()
5: stop(paste(cmd, "not parsed"))
4: parseGRASS(cmd, legacyExec = legacyExec)
3: doGRASS(cmd, flags = flags, ..., parameters = parameters, echoCmd = echoCmd, 
       legacyExec = legacyExec)
2: execGRASS("g.region", save = "input", flags = "overwrite", ignore.stderr = ignore.stderr)
1: initGRASS()

@rsbivand
Copy link
Owner

rsbivand commented Jun 7, 2024

Please install from the source package downloaded from CRAN only, do not use devtools or RStudio. The error message shows read_xml.raw being used; this method is in xml2, so should not be seen in 0.3-9 at all.

The underlying problem may be that GRASS 8.3.2 is emitting XML that is not in UTF-8 encoding in your locale. R sees your locale as fr_FR.UTF-8, which is fine, but how does GRASS see it? It may also be an incomplete string that irritates xml2.

@amelinevallet
Copy link
Author

Yes, indeed session_info() indicates a mismatch between loaded and on-disk rgrass 0.3-9 versions when I installed it with devtools.

> session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24)
 os       Ubuntu 22.04.4 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  fr_FR.UTF-8
 ctype    fr_FR.UTF-8
 tz       Europe/Paris
 date     2024-06-07
 rstudio  2024.04.1+748 Chocolate Cosmos (server)
 pandoc   2.9.2.1 @ /usr/bin/pandoc

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────
 ! package     * version date (UTC) lib source
   cachem        1.1.0   2024-05-16 [3] CRAN (R 4.4.0)
   cellranger    1.1.0   2016-07-27 [3] CRAN (R 4.1.0)
   class         7.3-22  2023-05-03 [4] CRAN (R 4.3.1)
   cli           3.6.2   2023-12-11 [3] CRAN (R 4.3.2)
   devtools    * 2.4.5   2022-10-11 [2] CRAN (R 4.2.1)
   digest        0.6.35  2024-03-11 [3] CRAN (R 4.3.3)
   dplyr         1.1.4   2023-11-17 [3] CRAN (R 4.3.2)
   e1071         1.7-14  2023-12-06 [2] CRAN (R 4.3.2)
   ellipsis      0.3.2   2021-04-29 [3] CRAN (R 4.1.1)
   fansi         1.0.6   2023-12-08 [3] CRAN (R 4.3.2)
   fastmap       1.2.0   2024-05-15 [3] CRAN (R 4.4.0)
   fs            1.6.4   2024-04-25 [3] CRAN (R 4.3.3)
   generics      0.1.3   2022-07-05 [3] CRAN (R 4.2.1)
   glue          1.7.0   2024-01-09 [3] CRAN (R 4.3.2)
   htmltools     0.5.8.1 2024-04-04 [3] CRAN (R 4.3.3)
   htmlwidgets   1.6.4   2023-12-06 [3] CRAN (R 4.3.2)
   httpuv        1.6.15  2024-03-26 [2] CRAN (R 4.3.3)
   later         1.3.2   2023-12-06 [2] CRAN (R 4.3.2)
   lifecycle     1.0.4   2023-11-07 [3] CRAN (R 4.3.2)
   magrittr      2.0.3   2022-03-30 [3] CRAN (R 4.1.3)
   memoise       2.0.1   2021-11-26 [3] CRAN (R 4.1.2)
   mime          0.12    2021-09-28 [3] CRAN (R 4.1.1)
   miniUI        0.1.1.1 2018-05-18 [2] CRAN (R 4.1.1)
   pillar        1.9.0   2023-03-22 [3] CRAN (R 4.2.3)
   pkgbuild      1.4.4   2024-03-17 [3] CRAN (R 4.3.3)
   pkgconfig     2.0.3   2019-09-22 [3] CRAN (R 4.0.1)
   pkgload       1.3.4   2024-01-16 [3] CRAN (R 4.3.2)
   profvis       0.3.8   2023-05-02 [3] CRAN (R 4.3.0)
   promises      1.3.0   2024-04-05 [2] CRAN (R 4.3.3)
   proxy         0.4-27  2022-06-09 [2] CRAN (R 4.2.0)
   purrr         1.0.2   2023-08-10 [3] CRAN (R 4.3.1)
   R6            2.5.1   2021-08-19 [3] CRAN (R 4.1.1)
   Rcpp          1.0.12  2024-01-09 [3] CRAN (R 4.3.2)
   readxl        1.4.3   2023-07-06 [3] CRAN (R 4.3.1)
   remotes       2.5.0   2024-03-17 [3] CRAN (R 4.3.3)
 V rgrass      * 0.4-2   2023-09-10 [1] CRAN (R 4.4.0) (on disk 0.3.9)
   rlang         1.1.3   2024-01-10 [3] CRAN (R 4.3.2)
   rstudioapi    0.16.0  2024-03-24 [3] CRAN (R 4.3.3)
   sessioninfo   1.2.2   2021-12-06 [3] CRAN (R 4.1.2)
   shiny         1.8.1.1 2024-04-02 [2] CRAN (R 4.3.3)
   stringi       1.8.4   2024-05-06 [2] CRAN (R 4.4.0)
   stringr       1.5.1   2023-11-14 [3] CRAN (R 4.3.2)
   tibble        3.2.1   2023-03-20 [3] CRAN (R 4.2.3)
   tidyselect    1.2.1   2024-03-11 [3] CRAN (R 4.3.3)
   urlchecker    1.0.1   2021-11-30 [3] CRAN (R 4.2.1)
   usethis     * 2.2.3   2024-02-19 [3] CRAN (R 4.3.2)
   utf8          1.2.4   2023-10-22 [3] CRAN (R 4.3.2)
   vctrs         0.6.5   2023-12-01 [3] CRAN (R 4.3.2)
   xml2          1.3.6   2023-12-04 [3] CRAN (R 4.3.2)
   xtable        1.8-4   2019-04-21 [2] CRAN (R 4.1.1)

 [1] /home/avallet/R/x86_64-pc-linux-gnu-library/4.4
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

 V ── Loaded and on-disk version mismatch.

I re-installed rgrass 0.3-9 version from the source package as indicated. Here is the session_info and traceback info:

download.file("https://cran.r-project.org/src/contrib/Archive/rgrass/rgrass_0.3-9.tar.gz", "/home/avallet/rgrass_0.3-9.tar.gz", method = "auto")
essai de l'URL 'https://cran.r-project.org/src/contrib/Archive/rgrass/rgrass_0.3-9.tar.gz'
Content type 'application/x-gzip' length 923084 bytes (901 KB)
==================================================
downloaded 901 KB

remove.packages("rgrass", lib="~/R/x86_64-pc-linux-gnu-library/4.4")

> install.packages("rgrass_0.3-9.tar.gz")
Installation du package dans ‘/home/avallet/R/x86_64-pc-linux-gnu-library/4.4’
(car ‘lib’ n'est pas spécifié)
supposition de 'repos = NULL' à partir de 'pkgs'
* installing *source* package ‘rgrass’ ...
** package ‘rgrass’ correctement décompressé et sommes MD5 vérifiées
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rgrass)

> install.packages("rgrass_0.3-9.tar.gz")
Installation du package dans ‘/home/avallet/R/x86_64-pc-linux-gnu-library/4.4’
(car ‘lib’ n'est pas spécifié)
supposition de 'repos = NULL' à partir de 'pkgs'
* installing *source* package ‘rgrass’ ...
** package ‘rgrass’ correctement décompressé et sommes MD5 vérifiées
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rgrass)
> Sys.setenv("GRASS_INSTALLATION"="/usr/lib/grass83")
> library(rgrass)
Le chargement a nécessité le package : XML
GRASS GIS interface loaded with GRASS version: (GRASS not running)
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8       
 [4] LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Paris
tzcode source: system (glibc)

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

other attached packages:
[1] rgrass_0.3-9    XML_3.99-0.16.1

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        R6_2.5.1          codetools_0.2-20  cellranger_1.1.0  tidyselect_1.2.1 
 [6] readxl_1.4.3      e1071_1.7-14      magrittr_2.0.3    glue_1.7.0        tibble_3.2.1     
[11] pkgconfig_2.0.3   dplyr_1.1.4       generics_0.1.3    lifecycle_1.0.4   cli_3.6.2        
[16] fansi_1.0.6       terra_1.7-78      vctrs_0.6.5       proxy_0.4-27      class_7.3-22     
[21] compiler_4.4.0    rstudioapi_0.16.0 tools_4.4.0       pillar_1.9.0      Rcpp_1.0.12      
[26] rlang_1.1.3      
> loc2 <- initGRASS() #return error message
No gisBase set. Trying to detect from the GRASS_INSTALLATION environment variable.
Taking gisBase value from GRASS_INSTALLATION: /usr/lib/grass83
A GISRC file /home/avallet/.grassrc8 already exists.
Do you want to override ('no' will abort)? (y/n) y
Overriding. Avoid this question by setting override = TRUE
Premature end of data in tag guisection line 349
Error : 1: Premature end of data in tag guisection line 349

De plus : Message d'avis :
Dans readLines(outFile) :
  ligne finale incomplète trouvée dans '/tmp/RtmpPh6psJ/file3b5f7453979a0'
Erreur dans parseGRASS(cmd, legacyExec = legacyExec) : g.region not parsed
> traceback()
5: stop(paste(cmd, "not parsed"))
4: parseGRASS(cmd, legacyExec = legacyExec)
3: doGRASS(cmd, flags = flags, ..., parameters = parameters, echoCmd = echoCmd, 
       legacyExec = legacyExec)
2: execGRASS("g.region", save = "input", flags = "overwrite", ignore.stderr = ignore.stderr)
1: initGRASS()
> library(devtools)
> session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24)
 os       Ubuntu 22.04.4 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  fr_FR.UTF-8
 ctype    fr_FR.UTF-8
 tz       Europe/Paris
 date     2024-06-07
 rstudio  2024.04.1+748 Chocolate Cosmos (server)
 pandoc   2.9.2.1 @ /usr/bin/pandoc

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────
 package     * version     date (UTC) lib source
 cachem        1.1.0       2024-05-16 [3] CRAN (R 4.4.0)
 cellranger    1.1.0       2016-07-27 [3] CRAN (R 4.1.0)
 class         7.3-22      2023-05-03 [4] CRAN (R 4.3.1)
 cli           3.6.2       2023-12-11 [3] CRAN (R 4.3.2)
 codetools     0.2-20      2024-03-31 [4] CRAN (R 4.3.3)
 devtools    * 2.4.5       2022-10-11 [2] CRAN (R 4.2.1)
 digest        0.6.35      2024-03-11 [3] CRAN (R 4.3.3)
 dplyr         1.1.4       2023-11-17 [3] CRAN (R 4.3.2)
 e1071         1.7-14      2023-12-06 [2] CRAN (R 4.3.2)
 ellipsis      0.3.2       2021-04-29 [3] CRAN (R 4.1.1)
 fansi         1.0.6       2023-12-08 [3] CRAN (R 4.3.2)
 fastmap       1.2.0       2024-05-15 [3] CRAN (R 4.4.0)
 fs            1.6.4       2024-04-25 [3] CRAN (R 4.3.3)
 generics      0.1.3       2022-07-05 [3] CRAN (R 4.2.1)
 glue          1.7.0       2024-01-09 [3] CRAN (R 4.3.2)
 htmltools     0.5.8.1     2024-04-04 [3] CRAN (R 4.3.3)
 htmlwidgets   1.6.4       2023-12-06 [3] CRAN (R 4.3.2)
 httpuv        1.6.15      2024-03-26 [2] CRAN (R 4.3.3)
 later         1.3.2       2023-12-06 [2] CRAN (R 4.3.2)
 lifecycle     1.0.4       2023-11-07 [3] CRAN (R 4.3.2)
 magrittr      2.0.3       2022-03-30 [3] CRAN (R 4.1.3)
 memoise       2.0.1       2021-11-26 [3] CRAN (R 4.1.2)
 mime          0.12        2021-09-28 [3] CRAN (R 4.1.1)
 miniUI        0.1.1.1     2018-05-18 [2] CRAN (R 4.1.1)
 pillar        1.9.0       2023-03-22 [3] CRAN (R 4.2.3)
 pkgbuild      1.4.4       2024-03-17 [3] CRAN (R 4.3.3)
 pkgconfig     2.0.3       2019-09-22 [3] CRAN (R 4.0.1)
 pkgload       1.3.4       2024-01-16 [3] CRAN (R 4.3.2)
 profvis       0.3.8       2023-05-02 [3] CRAN (R 4.3.0)
 promises      1.3.0       2024-04-05 [2] CRAN (R 4.3.3)
 proxy         0.4-27      2022-06-09 [2] CRAN (R 4.2.0)
 purrr         1.0.2       2023-08-10 [3] CRAN (R 4.3.1)
 R6            2.5.1       2021-08-19 [3] CRAN (R 4.1.1)
 Rcpp          1.0.12      2024-01-09 [3] CRAN (R 4.3.2)
 readxl        1.4.3       2023-07-06 [3] CRAN (R 4.3.1)
 remotes       2.5.0       2024-03-17 [3] CRAN (R 4.3.3)
 rgrass      * 0.3-9       2023-09-10 [1] CRAN (R 4.4.0)
 rlang         1.1.3       2024-01-10 [3] CRAN (R 4.3.2)
 rstudioapi    0.16.0      2024-03-24 [3] CRAN (R 4.3.3)
 sessioninfo   1.2.2       2021-12-06 [3] CRAN (R 4.1.2)
 shiny         1.8.1.1     2024-04-02 [2] CRAN (R 4.3.3)
 stringi       1.8.4       2024-05-06 [2] CRAN (R 4.4.0)
 stringr       1.5.1       2023-11-14 [3] CRAN (R 4.3.2)
 terra         1.7-78      2024-05-22 [1] CRAN (R 4.4.0)
 tibble        3.2.1       2023-03-20 [3] CRAN (R 4.2.3)
 tidyselect    1.2.1       2024-03-11 [3] CRAN (R 4.3.3)
 unixtools   * 0.1-1       2024-05-30 [1] local
 urlchecker    1.0.1       2021-11-30 [3] CRAN (R 4.2.1)
 usethis     * 2.2.3       2024-02-19 [3] CRAN (R 4.3.2)
 utf8          1.2.4       2023-10-22 [3] CRAN (R 4.3.2)
 vctrs         0.6.5       2023-12-01 [3] CRAN (R 4.3.2)
 XML         * 3.99-0.16.1 2024-01-22 [2] CRAN (R 4.3.2)
 xtable        1.8-4       2019-04-21 [2] CRAN (R 4.1.1)

 [1] /home/avallet/R/x86_64-pc-linux-gnu-library/4.4
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

@amelinevallet
Copy link
Author

amelinevallet commented Jun 7, 2024

Regarding your suggestion about encoding, I checked GRASS and R sessions locales.

Here is what I obtained for GRASS

avallet@tess:/usr/lib/R/library$ grass --exec env | grep LC_
grass --exec env | grep LANG
LC_CTYPE=fr_FR.UTF-8
LC_MESSAGES=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_COLLATE=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_ADDRESS=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_NUMERIC=C
LANG=fr_FR
LANGUAGE=fr_FR

And here for R:

Sys.getlocale()
[1] "LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C"

So if I understand properly, both use the same encoding (fr_FR.UTF-8)? Is there something else to check for GRASS? @rsbivand do you know where the xml files generated by GRASS are located ? I could check if their encoding really is fr_FR.UTF-8, or if there is an incomplete string somewhere ?

@rsbivand
Copy link
Owner

rsbivand commented Jun 7, 2024

With XML, the error is: Premature end of data in tag guisection line 349, while in xml2 it was Premature end of data in tag guisection line 1 [77] - which maybe suggests that the XML generated by --interface-description is incomplete, for this version of GRASS. Do you still have GRASS 8.2 installed - if so, could you try to point GRASS_INSTALLATION at 8.2 and try again?

@amelinevallet
Copy link
Author

I removed GRASS 8.2 version, but I am re-installing it right now.

@amelinevallet
Copy link
Author

amelinevallet commented Jun 7, 2024

To install GRASS 8.2, and easily switch between GRASS versions, I used the following lines:

#Download source code for version 8.2
wget https://grass.osgeo.org/grass82/source/grass-8.2.0.tar.gz
tar -zxvf grass-8.2.0.tar.gz
cd grass-8.2.0

#install GRASS GIS 8.2 in /usr/lib/grass82
./configure --prefix=/usr/lib/grass82
make
sudo make install

#Add GRASS 8.3 to the PATH with the grass83 alias
alias grass83="/usr/bin/grass"
export PATH=/usr/bin/grass:$PATH

#Add GRASS 8.2 to the PATH with an other alias
alias grass82='/usr/lib/grass82/bin/grass'
export PATH=/usr/lib/grass82/bin:$PATH

#NB : I do not know why paths of the executables are different, probably something I did differently between the two installations?

#Reload the environment variables
source ~/.bashrc

@amelinevallet
Copy link
Author

With GRASS 8.2 I do not receive the same error message:

> Sys.setenv("GRASS_INSTALLATION"="/usr/lib/grass82/grass82")
> library(rgrass)
> library(terra)
terra 1.7.78
> library(sf)
Linking to GEOS 3.11.1, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
> library(raster)
Le chargement a nécessité le package : sp
> library(unixtools)
> library(doParallel)
Le chargement a nécessité le package : foreach
Le chargement a nécessité le package : iterators
Le chargement a nécessité le package : parallel
> library(tidyverse)
── Attaching core tidyverse packages ─────────────────────────────────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ───────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ purrr::%||%()       masks base::%||%()
✖ purrr::accumulate() masks foreach::accumulate()
✖ tidyr::extract()    masks raster::extract(), terra::extract()
✖ dplyr::filter()     masks stats::filter()
✖ dplyr::lag()        masks stats::lag()
✖ dplyr::select()     masks raster::select()
✖ purrr::when()       masks foreach::when()
ℹ Use the conflicted package to force all conflicts to become errors
> set.tempdir("/mnt/dataIn/data_agata/Advanced_DEM_indices/temporary_files")
> GRASS_INSTALLATION <- Sys.getenv("GRASS_INSTALLATION")
> file.info(GRASS_INSTALLATION)$isdir[1]
[1] TRUE
> GRASS_INSTALLATION
[1] "/usr/lib/grass82/grass82"
> 
> path <- "/mnt/dataIn/data_agata/DEM/altitude.tif" #TO CHANGE MANUALLY WITH DESTRIPPED RASTER
> r <- rast(path)
> 
> loc <- initGRASS(gisBase=GRASS_INSTALLATION, home=tempdir(), SG=r, override=TRUE, remove_GISRC = TRUE)

I am not sure to understand what is the problem, but apparently, with the downgraded GRASS 8.2 version and rgrass 0.3-9, the error do not appear anymore. So we do have a workaround until the issue with GRASS 8.3 is more clearly identified, it is a good news !!! Thanks,

@rsbivand
Copy link
Owner

rsbivand commented Jun 7, 2024

Could you please try with rgrass 0.4-2?

@amelinevallet
Copy link
Author

I just tried, it worked with rgrass 0.4-2 too.

Here is the session_info for the test with rgrass 0.3-9

> Sys.setenv("GRASS_INSTALLATION"="/usr/local/grass82")
> library(rgrass)
Le chargement a nécessité le package : XML
GRASS GIS interface loaded with GRASS version: (GRASS not running)
> library(terra)
terra 1.7.78
> library(sf)
Linking to GEOS 3.11.1, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
> library(raster)
Le chargement a nécessité le package : sp
> library(unixtools)
> library(doParallel)
Le chargement a nécessité le package : foreach
Le chargement a nécessité le package : iterators
Le chargement a nécessité le package : parallel
> library(tidyverse)
── Attaching core tidyverse packages ─────────────────────────────────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ───────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ purrr::%||%()       masks base::%||%()
✖ purrr::accumulate() masks foreach::accumulate()
✖ tidyr::extract()    masks raster::extract(), terra::extract()
✖ dplyr::filter()     masks stats::filter()
✖ dplyr::lag()        masks stats::lag()
✖ dplyr::select()     masks raster::select()
✖ purrr::when()       masks foreach::when()
ℹ Use the conflicted package to force all conflicts to become errors
> 
> set.tempdir("/mnt/dataIn/data_agata/Advanced_DEM_indices/temporary_files")
> GRASS_INSTALLATION <- Sys.getenv("GRASS_INSTALLATION")
> file.info(GRASS_INSTALLATION)$isdir[1]
[1] TRUE
> GRASS_INSTALLATION
[1] "/usr/local/grass82"
> 
> path <- "/mnt/dataIn/data_agata/DEM/altitude.tif" #TO CHANGE MANUALLY WITH DESTRIPPED RASTER
> r <- rast(path)
> 
> loc <- initGRASS(gisBase=GRASS_INSTALLATION, home=tempdir(), SG=r, override=TRUE, remove_GISRC = TRUE)
> 
> write_RAST(as(raster(r), "SpatialGridDataFrame"), vname="altitude", overwrite = TRUE)
 100%
SpatialGridDataFrame read into GRASS using r.in.bin
> 
> 
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8       
 [4] LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Paris
tzcode source: system (glibc)

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

other attached packages:
 [1] lubridate_1.9.3   forcats_1.0.0     stringr_1.5.1     dplyr_1.1.4       purrr_1.0.2      
 [6] readr_2.1.5       tidyr_1.3.1       tibble_3.2.1      ggplot2_3.5.1     tidyverse_2.0.0  
[11] doParallel_1.0.17 iterators_1.0.14  foreach_1.5.2     unixtools_0.1-1   raster_3.6-26    
[16] sp_2.1-4          sf_1.0-16         terra_1.7-78      rgrass_0.3-9      XML_3.99-0.16.1  

loaded via a namespace (and not attached):
 [1] utf8_1.2.4         generics_0.1.3     class_7.3-22       KernSmooth_2.23-24 stringi_1.8.4     
 [6] lattice_0.22-6     hms_1.1.3          magrittr_2.0.3     timechange_0.3.0   grid_4.4.0        
[11] cellranger_1.1.0   e1071_1.7-14       DBI_1.2.2          fansi_1.0.6        scales_1.3.0      
[16] codetools_0.2-20   cli_3.6.2          rlang_1.1.3        units_0.8-5        munsell_0.5.1     
[21] withr_3.0.0        tools_4.4.0        tzdb_0.4.0         colorspace_2.1-0   vctrs_0.6.5       
[26] R6_2.5.1           proxy_0.4-27       lifecycle_1.0.4    classInt_0.4-10    pkgconfig_2.0.3   
[31] pillar_1.9.0       gtable_0.3.5       glue_1.7.0         Rcpp_1.0.12        tidyselect_1.2.1  
[36] rstudioapi_0.16.0  compiler_4.4.0     readxl_1.4.3   

And here for the test with rgrass 0.4-2

> install.packages("rgrass")
Installation du package dans ‘/home/avallet/R/x86_64-pc-linux-gnu-library/4.4’
(car ‘lib’ n'est pas spécifié)
essai de l'URL 'https://cloud.r-project.org/src/contrib/rgrass_0.4-2.tar.gz'
Content type 'application/x-gzip' length 925918 bytes (904 KB)
==================================================
downloaded 904 KB

* installing *source* package ‘rgrass’ ...
** package ‘rgrass’ correctement décompressé et sommes MD5 vérifiées
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rgrass)

Les packages source téléchargés sont dans
	‘/tmp/RtmpjV4VEn/downloaded_packages’
> Sys.setenv("GRASS_INSTALLATION"="/usr/local/grass82")
> 
> library(rgrass)
GRASS GIS interface loaded with GRASS version: GRASS 8.2.2dev (2023)
and location: file4da7925d9589c
> library(terra)
terra 1.7.78
> library(sf)
Linking to GEOS 3.11.1, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
> library(raster)
Le chargement a nécessité le package : sp
> library(unixtools)
> library(doParallel)
Le chargement a nécessité le package : foreach
Le chargement a nécessité le package : iterators
Le chargement a nécessité le package : parallel
> library(tidyverse)
── Attaching core tidyverse packages ─────────────────────────────────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ───────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ purrr::%||%()       masks base::%||%()
✖ purrr::accumulate() masks foreach::accumulate()
✖ tidyr::extract()    masks raster::extract(), terra::extract()
✖ dplyr::filter()     masks stats::filter()
✖ dplyr::lag()        masks stats::lag()
✖ dplyr::select()     masks raster::select()
✖ purrr::when()       masks foreach::when()
ℹ Use the conflicted package to force all conflicts to become errors
> 
> set.tempdir("/mnt/dataIn/data_agata/Advanced_DEM_indices/temporary_files")
> GRASS_INSTALLATION <- Sys.getenv("GRASS_INSTALLATION")
> file.info(GRASS_INSTALLATION)$isdir[1]
[1] TRUE
> GRASS_INSTALLATION
[1] "/usr/local/grass82"
> 
> path <- "/mnt/dataIn/data_agata/DEM/altitude.tif" #TO CHANGE MANUALLY WITH DESTRIPPED RASTER
> r <- rast(path)
> 
> loc <- initGRASS(gisBase=GRASS_INSTALLATION, home=tempdir(), SG=r, override=TRUE, remove_GISRC = TRUE)
> 
> write_RAST(as(raster(r), "SpatialGridDataFrame"), vname="altitude", overwrite = TRUE)
 100%
SpatialGridDataFrame read into GRASS using r.in.bin
> 
> 
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8       
 [4] LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Paris
tzcode source: system (glibc)

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

other attached packages:
 [1] lubridate_1.9.3   forcats_1.0.0     stringr_1.5.1     dplyr_1.1.4       purrr_1.0.2      
 [6] readr_2.1.5       tidyr_1.3.1       tibble_3.2.1      ggplot2_3.5.1     tidyverse_2.0.0  
[11] doParallel_1.0.17 iterators_1.0.14  foreach_1.5.2     unixtools_0.1-1   raster_3.6-26    
[16] sp_2.1-4          sf_1.0-16         terra_1.7-78      rgrass_0.4-2     

loaded via a namespace (and not attached):
 [1] utf8_1.2.4         generics_0.1.3     class_7.3-22       xml2_1.3.6         KernSmooth_2.23-24
 [6] stringi_1.8.4      lattice_0.22-6     hms_1.1.3          magrittr_2.0.3     grid_4.4.0        
[11] timechange_0.3.0   e1071_1.7-14       DBI_1.2.2          fansi_1.0.6        scales_1.3.0      
[16] codetools_0.2-20   cli_3.6.2          rlang_1.1.3        units_0.8-5        munsell_0.5.1     
[21] withr_3.0.0        tools_4.4.0        tzdb_0.4.0         colorspace_2.1-0   vctrs_0.6.5       
[26] R6_2.5.1           proxy_0.4-27       lifecycle_1.0.4    classInt_0.4-10    pkgconfig_2.0.3   
[31] pillar_1.9.0       gtable_0.3.5       glue_1.7.0         Rcpp_1.0.12        tidyselect_1.2.1  
[36] rstudioapi_0.16.0  compiler_4.4.0 

I hope this information is useful

@amelinevallet
Copy link
Author

amelinevallet commented Jun 7, 2024

A pbm raised when using GRASS 8.2 : it is not possible to download addons from github with g.extension. The problem is documented here: https://gis.stackexchange.com/questions/474069/cannot-install-grass-addons-in-grass-8-2-ubuntu-jammy, and the workaround proposition works well.

@rsbivand
Copy link
Owner

rsbivand commented Jun 7, 2024

Having at last rebuilt my GRASS 8.3.2 (GEOS was updated last night, so I rebuilt GEOS, GDAL and finally GRASS from source) on Fedora 40, with R 4.4.0 and current rgrass, I do not see any problem.

I cannot see from https://github.com/OSGeo/grass/commits/main/lib/gis/parser_interface.c that G__usage_xml starting at: https://github.com/OSGeo/grass/blob/87847c25b85868298807c07743d17856d37fdf4a/lib/gis/parser_interface.c#L100 has changed in the recent period, and it does not link to external software to write the XML output.

My guess might then be that GRASS 8.3.2 was not updated successfully from 8.2 in your case.

How was GRASS 8.3.2 installed, from source or binary? If from source, which configure arguments were used, and did make complete without error? If this is an Ubuntu-specific problem, we'd need to go back to the grass-dev mailing list. Are there other tests that could be run starting GRASS directly, not from within R, to check that it works locally? https://github.com/OSGeo/grass/blob/main/testsuite/README.md is not very informative, I'm afraid.

@amelinevallet
Copy link
Author

Grass 8.3.2 was installed with :
sudo apt-get update
sudo add-apt-repository ppa:ubuntugis/ppa
sudo add-apt-repository ppa:grass/grass-stable
sudo apt-get update
sudo apt-get install grass
sudo apt-get install grass-doc

@florisvdh
Copy link
Collaborator

No problem here with GRASS GIS 8.3.2 on Linux Mint 21.3 (based off Ubuntu 22.04) + R 4.4.0 + rgrass 0.4.2 (CRAN):

Code and output
$ R

R version 4.4.0 (2024-04-24) -- "Puppy Cup"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

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.

> packageVersion("rgrass")
[1] ‘0.4.2> library(rgrass)
GRASS GIS interface loaded with GRASS version: (GRASS not running)
> initGRASS(gisDbase = "/home/floris/grassdata", location = "nc_basic_spm_grass7", mapset = "PERMANENT", override = TRUE)
No gisBase set. Trying to detect from the GRASS_INSTALLATION environment variable.
No GRASS_INSTALLATION environment variable was found.
Trying to set gisBase by running command `grass --config path` (requires grass in the system PATH).
Taking gisBase value from `grass --config path` output: /usr/lib/grass83
gisdbase    /home/floris/grassdata 
location    nc_basic_spm_grass7 
mapset      PERMANENT 
rows        1350 
columns     1500 
north       228500 
south       215000 
west        630000 
east        645000 
nsres       10 
ewres       10 
projection:
 PROJCRS["NAD83(HARN) / North Carolina",
    BASEGEOGCRS["NAD83(HARN)",
        DATUM["NAD83 (High Accuracy Reference Network)",
            ELLIPSOID["GRS 1980",6378137,298.257222101,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4152]],
    CONVERSION["SPCS83 North Carolina zone (meter)",
        METHOD["Lambert Conic Conformal (2SP)",
            ID["EPSG",9802]],
        PARAMETER["Latitude of false origin",33.75,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8821]],
        PARAMETER["Longitude of false origin",-79,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8822]],
        PARAMETER["Latitude of 1st standard parallel",36.1666666666667,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8823]],
        PARAMETER["Latitude of 2nd standard parallel",34.3333333333333,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8824]],
        PARAMETER["Easting at false origin",609601.22,
            LENGTHUNIT["metre",1],
            ID["EPSG",8826]],
        PARAMETER["Northing at false origin",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8827]]],
    CS[Cartesian,2],
        AXIS["easting (X)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["northing (Y)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Engineering survey, topographic mapping."],
        AREA["United States (USA) - North Carolina - counties of Alamance; Alexander; Alleghany; Anson; Ashe; Avery; Beaufort; Bertie; Bladen; Brunswick; Buncombe; Burke; Cabarrus; Caldwell; Camden; Carteret; Caswell; Catawba; Chatham; Cherokee; Chowan; Clay; Cleveland; Columbus; Craven; Cumberland; Currituck; Dare; Davidson; Davie; Duplin; Durham; Edgecombe; Forsyth; Franklin; Gaston; Gates; Graham; Granville; Greene; Guilford; Halifax; Harnett; Haywood; Henderson; Hertford; Hoke; Hyde; Iredell; Jackson; Johnston; Jones; Lee; Lenoir; Lincoln; Macon; Madison; Martin; McDowell; Mecklenburg; Mitchell; Montgomery; Moore; Nash; New Hanover; Northampton; Onslow; Orange; Pamlico; Pasquotank; Pender; Perquimans; Person; Pitt; Polk; Randolph; Richmond; Robeson; Rockingham; Rowan; Rutherford; Sampson; Scotland; Stanly; Stokes; Surry; Swain; Transylvania; Tyrrell; Union; Vance; Wake; Warren; Washington; Watauga; Wayne; Wilkes; Wilson; Yadkin; Yancey."],
        BBOX[33.83,-84.33,36.59,-75.38]],
    ID["EPSG",3358]] 
> 
> sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24)
 os       Linux Mint 21.3
 system   x86_64, linux-gnu
 ui       X11
 language nl_BE:nl
 collate  nl_BE.UTF-8
 ctype    nl_BE.UTF-8
 tz       Europe/Brussels
 date     2024-06-14
 pandoc   3.1.11 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/x86_64/pandocPackages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 cli           3.6.2   2023-12-11 [3] RSPM (R 4.3.0)
 codetools     0.2-20  2024-03-31 [3] RSPM (R 4.3.0)
 Rcpp          1.0.12  2024-01-09 [3] RSPM (R 4.3.0)
 rgrass      * 0.4-2   2024-03-17 [3] RSPM (R 4.3.0)
 rlang         1.1.4   2024-06-04 [3] RSPM (R 4.4.0)
 sessioninfo   1.2.2   2021-12-06 [3] RSPM (R 4.2.0)
 terra         1.7-78  2024-05-22 [1] RSPM (R 4.4.0)
 xml2          1.3.6   2023-12-04 [3] RSPM (R 4.3.0)

 [1] /home/floris/lib/R/library
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> 

However GRASS GIS on my system has been installed somewhat differently (the PPAs that you list, don't have 8.3.2 for Ubuntu Jammy). The stable binary GRASS GIS releases for Ubuntu are at the ubuntugis-unstable PPA, as linked at https://grass.osgeo.org/download/linux/). Hence you need add-apt-repository ppa:ubuntugis/ubuntugis-unstable.

I have:

$ apt policy grass
grass:
  Installed: 8.3.2-1~jammy1
  Candidate: 8.3.2-1~jammy1
  Version table:
 *** 8.3.2-1~jammy1 500
        500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu jammy/main amd64 Packages
        500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu jammy/main i386 Packages
        100 /var/lib/dpkg/status
     7.8.7-1 500
        500 http://ftp.belnet.be/ubuntu jammy/universe amd64 Packages
        500 http://ftp.belnet.be/ubuntu jammy/universe i386 Packages

So I'd suggest to purge existing GRASS GIS 8.3.2, reinstall it from this PPA and try again.

@ecodiv
Copy link

ecodiv commented Jun 16, 2024

No problem here with GRASS GIS 8.3.2 and 8.5.0dev on Ubuntu 22.04 and R 4.4.0 + rgrass 0.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants