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

[BUG]: Receiving connection refused in Termux

Open Millesant opened this issue 11 months ago • 5 comments

Thanks for taking the time to fill out this out! :bow: By submitting this issue, you agree to follow our Code of Conduct.

What happened?

What did you do? What happened? What did you expect to happen?

This error below is thrown to stdout when using gh copilot commands in Termux terminal emulator on Android

✗ Error: failed to create thread: error sending request: error making request: Post "https://api.githubcopilot.com/github/chat/threads": dial tcp: lookup api.githubcopilot.com on [::1]:53: read udp [::1]:39758->[::1]:53: read: connection refused

Versions

What versions of the relevant software are you running? For example: gh v2.37.0, gh-copilot v0.5.2-beta

gh version 2.46.0 https://github.com/cli/cli/releases/tag/v2.46.0

gh copilot version 1.0.0 (2024-03-18)

Relevant terminal output

Please copy and paste any relevant terminal output. Please check your output before submission to ensure sensitive information is redacted.

Screenshot_2024-03-22-11-07-28-209_com termux-edit

Millesant avatar Mar 22 '24 14:03 Millesant

Can you run the same command with GODEBUG=netdns=2 in your environment on? I suspect there's something funny happening here around Go's DNS resolution.

williammartin avatar Mar 25 '24 13:03 williammartin

Related comment from the CLI: https://github.com/cli/cli/issues/5723#issuecomment-1141469170

williammartin avatar Mar 25 '24 14:03 williammartin

Can you run the same command with GODEBUG=netdns=2 in your environment on? I suspect there's something funny happening here around Go's DNS resolution.

Sure, here it is Screenshot_2024-03-26-12-52-21-030_com termux

Millesant avatar Mar 26 '24 15:03 Millesant

So I can see from your output that you are using the built in Go DNS resolver. I think you're running into this upstream lack of support for binaries compiled without cgo for Android: https://github.com/golang/go/issues/8877

Right now I'm not really sure what we can do about this on our end. The workarounds on that issue seem to be "patch Go itself" or "point the net Dialer at a specific DNS server". Need to think about this.

williammartin avatar Mar 26 '24 16:03 williammartin

I do not use AI but I saw that this issue was linked with golang/go#8877. I tried reading details about why localhost DNS server is used and writing about it in a comment in another repository, but I do not want to try advertising it. I was thinking some parts of the comment may be relevant as a workaround:

/etc/resolv.conf is usually used when targetting Linux. The DNS server listening at UDP port 53 on IPv6 localhost is probably used when the file cannot be used, but a DNS server is not usually run. Go programs in Termux packages target Android and use $PREFIX/etc/resolv.conf in resolv-conf package. I do not think it will be much useful distributing executable files targetting Android upstream, but proot can be used like this:

pkg install proot resolv-conf
proot -b $PREFIX/etc/resolv.conf:/etc/resolv.conf gh copilot ...

I do not know if a built version of golang package in Termux can be used without a mobile device when distributing executable files targetting Termux upstream. I tried searching a bit but I have not seen Copilot being requested to be distributed as a package in official repository and Termux User Repository yet.

niten94 avatar Sep 07 '24 09:09 niten94