termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.33k stars 3.07k forks source link

[Bug]: Go LSP displays bad sys call error in helix #21034

Closed n-ce closed 3 months ago

n-ce commented 3 months ago

Problem description

I just got started with programming in go, and followed this https://github.com/helix-editor/helix/wiki/Language-Server-Configurations#go for installation with helix. This is only complication that occured during the installation of go tooling.

go: downloading github.com/sourcegraph/jsonrpc2 v0.0.0-20191222043438-96c4efab7ee2
golangci/golangci-lint info checking GitHub for tag 'v1.59.1'
sh: 288: jq: not found
golangci/golangci-lint info found version: 1.59.1 for v1.59.1/linux/arm64
golangci/golangci-lint info installed /data/data/com.termux/files/home/go/bin/golangci-lint

However I am welcomed with this error on my first program.

Screenshot_20240803-123336

What steps will reproduce the bug?

What is the expected behavior?

No LSP error messages on a blank program.

System information

Termux Variables:
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=6901
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirror.albony.in/termux/termux-main stable main
Updatable packages:
All packages up to date
termux-tools version:
1.43.2
Android version:
14
Kernel build information:
Linux localhost 5.15.123-android13-8-00042-g3c19baf38bc8-ab11190960 #1 SMP PREEMPT Thu Dec 7 10:47:52 UTC 2023 aarch64 Android
Device manufacturer:
motorola
Device model:
moto g04
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
TomJo2000 commented 3 months ago

We have a gopls package available for Termux, are you using that or are you compiling it yourself?

n-ce commented 3 months ago

We have a gopls package available for Termux, are you using that or are you compiling it yourself?

I was using go install golang.org/x/tools/gopls@latest as per helix instructions and now I did rm -r ~/go/bin/gopls and pkg install gopls but the issue remains.

one more thing to consider is fprintln not working as expected Screenshot_20240803-130652 IMG_20240803_131020

TomJo2000 commented 3 months ago

one more thing to consider is fprintln not working as expected

That would be an issue with Golang itself, no?

licy183 commented 3 months ago

This is only complication that occured during the installation of go tooling.

go: downloading github.com/sourcegraph/jsonrpc2 v0.0.0-20191222043438-96c4efab7ee2
golangci/golangci-lint info checking GitHub for tag 'v1.59.1'
sh: 288: jq: not found
golangci/golangci-lint info found version: 1.59.1 for v1.59.1/linux/arm64
golangci/golangci-lint info installed /data/data/com.termux/files/home/go/bin/golangci-lint

Termux is based on Bionic libc. faccessat2 syscall is banned by SELinux due to security issue [1]. It seems that golangci/golangci-lint is downloaded from GitHub Release rather than complied on device, so it's normal that it doesn't work properly on Android.

one more thing to consider is fprintln not working as expected

The prototype of fmt.Fprintln is func Fprintln(w io.Writer, a ...any) (n int, err error), so this is an expected behavior. You probably want fmt.Println.

[1] https://github.com/golang/go/blob/master/src/syscall/syscall_linux.go#L166C52-L167C70

truboxl commented 3 months ago

https://github.com/golangci/golangci-lint/blob/master/install.sh#L193-L238

The install script does not properly detect OS in uname_os() leading to download linux/arm64 version. Ask upstream to fix their script and also provide the android/arm64 binary in their releases page.

For now you have to build manually instead of follow the instructions.

n-ce commented 3 months ago

The syscall issue seems to have been fixed after a restart. I am not sure but I think the gopls local pkg might have solved this but was in conflict with the previous installation which a restart cleared. I will re-open in case this surfaces back. And any complications with golangci/golangci-lint will have to be opened in a new issue preferably in the source repo itself.

TomJo2000 commented 3 months ago

I suspect building gopls from source with default compiler flags misses some options needed to make it work on Termux. It being fixed after a restart might have something to do with the old version still being active in the backround, but that is just conjecture.

n-ce commented 3 months ago

For now you have to build manually instead of follow the instructions.

Is there a tutorial anywhere on building from source?

Screenshot_20240803-190738_1 Anyways, It seems to be working which is why I guess no android user's been complaining about it.