You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ gh --version
gh version 0.5.7 (2020-02-20)
https://github.com/cli/cli/releases/tag/v0.5.7
ghappears to conform to the XDG basedir spec by writing to ~/.config/gh. However, it does not respect XDG_CONFIG_HOME as it should. ~/.config is the default value for XDG_CONFIG_HOME, but should only be used if XDG_CONFIG_HOME itself is unset. If it is set, it should be respected.
Steps to reproduce the behavior
rm -rf ~/.config/gh (or rename)
export XDG_CONFIG_HOME=$(mktemp -d) (configure a custom config-home)
gh issue list run a command to trigger authentication
ls ~/.config/gh note that gh was re-created under ~/.config instead of the temp directory
ls $XDG_CONFIG_HOME note that nothing was written to XDG_CONFIG_HOME; this is where gh/config.ymlshould have been written.
Expected vs actual behavior
Conformance to the XDG spec requires that the XDG_CONFIG_HOME variable be respected for where to write user configuration files. gh is writing to ~/.config but not respecting XDG_CONFIG_HOME when it is set.
I also noticed that the files within .config/gh aren't "config" (at least, not in the sense that I'd expect people to be able to version in dotfiles repo or anything). Both the oauth token in config.yml and the entire state.yml file should probably be saved in XDG_DATA_HOME. Should that just be noted here or as a separate issue? (It's all the same general concern, but I'd honestly expect them to be implemented as separate PRs. But also understand it's still early days for the project and having a hundred issues isn't helpful. 😸 )
I'm very pleased to see that adding support is a goal for a stable release!
I also noticed that the files within .config/gh aren't "config" (at least, not in the sense that I'd expect people to be able to version in dotfiles repo or anything).
This is a very important and often overlooked part of the entire value proposition of the XDG basedir spec. What resides in $XDG_CONFIG_HOME should only be configuration files in the purest sense, and be ideally a human readable, plain text file format that is easily edited by hand and stable (in that, if I invoke gh, it won't modify the file unless explicitly asked).
Apologies if I've come across a bit strong there, but there are a thousand and one programs that violate that and nullify half the point of the spec (see: Chromium and everything derived from it).
Reacted by Mislav Marohnić, James D, Edwin Kofler, Neurognostic and Daniel Bayley
Apologies if I've come across a bit strong there, but there a thousand and one programs that violate that and nullify half the point of the spec
@severen Your opinions about XDG certainly seem strongly held, but I value you arguing for them because that gives us useful pointers about what we should consider when we do implement it.
@jasonkarns I agree that our config file right now isn't really config. We might be able to avoid storing one's username, because we know your user handle as soon as we authenticate with the stored token, and we might be able to avoid storing the token in a file in the first place if we implement storing it in your OS's keyring.
In the future, though, GitHub CLI will probably have some actual configuration options, and we will store these under XDG_CONFIG_HOME, and I'm guessing that we can store "data" files (such as the date of the last lookup of the update notifier) under XDG_DATA_HOME.
Reacted by Severen Redwood, Oliver Ford, Edwin Kofler, Neurognostic, Alisson Bruno and Daniel Bayley
Reacted by Jason Karns, James D, Oliver Ford, Edwin Kofler, Neurognostic and Alisson Bruno
I'm not sure I understand exactly what you are proposing to do with hosts.yml, but I'm going to outline my general thoughts.
In a future where we support the XDG basedir spec (I'm sorry @jasonkarns@severen that this didn't make it into our v1.0), I do not feel strongly about hosts.yml being moved to XDG_DATA_HOME. After all, most of what hosts.yml holds is host-specific configuration, and as such I feel like it belongs to XDG_CONFIG_HOME.
We can weigh the pros vs. cons of storing OAuth tokens in this file, or in DATA vs CONFIG directory, but I believe that ultimately we should move these tokens out of plain text files anyway: #449
Activity
mislav commentedon Feb 26, 2020
Thank you! I definitely want to support the XDG basedir spec before we reach stable release. 👍
jasonkarns commentedon Feb 26, 2020
I also noticed that the files within .config/gh aren't "config" (at least, not in the sense that I'd expect people to be able to version in dotfiles repo or anything). Both the oauth token in config.yml and the entire state.yml file should probably be saved in XDG_DATA_HOME. Should that just be noted here or as a separate issue? (It's all the same general concern, but I'd honestly expect them to be implemented as separate PRs. But also understand it's still early days for the project and having a hundred issues isn't helpful. 😸 )
severen commentedon Mar 6, 2020
I'm very pleased to see that adding support is a goal for a stable release!
This is a very important and often overlooked part of the entire value proposition of the XDG basedir spec. What resides in
$XDG_CONFIG_HOMEshould only be configuration files in the purest sense, and be ideally a human readable, plain text file format that is easily edited by hand and stable (in that, if I invoke gh, it won't modify the file unless explicitly asked).Apologies if I've come across a bit strong there, but there are a thousand and one programs that violate that and nullify half the point of the spec (see: Chromium and everything derived from it).
mislav commentedon Mar 6, 2020
@severen Your opinions about XDG certainly seem strongly held, but I value you arguing for them because that gives us useful pointers about what we should consider when we do implement it.
@jasonkarns I agree that our config file right now isn't really config. We might be able to avoid storing one's username, because we know your user handle as soon as we authenticate with the stored token, and we might be able to avoid storing the token in a file in the first place if we implement storing it in your OS's keyring.
In the future, though, GitHub CLI will probably have some actual configuration options, and we will store these under XDG_CONFIG_HOME, and I'm guessing that we can store "data" files (such as the date of the last lookup of the update notifier) under XDG_DATA_HOME.
[-]Does not respect XDG_CONFIG_HOME[/-][+]Improved XDG basedir spec compliance[/+]vilmibm commentedon Nov 24, 2020
I'd like to revisit this conversation, but I think that sets off a connected conversation about host-specific configuration.
It sounds like we should stop putting host-specific config into
hosts.ymlso thathosts.ymlcan be moved intoXDG_DATA_HOME.In general, I think the host/global config concept can be improved or at least better edified; that will make it easier to consider this issue.
@mislav @samcoe thoughts?
mislav commentedon Nov 24, 2020
I'm not sure I understand exactly what you are proposing to do with
hosts.yml, but I'm going to outline my general thoughts.In a future where we support the XDG basedir spec (I'm sorry @jasonkarns @severen that this didn't make it into our v1.0), I do not feel strongly about
hosts.ymlbeing moved to XDG_DATA_HOME. After all, most of whathosts.ymlholds is host-specific configuration, and as such I feel like it belongs to XDG_CONFIG_HOME.We can weigh the pros vs. cons of storing OAuth tokens in this file, or in DATA vs CONFIG directory, but I believe that ultimately we should move these tokens out of plain text files anyway: #449