Git Product home page Git Product logo

Comments (19)

shaneHowearth avatar shaneHowearth commented on June 8, 2024

Note: I am on a Raspberry Pi

$ uname -rms
Linux 6.1.21-v8+ aarch64

Which I accept might be a problem :)

from vim-go.

bhcleek avatar bhcleek commented on June 8, 2024

From golang/go#64190, it seems like the issue is that you need to set your go environment correctly. Have you done that and then restarted vim before trying to :GoInstallBinaries godef?

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

As mentioned in this issue, I've set go env "correctly" (keeping in mind that GOHOSTARCH cannot be updated) and I have set the shell env vars, and I have tried setting them when I call vim itself

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

Also note:
GoInstallBinaries produces:

vim-go: godef not found. Installing github.com/rogpeppe/godef@latest to folder /home/shane/go/bin/
vim-go: Error installing github.com/rogpeppe/godef@latest: runtime/cgo
vim-go: # runtime/cgo
vim-go: In file included from _cgo_export.c:4:
vim-go: cgo-gcc-export-header-prolog:31:14: error: size of array ‘_check_for_64_bit_pointer_matching_GoInt’ is negativ
e
vim-go: dlv not found. Installing github.com/go-delve/delve/cmd/dlv@latest to folder /home/shane/go/bin/
vim-go: Error installing github.com/go-delve/delve/cmd/dlv@latest: runtime/cgo
vim-go: # runtime/cgo
vim-go: In file included from _cgo_export.c:4:
vim-go: cgo-gcc-export-header-prolog:31:14: error: size of array ‘_check_for_64_bit_pointer_matching_GoInt’ is negativ
e
vim-go: staticcheck not found. Installing honnef.co/go/tools/cmd/staticcheck@latest to folder /home/shane/go/bin/^C
Command terminated

GoUpdateBinaries godef produces

vim-go: Updating godef. Reinstalling github.com/rogpeppe/godef@latest to folder /home/shane/go/bin/
vim-go: Error installing github.com/rogpeppe/godef@latest: runtime/cgo
vim-go: # runtime/cgo
vim-go: In file included from _cgo_export.c:4:
vim-go: cgo-gcc-export-header-prolog:31:14: error: size of array ‘_check_for_64_bit_pointer_matching_GoInt’ is negativ
e
vim-go: updating finished!
ls ~/go/bin/
asmfmt    fillstruct  golangci-lint  gorename  guru   impl    linux_arm  revive
errcheck  goimports   gomodifytags   gotags    iferr  keyify  motion

And

 $ go install github.com/rogpeppe/godef@latest

Exits without error (presumably that means a successful installation)

edit: Apologies Update wasn't trying to get godef in the short sample time I was running it for this)

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

Trying:

$ GOBIN=~/go/bin GOOS=linux GOHOSTOS=linux GOARCH=arm GOHOSTARCH=arm go install github.com/rogpeppe/godef@latest
go: cannot install cross-compiled binaries when GOBIN is set

but

GOBIN=~/go/bin GOOS=linux GOHOSTOS=linux GOARCH=arm GOHOSTARCH=arm go get -u github.com/rogpeppe/godef@latest
go: downloading 9fans.net/go v0.0.4
go: downloading golang.org/x/sys v0.14.0
go: added 9fans.net/go v0.0.4
go: added github.com/rogpeppe/godef v1.1.2
go: added golang.org/x/mod v0.14.0
go: added golang.org/x/sys v0.14.0
go: added golang.org/x/tools v0.15.0

and still not happening with vim

GOBIN=~/go/bin GOOS=linux GOHOSTOS=linux GOARCH=arm GOHOSTARCH=arm vim cmd/main.go

:GoUpdateBinaries godef
vim-go: Updating godef. Reinstalling github.com/rogpeppe/godef@latest to folder /home/shane/go/bin
vim-go: Error installing github.com/rogpeppe/godef@latest: runtime/cgo
vim-go: # runtime/cgo
vim-go: In file included from _cgo_export.c:4:
vim-go: cgo-gcc-export-header-prolog:31:14: error: size of array ‘_check_for_64_bit_pointer_matching_GoInt’ is negative
vim-go: updating finished!

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

Ok, am resorting to the good old fashioned:

mkdir -p ~/go/src/github.com/rogpeppe
cd $_
git clone https://github.com/rogpeppe/godef.git
cd godef
go build .
mv godef ~/go/bin

GoUpdateBinaries still doesn't work (it's like it cannot see the file), I'll report back if I have any more progress/issues

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

Ok, I gave up trying to get things installed and instead tried to just use it as is.

When I try to start vim I get

"cmd/main.go" 18L, 296B
vim-go: could not determine appropriate working directory for gopls
Press ENTER or type command to continue

That error message pops up again once I enter into the code.

I had gopls installed, via

apt install gopls

but decided to try and install it in

~/go/bin

I cloned https://github.com/golang/tools/tree/master/gopls to ~/go/src/golang.org/x/tools cd into gopls/, and built it with go build ., then moved the resulting binary to ~/go/bin

But get the above error.

FTR

$ which gopls
/home/shane/go/bin/gopls

$ gopls version
golang.org/x/tools/gopls (devel)
    golang.org/x/tools/gopls@(devel)

I see in the vim-go code that the error comes from

call go#util#EchoError('could not determine appropriate working directory for gopls')

But I don't know enough about vim script to be able to debug further (It seems that this line let l:wd = go#util#ModuleRoot() is producing -1, but I don't know what it /should/ be, or why it's getting that value

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

For some reason I was getting an error when I restarted my shell which led me to dependabot/dependabot-core#7895

If I start vim with:

GOTOOLCHAIN="local" vi cmd/main.go

The above gopls error disappears, and I am able to start without error, but if I try to go to the definition I get a gopls error

no package metadata for file file:///path/to/file/I/am/trying/to/edit

Which either comes from
https://github.com/golang/tools/blob/992d98451cb0cd4370c14e54e4262be89e83bfe2/gopls/internal/lsp/source/view.go#L272

or
https://github.com/golang/tools/blob/992d98451cb0cd4370c14e54e4262be89e83bfe2/gopls/internal/lsp/source/rename.go#L307

(I suspect the former as I'm trying to view, not rename/refactor)

from vim-go.

bhcleek avatar bhcleek commented on June 8, 2024

I'm not sure what's going on for sure, but I can imagine a few things.

First, can you please use vim instead of vi so that vim does not start in compatibility mode. Second, can you execute :let g:go_debug=['shell-commands'] before executing :GoInstallBinaries or :GoUpdateBinaries. You can then run :messages to see the shell commands that vim-go is executing.

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

Ok, vim cmd/main.go

"cmd/main.go" 18L, 296B
vim-go: shell command: 'go' 'env' 'GOBIN'
vim-go: shell command: '/usr/local/go/bin/go' 'list'
vim-go: job command: ['/home/shane/go/bin/gopls', '-remote=auto']
vim-go: shell command: '/usr/local/go/bin/go' 'env' 'GOMOD'
vim-go: shell command: '/usr/local/go/bin/go' 'env' 'GOMOD'
vim-go: could not determine appropriate working directory for gopls
Press ENTER or type command to continue

:GoInstallBinaries

vim-go: shell command: 'go' 'env' 'GOHOSTOS'
vim-go: shell command: 'go' 'env' 'GOHOSTARCH'
vim-go: dlv not found. Installing github.com/go-delve/delve/cmd/dlv@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/go-delve/delve/cmd/dlv@latest'
vim-go: Error installing github.com/go-delve/delve/cmd/dlv@latest: /home/shane/go/pkg/mod/github.com/go-delve/delve@v1
.21.2/service/debugger/debugger.go:32:2: found packages native (followexec_other.go) and your_operating_system_is_not_
supported_by_delve (support_sentinel.go) in /home/shane/go/pkg/mod/github.com/go-delve/[email protected]/pkg/proc/native
vim-go: staticcheck not found. Installing honnef.co/go/tools/cmd/staticcheck@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'honnef.co/go/tools/cmd/staticcheck@latest'
vim-go: Error installing honnef.co/go/tools/cmd/staticcheck@latest: go: cannot install cross-compiled binaries when GO
BIN is set
vim-go: installing finished!
Press ENTER or type command to continue

:GoUpdateBinaries

vim-go: Error installing github.com/davidrjenni/reftools/cmd/fillstruct@master: go: cannot install cross-compiled bina
ries when GOBIN is set
vim-go: Updating godef. Reinstalling github.com/rogpeppe/godef@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/rogpeppe/godef@latest'
vim-go: Error installing github.com/rogpeppe/godef@latest: go: cannot install cross-compiled binaries when GOBIN is se
t
vim-go: Updating motion. Reinstalling github.com/fatih/motion@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/fatih/motion@latest'
vim-go: Error installing github.com/fatih/motion@latest: go: cannot install cross-compiled binaries when GOBIN is set
vim-go: Updating errcheck. Reinstalling github.com/kisielk/errcheck@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/kisielk/errcheck@latest'
vim-go: Error installing github.com/kisielk/errcheck@latest: go: cannot install cross-compiled binaries when GOBIN is
set
vim-go: Updating dlv. Reinstalling github.com/go-delve/delve/cmd/dlv@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/go-delve/delve/cmd/dlv@latest'
vim-go: Error installing github.com/go-delve/delve/cmd/dlv@latest: /home/shane/go/pkg/mod/github.com/go-delve/delve@v1
.21.2/service/debugger/debugger.go:32:2: found packages native (followexec_other.go) and your_operating_system_is_not_
supported_by_delve (support_sentinel.go) in /home/shane/go/pkg/mod/github.com/go-delve/[email protected]/pkg/proc/native
vim-go: Updating gorename. Reinstalling golang.org/x/tools/cmd/gorename@master to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'golang.org/x/tools/cmd/gorename@master'
vim-go: Error installing golang.org/x/tools/cmd/gorename@master: go: cannot install cross-compiled binaries when GOBIN
 is set
vim-go: Updating iferr. Reinstalling github.com/koron/iferr@master to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/koron/iferr@master'
vim-go: Error installing github.com/koron/iferr@master: go: cannot install cross-compiled binaries when GOBIN is set
vim-go: Updating gotags. Reinstalling github.com/jstemmer/gotags@master to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/jstemmer/gotags@master'
vim-go: Error installing github.com/jstemmer/gotags@master: go: cannot install cross-compiled binaries when GOBIN is s
et
vim-go: Updating impl. Reinstalling github.com/josharian/impl@main to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/josharian/impl@main'
vim-go: Error installing github.com/josharian/impl@main: go: cannot install cross-compiled binaries when GOBIN is set
vim-go: Updating goimports. Reinstalling golang.org/x/tools/cmd/goimports@master to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'golang.org/x/tools/cmd/goimports@master'
vim-go: Error installing golang.org/x/tools/cmd/goimports@master: go: cannot install cross-compiled binaries when GOBI
N is set
vim-go: Updating golangci-lint. Reinstalling github.com/golangci/golangci-lint/cmd/golangci-lint@latest to folder /hom
e/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/golangci/golangci-lint/cmd/golangc
i-lint@latest'
vim-go: Error installing github.com/golangci/golangci-lint/cmd/golangci-lint@latest: go: cannot install cross-compiled
 binaries when GOBIN is set
vim-go: Updating gomodifytags. Reinstalling github.com/fatih/gomodifytags@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/fatih/gomodifytags@latest'
vim-go: Error installing github.com/fatih/gomodifytags@latest: go: cannot install cross-compiled binaries when GOBIN i
s set
vim-go: Updating keyify. Reinstalling honnef.co/go/tools/cmd/keyify@master to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'honnef.co/go/tools/cmd/keyify@master'
vim-go: Error installing honnef.co/go/tools/cmd/keyify@master: go: cannot install cross-compiled binaries when GOBIN i
s set
vim-go: Updating staticcheck. Reinstalling honnef.co/go/tools/cmd/staticcheck@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'honnef.co/go/tools/cmd/staticcheck@latest'
vim-go: Error installing honnef.co/go/tools/cmd/staticcheck@latest: go: cannot install cross-compiled binaries when GO
BIN is set
vim-go: Updating asmfmt. Reinstalling github.com/klauspost/asmfmt/cmd/asmfmt@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/klauspost/asmfmt/cmd/asmfmt@latest
'
vim-go: Error installing github.com/klauspost/asmfmt/cmd/asmfmt@latest: go: cannot install cross-compiled binaries when GOBIN is set
vim-go: updating finished!
Press ENTER or type command to continue

FTR this is the error I am getting that motivated me to find the GOTOOLCHAIN environment variable

go env |grep -i bin
go: downloading go1.24 (linux/arm64)
go: download go1.24 for linux/arm64: toolchain not available

I cannot find where GOBIN might be set - its not in go env nor my shell

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

I started vim with
GOTOOLCHAIN="local" vim cmd/main.go
and got these errors (it's a sample because there were too much and copy/paste inside tmux isn't flash for me at the minute)

vim-go: Updating fillstruct. Reinstalling github.com/davidrjenni/reftools/cmd/fillstruct@master to folder /home/shane/
go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/davidrjenni/reftools/cmd/fillstruc
t@master'
vim-go: Updating godef. Reinstalling github.com/rogpeppe/godef@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/rogpeppe/godef@latest'
vim-go: Error installing github.com/rogpeppe/godef@latest: runtime/cgo
vim-go: # runtime/cgo
vim-go: In file included from _cgo_export.c:4:
vim-go: cgo-gcc-export-header-prolog:31:14: error: size of array ‘_check_for_64_bit_pointer_matching_GoInt’ is negativ
e
vim-go: Updating motion. Reinstalling github.com/fatih/motion@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/fatih/motion@latest'
vim-go: Updating errcheck. Reinstalling github.com/kisielk/errcheck@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/kisielk/errcheck@latest'
vim-go: Updating dlv. Reinstalling github.com/go-delve/delve/cmd/dlv@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/go-delve/delve/cmd/dlv@latest'

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024
GOTOOLCHAIN="local" go install -v github.com/rogpeppe/godef@latest

and

GOTOOLCHAIN="local" go install -v -mod=mod github.com/rogpeppe/godef@latest

Aren't doing anything either - I think that I will raise that with the Go project

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

I notice that vim-go starts with

vim-go: shell command: 'go' 'env' 'GOHOSTOS'
vim-go: shell command: 'go' 'env' 'GOHOSTARCH'

but I know that GOHOSTARCH is arm64 and cannot be changed to arm - is there a way to get vim-go to use the ENV VARS that I pass/set rather than go env ?

from vim-go.

bhcleek avatar bhcleek commented on June 8, 2024

Vim-go uses go env to get GOHOSTOS and GOHOSTARCH values and then sets GOOS and GOARCH to those values before installing the binaries. Why is your GOHOSTARCH reporting arm64 instead of arm? 🤔 That certainly seems to be the root of this problem, as the arm64 value then causes problems when cgo checks with cgo-gcc-export-header-prolog.

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

I don't know /why/ it's doing that, I only know that it is (and even then I only stumbled on the solution).

The question is, how can I get vim-go to use the supplied values and /not/ the go env values, which I cannot change apparently

from vim-go.

bhcleek avatar bhcleek commented on June 8, 2024

Vim-go doesn't have a way to change that currently, specifically because it's building the binaries for the host system and it needs to override any cross compilation that would otherwise occur when GOOS and GOARCH vary from GOHOSTOS and GOHOSTARCH.

I wonder if disabling cgo might not avoid this for you. Can you try CGO_ENABLED=0 vim and then execute :GoUpdateBinaries?

There seem to be two possible solutions to your difficulties if disabling cgo doesn't work.

First, we could change vim-go so that if GOHOSTARCH is greater than GOARCH, then vim-go would not set GOARCH to GOHOSTARCH. I'm a little hesitant to do that, but perhaps it's worth doing for the arm64 vs arm case because of Raspberry Pi.

The second option is that you can manually build the binaries that are leveraging cgo.

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

Ok, GOTOOLCHAIN="local" CGO_ENABLED=0 vim seems to have produced the desired outcome

vim-go: Updating guru. Reinstalling golang.org/x/tools/cmd/guru@master to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'golang.org/x/tools/cmd/guru@master'
vim-go: Updating gopls. Reinstalling golang.org/x/tools/gopls@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'golang.org/x/tools/gopls@latest'
vim-go: Updating fillstruct. Reinstalling github.com/davidrjenni/reftools/cmd/fillstruct@master to folder /home/shane/
go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/davidrjenni/reftools/cmd/fillstruc
t@master'
vim-go: Updating godef. Reinstalling github.com/rogpeppe/godef@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/rogpeppe/godef@latest'
vim-go: Updating motion. Reinstalling github.com/fatih/motion@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/fatih/motion@latest'
vim-go: Updating errcheck. Reinstalling github.com/kisielk/errcheck@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/kisielk/errcheck@latest'
vim-go: Updating dlv. Reinstalling github.com/go-delve/delve/cmd/dlv@latest to folder /home/shane/go/bin/
vim-go: shell command: '/usr/local/go/bin/go' 'install' '-v' '-mod=mod' 'github.com/go-delve/delve/cmd/dlv@latest

It's completed, but gopls isn't taking me to the definition of chi.NewRouter()

With the error:

vim-go: no package metadata for file file:///home/shane/go/src/github.com/shanehowearth/projectX/api/cmd/main.go

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

I've just discovered that my go.mod was wildly inaccurate - it had a go version of 1.24, but the version on the machine is only 1.21.4 - fixing that seems to have got things working properly now

from vim-go.

shaneHowearth avatar shaneHowearth commented on June 8, 2024

I think that this is solved now

from vim-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.