Skip to content

Commit 085d14b

Browse files
authored
Use XDG_CONFIG_HOME for config folder (#559)
Retrieve the default folder for storing config files from the XDG_CONFIG_HOME env var if present. Fall back to "~/.config" if the env var is not declared. This allows customization of the config folder. For example when running on a YARN cluster, ~ expands to /home/ and attempting to save the config raises a permission error.
1 parent 119ddf1 commit 085d14b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sentinelhub/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,5 @@ def _mask_credentials(self, value: str) -> str:
216216
@classmethod
217217
def get_config_location(cls) -> str:
218218
"""Returns the default location of the user configuration file on disk."""
219-
user_folder = os.path.expanduser("~")
220-
return os.path.join(user_folder, ".config", "sentinelhub", "config.toml")
219+
config_folder = os.getenv("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
220+
return os.path.join(config_folder, "sentinelhub", "config.toml")

0 commit comments

Comments
 (0)