-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
gh auth login
hangs when config.yml
is read-only, potentially producing an "auth schism"
#8357
Comments
Yeh the confusion here stems from the fact that cli/pkg/cmd/auth/shared/login_flow.go Line 159 in 06e438b
In the case of cli/pkg/cmd/auth/refresh/refresh.go Line 198 in 06e438b
Perhaps the simplest thing to do to remove the confusion is just to move that message out of the login flow and into the login command. With regards the hang, I need to do some investigation. I'm surprised there is a hang rather than an error? For example, in #7360 there is an |
Did more investigation about the hang. When experiencing the hang, I was using the packaged I can repro the hang using 2.29.0, with both the distro's binary and the binary provided on the release download page. However, with 2.39.1, I get a proper error message, again both with the distro's unstable binary as well as with the binary from the release page: $ ./gh auth login
? What account do you want to log into? GitHub.com
? You're already logged into github.com. Do you want to re-authenticate? Yes
? What is your preferred protocol for Git operations? SSH
? Generate a new SSH key to add to your GitHub account? No
? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org'.
? Paste your authentication token: ****************************************
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
open /home/twieczorek/.config/gh/config.yml: read-only file system I also tried strace, but there's not much enlightening in there, at least not for me. And in the end, the hang is no longer happening in current versions, so it doesn't really matter 🤷 🙂. strace on v2.29.0 after pasting the token and hitting enter
|
Thanks for investigation, nothing obvious in the With this new error, it maybe is also clearer that something in fact went wrong even if it says |
Yeah. The only thing remaining is the weird outcome that |
Right, I forgot about that. Would it be possible for you to double check for me if that is still the case in the latest version? By that I mean, logging out and then going through the log in process again, seeing it fail on I can't quite see how that would happen in the latest as the |
This can be triggered by simply removing the $ ./gh version
gh version 2.39.1 (2023-11-14)
https://github.com/cli/cli/releases/tag/v2.39.1
$ ./gh auth status
github.com
✓ Logged in to github.com as twz123 (keyring)
✓ Git operations for github.com configured to use ssh protocol.
✓ Token: gho_************************************
✓ Token scopes: gist, read:org, repo
$ mv ~/.config/gh/hosts.yml ~/.config/gh/hosts.yml.foo
$ ./gh auth status
You are not logged into any GitHub hosts. Run gh auth login to authenticate.
$ ./gh auth login
? What account do you want to log into? GitHub.com
? You're already logged into github.com. Do you want to re-authenticate? (y/N)
^C
$ GH_TOKEN=$(./gh auth token) ./gh auth status
github.com
✓ Logged in to github.com as twz123 (GH_TOKEN)
✓ Git operations for github.com configured to use https protocol.
✓ Token: gho_************************************
✓ Token scopes: gist, read:org, repo
|
Thanks for the extra investigation, super valuable. Yeh, I understand how this would occur if the |
Describe the bug
When
config.yml
is read-only,gh auth login
hangs indefinitely after having stored the token in secure storage and printing✓ Authentication complete.
This can cause some confusion for users, as described in the linked discussion below.Steps to reproduce the behavior
Expected vs actual behavior
hosts.yml
)gh
, as some parts of the CLI claim authentication is done while others ask for credentials.Logs
None.
The text was updated successfully, but these errors were encountered: