config: allow overriding data directory via GH_DATA_DIR#209
Open
config: allow overriding data directory via GH_DATA_DIR#209
GH_DATA_DIR#209Conversation
Tests were inheriting environment variables from the host environment (GH_TOKEN, GH_CONFIG_DIR, etc.), causing failures when these were set. Explicitly clear these variables in each test to ensure isolation.
Add support for GH_DATA_DIR environment variable to customize the data directory location, mirroring GH_CONFIG_DIR for config. Data path precedence: GH_DATA_DIR → XDG_DATA_HOME → LocalAppData → HOME This enables system-wide configuration on NixOS and other declarative systems where config may be read-only in /etc/gh but data (extensions, etc.) needs a separate writable location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey, this is a bit of a drive-by PR but I think it's quite small in nature and fills in a gap that'd help with consistency. I've added support for overriding the data directory via a
GH_DATA_DIRenvironment variable, which is akin toGH_CONFIG_DIR. This is nice for users who want a global/user-agnostic configuration, and don't want to pollute their home dirs. In my case, I want to manage extensions in a different directory than the default (I use NixOS and want to have my config be read-only in/etc/gh).The precedence for locating the data dir is now
GH_DATA_DIR-->XDG_DATA_HOME-->LocalAppData(Windows) -->HOMEWhile I was at it, I also fixed tests that suffered from environment pollution. I set
GH_TOKENand this was breaking some tests.Thanks a ton!
N.B. If accepted, I can help update the main CLI repo with docs :)