fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.98k stars 1.45k forks source link

E900: Invalid channel id (again?) #3573

Closed sbinet closed 1 year ago

sbinet commented 1 year ago

What did you do? (required: The issue will be closed when not provided)

$> cd $TMP
$> mkdir vimgo
$> cd vimgo
$> go mod init vimgo
$> cat > pkg.go << EOF
package vimgo
func F() {
  println("hello")
}
EOF
$> vim pkg.go

when saving or modifying the file one gets the dreaded:

vim-go: initializing gopls
vim-go: initialized gopls
vim-go: Finished loading packages.
Error detected while processing BufWritePre Autocommands for "<buffer=1>"..function go#auto#fmt_autosave[17]..go#fmt#Format[65]..go#fmt#update_file[20]..go#lsp#DidChange[25]..14[43]..17:
line   11:
E900: Invalid channel id
"pkg.go" 5L, 46B written

Configuration (MUST fill this out):

vim-go version:

ec8f05bb

vimrc you used to reproduce:

vimrc ```vim set nocompatible filetype off " set the runtime path to include Vundle and initialize it set rtp+=~/.vim/bundle/vundle/ call vundle#begin() " let Vundle manage Vundle. Plugin 'VundleVim/Vundle.vim' Plugin 'fatih/vim-go' call vundle#end() filetype plugin indent on syntax on "" support for Go "" au FileType go setlocal formatoptions=cqrot1 ai nofoldenable ```

Vim version (first three lines from :version):

NVIM v0.9.1 Build type: Release LuaJIT 2.1.1692616192

Go version (go version):

go version devel go1.22-9aaf5234bf Thu Aug 31 00:56:17 2023 +0000 linux/amd64

Go environment

go env Output:

GO111MODULE=''
GOARCH='amd64'
GOBIN='/home/binet/go/bin'
GOCACHE='/home/binet/.cache/go-build'
GOENV='/home/binet/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/binet/go/pkg/mod'
GOOS='linux'
GOPATH='/home/binet/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/binet/sdk/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/binet/sdk/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.22-9aaf5234bf Thu Aug 31 00:56:17 2023 +0000'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/binet/tmp/vimgo/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1908633782=/tmp/go-build -gno-record-gcc-switches'

gopls version

gopls version Output:

golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=

vim-go configuration:

vim-go configuration
g:go_fmt_command = 'goimports'
g:go_rename_command = 'gopls'
g:go_bin_path = '/home/binet/go/bin'
g:go_template_autocreate = 0
g:go_loaded_gosnippets = 1
g:go_jump_to_error = 1
g:go_loaded_install = 1
g:go_def_mode = 'gopls'
g:go_info_mode = 'gopls'

filetype detection configuration:

filetype detection
filetype detection:ON  plugin:ON  indent:ON
sbinet commented 1 year ago

hum... compiling the same gopls version but with golang/go@c19c4c566c (ie: Go1.21.0) works.

and it would seem that the "invalid channel id" error comes up when compiling gopls with golang/go@5fa4aac0cec637fd9415fb260e3fbc2975377e00

can people reproduce it ?

bhcleek commented 1 year ago

The most common reason for the Invalid channel id error is because gopls has crashed. Given that you can duplicate this with a specific revision of the Go source code, I recommend that you file an issue in github.com/golang/go about it.

sbinet commented 1 year ago

Would you have a set of shell commands that'd replicate the set of vim operations I've sketched above ?

Ie : what does vim-go send to gopls ?

bhcleek commented 1 year ago

You can add let g:go_debug=['lsp'] to see the logs of requests and responses to gopls from vim-go. That may be enough for the gopls team to understand what's going on. Alternatively, they may ask you to use the -logfile option. You can use g:go_gopls_options (see :help g:go_gopls_options) to set it.

However, the very simple reproduction case you've described may be all they need.

sbinet commented 1 year ago

it's a known issue: https://github.com/golang/go/issues/62191