-
Notifications
You must be signed in to change notification settings - Fork 9
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
initGRASS() and cross-platform reproducibility #29
Comments
Well, you don't really need to hardcode it, right? The following works in different systems and then, the user does not need to set an environment variable at all. Would you be able to grab that somehow in your workaround?
IMHO, relying on an environment variable that must be set by the user (think normal users and new comers) to get source: https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7 |
@veroandreo thanks for the hint! That would be doable indeed (using In my suggestion, allowing an environment variable (that presets $ cat ~/.Renviron
R_LIBS_USER="~/lib/R/library"
GISBASE_GRASS="/usr/lib/grass78" |
I agree with @veroandreo that an environment variable, especially set in say |
I understand that one overall setting (
I follow that too. The option of using the environment var instead of hardcoding But it was just an idea, no problem to drop it. IMHO an approach where users can maintain their own system settings outside of their R code is interesting, especially for collaborative environments - as you say. But of course we might still implement the env var suggestion locally and assign such an env var value to Feel free to close! |
An alternative could be to use |
Just as a note here...@florisvdh is 100%. The standard for me when I'm wrapping something that might require a user-specific setup is to make it possible to specify the option as an getOption("pkg.some_config", Sys.getenv("R_PKG_SOME_CONFIG", "default-value")) |
This issue proposes an idea I've been thinking of since some time - if useful, it might fit in a possible package upgrade to support GRASS 8 (#28).
Currently,
initGRASS()
has a requiredgisBase
argument (e.g. in a Linux setup with GRASS 7.8, this would often be/usr/lib/grass78
). However hardcoding this path in a script makes the script unfit for cross-platform reproducibility (or for recycling a script for future usage), given the various versions and modes of GRASS installation. Currently I try to overcome this with something likegisbase_grass <- ifelse(.Platform$OS.type == "windows", link2GI::paramGRASSw()$gisbase_GRASS[1], link2GI::paramGRASSx()$gisbase_GRASS[1])
- but I don't expect miracles either: it seemed difficult also inlink2GI
to cope with all possible situations and GRASS versions, since things continue to evolve.Idea: allowing the
gisBase
argument to be missing, in which caseinitGRASS()
would check for the existence of an environment variableGISBASE_GRASS
(not to be confused with theGISDBASE
variable) and take its value. This environment variable would need to be set by the user if (s)he wishes to implement such feature, e.g. in a user level.Renviron
file (i.e. not as a part of a shared R project). So this would be an optional route avoiding to hardcode the lib path in an R script, while on the other hand this script could only run if a user has set the environment variable (if not,initGRASS()
will error but could explain the possibility in the error message).The text was updated successfully, but these errors were encountered: