Skip to content

gh tries to use hosts.yml after initial boot and fails, then tries keyring and succeeds #8802

@tdhooten

Description

@tdhooten

Describe the bug

Immediately after boot, any attempt to use the gh cli commands fails as unauthorized. Any second attempt always works. This is because gh tries to use hosts.yml initiallity for authorization, and it says the (nonexistent) token is invalid. On second attempts it correctly looks in the system keyring, finds the credentials, and succeeds.

gh version 2.45.0 (1980-01-01)
https://github.com/cli/cli/releases/tag/v2.45.0

OS: NixOS 24.05
DE: KDE Plasma 6.0.1

Steps to reproduce the behavior

  1. Boot system
  2. Run gh auth status once:
❯ gh auth status
github.com
  X Failed to log in to github.com account XXXXXXX (/home/XXXXXXX/.config/gh/hosts.yml)
  - Active account: true
  - The token in /home/XXXXXXX/.config/gh/hosts.yml is invalid.
  - To re-authenticate, run: gh auth login -h github.com
  - To forget about this account, run: gh auth logout -h github.com -u tdhooten
  1. Run gh auth status again:
❯ gh auth status
github.com
  ✓ Logged in to github.com account XXXXXXX (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: gho_************************************
  - Token scopes: 'gist', 'read:org', 'repo', 'workflow'

Expected vs actual behavior

Expected: it should work the first time.
Actual: it only works the second time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcoreThis issue is not accepting PRs from outside contributorsp2Affects more than a few users but doesn't prevent core functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions