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
config.yml
is opened for writing on gh auth switch
when it should not be
#8496
Comments
I can reproduce the file opening behavior that you mentioned, but..
..it seems that the switch action doesn't actually go through, thus matching the error message. 98% ~ ❯ gh auth token
gho_redacted5sh
(base)
98% ~ ❯ gh auth switch
X Failed to switch account for github.com to arunsathiya
open /Users/arun/.config/gh/hosts.yml: operation not permitted
(base)
98% ~ ❯ gh auth token
gho_redacted5sh We can notice that both tokens end in 5sh, thus indicating the same account. |
Ah, in my (and most I can reproduce the same thing you did if |
Interesting. I have been using keyring/keychain for secure storage, so I was not familiar with When I used |
Hey, thanks for opening this issue and sorry for the inconvenience and delay (catching up on issues that need triage after the holidays). I can reproduce this on Mac:
This is definitely a bug and I will look into it. As you noted, it shouldn't actually result in any functional problem because well, the
The historical reason for the split as far as I know is that it should be possible to put the config in version control without worrying about tokens being committed. I don't know if that's true or not as no one from the team is still around 😬 |
Actually there is a bug here as well because the rollback logic in case of error leaves things in an inconsistent state. The problem is that the hosts file has been persisted while the config file hasn't. Thus the
I've upgraded this to a |
As far as I can tell this has been an issue for a long long time for any command that made changes to the
This change coincided with cli/go-gh#44 which moved config management from But the thing is that it appears to me as if the general node is marked as modified if there is a hosts file: Here's a test that demonstrates this incorrect behaviour:
|
Created cli/go-gh#147 to address this. |
That PR has been merged, so when we ship a new version of |
Describe the bug
Certain commands, like
gh auth switch
, appear to fail entirely with an error failing to open theconfig.yml
when it is immutable (i.e. when using home-manager):However, they do not actually fail, and the account is switched. This error is rather misleading, because I thought this was a fatal error at first and the account switch didn't happen when it did, and I don't believe that
config.yml
should ever be opened in situations like this where it never is touched at all.This occurs on
gh version 2.40.1
.Steps to reproduce the behavior
config.yml
immutable. (chattr +i ~/.config/gh/config.yml
for testing)gh auth switch
Expected vs actual behavior
I expected the account to be switched without errors like this, and the
config.yml
to not be opened for writing at all.Logs
The text was updated successfully, but these errors were encountered: