gh-copilot icon indicating copy to clipboard operation
gh-copilot copied to clipboard

[BUG]: HTTPS_PROXY not work with copilot CLI

Open Dennis3453 opened this issue 1 year ago โ€ข 4 comments

What happened?

gh copilot explain & suggest not using HTTPS_PROXY. Other gh commands are okay (auth, search, status, etc)

Edited: The issue happened inside WSL ubuntu terminal, copilot cli works on Windows CMD

Versions

What versions of the relevant software are you running? gh-copilot version 1.0.2 (2024-04-26) gh version 2.49.0 (2024-04-30) https://github.com/cli/cli/releases/tag/v2.49.0

Relevant terminal output

$ gh copilot explain "sth"
โœ— Error: failed to create thread: error sending request: error making request: Post "https://api.githubcopilot.com/github/chat/threads": Proxy Authorization Required

Dennis3453 avatar May 08 '24 03:05 Dennis3453

@Dennis3453 : thank you for opening this issue and apologies for the trouble! ๐Ÿ™‡

Edited: The issue happened inside WSL ubuntu terminal, copilot cli works on Windows CMD

Few questions for you:

  1. What version on Windows and Ubuntu?

  2. Is WSL being used through Visual Studio Code or terminal?

  3. What happens when you set the following environment variables and use the extension?

    export HTTP_PROXY="127.0.0.1:3128"
    export HTTPS_PROXY="127.0.0.1:3129"
    export http_proxy="127.0.0.1:3130"
    export https_proxy="127.0.0.1:3131"
    

    When I do this through VS Code on a WSL vm, I can see that the conventional environment variables are picked up in the following order:

    1. HTTPS_PROXY
    2. HTTP_PROXY
    3. https_proxy
    4. http_proxy
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 22.04.2 LTS
    Release:        22.04
    Codename:       jammy
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export HTTP_PROXY="127.0.0.1:3128"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export HTTPS_PROXY="127.0.0.1:3129"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export http_proxy="127.0.0.1:3130"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export https_proxy="127.0.0.1:3131"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ GH_DEBUG=api gh copilot suggest -t shell how to setup a proxy server on Windows 11
    * Request at 2024-05-13 09:48:46.430815229 -0400 EDT m=+0.125775764
    * Request to https://api.githubcopilot.com/github/chat/threads
    > POST /github/chat/threads HTTP/1.1
    > Host: api.githubcopilot.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: Bearer โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
    > Content-Length: 2
    > Content-Type: application/json
    > Time-Zone: America/New_York
    > User-Agent: go-gh
    > X-Github-Api-Version: 2023-07-07
    
    {}
    
    * Request at 2024-05-13 09:48:46.430940644 -0400 EDT m=+0.125901186
    * Request to https://api.github.com/repos/github/gh-copilot/releases/latest
    > GET /repos/github/gh-copilot/releases/latest HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
    > Content-Type: application/json; charset=utf-8
    > Time-Zone: America/New_York
    > User-Agent: go-gh
    
    * proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused
    * Request took 139.721ยตs
    * proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused
    * Request took 278.711ยตs
    
    โœ— Error: failed to create thread: error sending request: error making request: Post "https://api.githubcopilot.com/github/chat/threads": proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused
    

andyfeller avatar May 13 '24 13:05 andyfeller

  1. What version on Windows and Ubuntu? OS Name Microsoft Windows 11 Pro Version 10.0.22631 Build 22631 Ubuntu 20.04.6 LTS (GNU/Linux 5.15.150.1-microsoft-standard-WSL2 x86_64)

  2. WSL use through terminal

  3. What happens when you set the following environment variables and use the extension? โœ— Error: failed to create thread: error sending request: error making request: Post "https://api.githubcopilot.com/github/chat/threads": proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused

Dennis3453 avatar May 28 '24 06:05 Dennis3453

I can use gh copilot now by setting HTTPS_PROXY instead of https_proxy. Thanks.

Dennis3453 avatar May 28 '24 06:05 Dennis3453

@Dennis3453: do you have any ideas beyond a small mention in the README about setting HTTPS_PROXY env var to avoid the impact for the next person?

This isn't the first time I've ran into issues with CLIs in general in environments that require use of a proxy. These variables aren't CLI specific, which is generally why every CLI tools doesn't document their use. That said, I'd like to figure out the right amount of info to help the next person.

Does this affect any other CLIs you work with?

andyfeller avatar Jun 03 '24 21:06 andyfeller