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

lib/init: add GRASS_CONFIG_DIR environment variable #3899

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

imincik
Copy link
Contributor

@imincik imincik commented Jun 19, 2024

GRASS_CONFIG_DIR variable allows to set alternative root path for
.grass<VERSION> configuration directory. If not set, $HOME directory
is used.

The main use case of this PR is to be able to run multiple isolated instances of grass. Using $HOME or $XDG_CONFIG_HOME variables to force grass to store configuration in alternative directory is not a good idea, because this will also have an impact on other tools relying on those variables. That's why I introduced a new grass specific environment variable.

/cc @landam

GRASS_CONFIG_DIR variable allows to set alternative root path for
`.grass<VERSION>` configuration directory. If not set, $HOME directory
is used.
@nilason
Copy link
Contributor

nilason commented Jun 19, 2024

Related #3153

@landam landam self-assigned this Jun 19, 2024
@landam landam added this to the 8.5.0 milestone Jun 19, 2024
@nilason
Copy link
Contributor

nilason commented Jun 19, 2024

Would it be possible to, instead of introducing another GRASS env var, adopt our code to respect (if set) $XDG_CONFIG_HOME (see https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html)?

@imincik
Copy link
Contributor Author

imincik commented Jun 19, 2024

Would it be possible to, instead of introducing another GRASS env var, adopt our code to respect (if set) $XDG_CONFIG_HOME (see https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html)?

The main use case of this PR is to be able to run multiple isolated instances of grass. Using $HOME or $XDG_CONFIG_HOME variables to force grass to store configuration in alternative directory is not a good idea, because this will also have an impact on other tools relying on those variables. That's why I introduced a new grass specific environment variable.

@imincik
Copy link
Contributor Author

imincik commented Jun 19, 2024

Would it be possible to, instead of introducing another GRASS env var, adopt our code to respect (if set) $XDG_CONFIG_HOME (see https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html)?

But I agree, that usage of XDG_CONFIG_HOME instead of HOME is a good fix for #3153 .

@nilason
Copy link
Contributor

nilason commented Jun 19, 2024

The main use case of this PR is to be able to run multiple isolated instances of grass. Using $HOME or $XDG_CONFIG_HOME variables to force grass to store configuration in alternative directory is not a good idea, because this will also have an impact on other tools relying on those variables. That's why I introduced a new grass specific environment variable.

I see.

Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some typos

lib/init/grass.py Outdated Show resolved Hide resolved
lib/init/variables.html Outdated Show resolved Hide resolved
landam and others added 2 commits June 19, 2024 17:35
Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
@github-actions github-actions bot added Python Related code is in Python HTML Related code is in HTML libraries docs labels Jun 19, 2024
lib/init/grass.py Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
nilason
nilason previously approved these changes Jun 20, 2024
@landam landam marked this pull request as draft June 20, 2024 08:48
- create grass.utils.config to avoid code duplication in grass.py and core.utils
- change grass.py in order to use grass.utils.config.get_grass_config_path()
@github-actions github-actions bot added the GUI wxGUI related label Jun 20, 2024
@landam landam marked this pull request as ready for review June 26, 2024 12:39
@nilason
Copy link
Contributor

nilason commented Jun 26, 2024

I will not be able to look at and test this this week, but please hold on, I see there are Mac specific changes now that need hands-on testing/review.

@landam
Copy link
Member

landam commented Jun 27, 2024

I will not be able to look at and test this this week, but please hold on, I see there are Mac specific changes now that need hands-on testing/review.

Sure. This PR shouldn't change behaviour compared to #3694.

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a reasonable feature, although I'm wondering whether other (all?) software allows the same, i.e., having its own variable to set config dir just for that software.

As for the implementation, there is couple of other places which may need fixing. g.extension needs to do something, but I didn't examine what. lib/gis/home.c worries me a little bit as it seems to figure out the path as well, at this point duplicating what is in Python which is more complex code with this PR and the anticipated XDG change.

python/grass/app/runtime.py Outdated Show resolved Hide resolved
python/grass/app/runtime.py Outdated Show resolved Hide resolved
python/grass/app/runtime.py Outdated Show resolved Hide resolved
lib/init/grass.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs GUI wxGUI related HTML Related code is in HTML libraries Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants