Hi Bernardo,

The presented system() command requires grass to be in the system's PATH. An alternative is to use the R package link2GI <https://r-spatial.github.io/link2GI/> to get the gisBase argument of initGRASS(); AFAIK it has been updated to also support GRASS 8.

Possible approach copied from an R markdown document:

gisbase_grass <-
  if (interactive()) {
    if (.Platform$OS.type == "windows") link2GI::paramGRASSw()$gisbase_GRASS[1] else {
      link2GI::paramGRASSx()$gisbase_GRASS[1]
    }
  } else params$gisbase_grass


Regards

Floris


Op 26/08/2022 om 13:09 schreef Roger Bivand:
Please also see
https://github.com/rsbivand/rgrass/issues/64 and perhaps give more context - is this the public github repo
https://github.com/NINAnor/oneimpact/ ?

Roger

---
Roger Bivand
Emeritus Professor
Department of Economics
Norwegian School of Economics, Bergen, Norway

------------------------------------------------------------------------
*Fra:* grass-stats <grass-stats-boun...@lists.osgeo.org> på vegne av Bernardo Santos via grass-stats <grass-stats@lists.osgeo.org>
*Sendt:* fredag 26. august 2022, 12:56
*Til:* grass-stats@lists.osgeo.org <grass-stats@lists.osgeo.org>; GRASS User List <grass-u...@lists.osgeo.org>
*Emne:* [GRASS-stats] Running r-grass examples when building a R package

Dear all,

I am building a R package and some of the functions use rgrass to connect to a GRASS project and run thingfs within GRASS. I have now set up a webpage for the package using pkgdown in integrated to Github actions. This means when I push new commits all the examples of R functions are run again and the webpage is updated with the results of the examples. Here is the webpage: https://ninanor.github.io/oneimpact/ <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fninanor.github.io%2Foneimpact%2F&data=05%7C01%7Croger.bivand%40nhh.no%7C9ee806160e144928a19908da8751a4d1%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C637971081981258278%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DGuKqYQDHFgwT3qY%2BjzglZF1mboRdv2fx7ETXdmYRJ0%3D&reserved=0>

All works fine, except the functions calling GRASS. When I run the examples form my local computer everything works, but in the Github actions it does not run, apparently because the command

|system <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Frdrr.io%2Fr%2Fbase%2Fsystem.html&data=05%7C01%7Croger.bivand%40nhh.no%7C9ee806160e144928a19908da8751a4d1%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C637971081981258278%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PWx9f7SSQY6EQn2nPNsCFAdIjT3hp3T6Kk7S9%2BAKnDs%3D&reserved=0>("grass78 --config path", intern = T)| to find the GRASS folder and use within rgrass::initGRASS does not work, so the connection between R and GRASS do not exist.

Does someone in the group has experience with that and could help with hints to solve it? Is there a recommended way to make sure Github actions know where GRASS is and use it?

Best
Bernardo


_______________________________________________
grass-stats mailing list
grass-stats@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-stats
_______________________________________________
grass-stats mailing list
grass-stats@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-stats

Reply via email to