Skip to content

gh auth ignores the http_unix_socket config value #11891

Description

@drevell

Describe the bug

gh has an option "http_unix_socket" that should route HTTP requests through the provided unix domain socket. In some places, that option is ignored where it should be used.

Fix PR

I sent you a PR with an attempted fix in #11890

Affected version

2.80.0

Steps to reproduce the behavior

Run gh auth login with the http_unix_socket option set, and watch it be ignored for outgoing HTTP requests.

Expected vs actual behavior

Device flow authentication should be possible when using http_unix_socket. gh should not bypass the socket and make HTTP requests directly (should not bypass the proxy).

Logs

Paste the activity from your command line. Redact if needed.

$ GH_CONFIG_DIR=$HOME/gh_config gh config list
...redacted...
http_unix_socket=/<redacted>/ggh-1760032788919400188.sock
$ GH_CONFIG_DIR=$HOME/gh_config GH_DEBUG=api gh auth login -h <redacted>
? What is your preferred protocol for Git operations on this host? HTTPS
[git config credential.https://<redacted>]
[git config credential.helper]
? Authenticate Git with your GitHub credentials? No
? How would you like to authenticate GitHub CLI? Login with a web browser
<at this point the gh CLI starts talking directly to the GHES server when it should use the http_unix_socket>
* Request at 2025-10-09 12:15:39.622283804 -0700 PDT m=+5.062799595
* Request to https://<redacted>/login/device/code
> POST /login/device/code HTTP/1.1
> Host: <redacted>
> Content-Length: 57
> Content-Type: application/x-www-form-urlencoded

...redacted...

Activity

  1. babakks commented on Oct 10, 2025

    @babakks
    Member

    Hi @drevell! Thanks for reporting and making a PR for it! 🍻

    I looked into the internals of how gh instantiates HTTP clients, and I can confirm what you're seeing as a bug. As I checked, only the auth login command is affected and other commands should work as expected.

    Regarding the PR, while I appreciate your time for making it, I'm going to close it as it's duplicating the code in cli/go-gh, which is a base module used by gh and extensions that takes care of fundamental/cross-cutting concerns.

    I'm working on a fix for this issue, but in the meantime I need to know if the PR you made resolves your issue with auth login.

    Also, I don't know how things are set up at your end, but since you mentioned proxy, I'm curious to know if you have tried setting HTTPS_PROXY env var. Sorry, if that's inapplicable to your use case, but I'm asking in case there's already a solution to unblock you.

  2. added
    priority-2Affects more than a few users but doesn't prevent core functions
    gh-authrelating to the gh auth command
    and removed on Oct 10, 2025
  3. self-assigned this
    on Oct 10, 2025
  4. drevell commented on Oct 10, 2025

    @drevell
    Author

    Thank you Babak, I understand that it doesn't make sense to use my PR when there's existing logic in a library for this. Thanks for taking the time to understand what's going on.

    Thanks for the suggestion of HTTPS_PROXY. For our particular use case, we really want to use the http_unix_socket rather than HTTPS_PROXY (we're certainly aware of that option). The reasons are obscure and corporate and have to do with the limitations of the quirky proxy we're required to use.

  5. babakks commented on Oct 13, 2025

    @babakks
    Member

    @drevell I've just submitted a PR for this. While it's waiting for review, can you please clone the PR branch, build from source, and verify it fixes the issue?

    I've already added the steps to verify the behaviour, but since you already have a working setup, I think you wouldn't need it. However, you can go through the same commands/experiences to make sure all is okay.

  6. drevell commented on Oct 14, 2025

    @drevell
    Author

    The fix works for me. The bug was preventing us from using the OAuth "device flow." With the fix, it now works.

    $ gh auth login
    ? What is your preferred protocol for Git operations on this host? SSH
    ? Upload your SSH public key to your GitHub account? Skip
    ? How would you like to authenticate GitHub CLI? Login with a web browser
    
    ! First copy your one-time code: <redacted>
    Press Enter to open https://<redacted>/login/device in your browser...
    [<redacted>] Missing X server or $DISPLAY
    [<redacted>] The platform failed to initialize.  Exiting.
    
    ...<at this point I copy-paste the above URL into my browser and complete the login flow>...
    
    ✓ Authentication complete.
    - gh config set -h <redacted> git_protocol ssh
    ✓ Configured git protocol
    ! Authentication credentials saved in plain text
    ✓ Logged in as revell
    ! You were already logged in to this account
    
  7. babakks commented on Oct 15, 2025

    @babakks
    Member

    The changes will be shipped in the upcoming release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggh-authrelating to the gh auth commandpriority-2Affects 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