fatih / vim-go

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

vim.go: $GOPATH is not set #86

Closed ghost closed 10 years ago

ghost commented 10 years ago

@fatih I have installed vim-go as instructed in the github repo using pathogen.But every time i try to open vim it shows message displaying vim.go: $GOPATH is not set Press ENTER or type command to continue

Plus vim-go plugin didn't work with vim also.

juanolon commented 10 years ago

i got the same issue. first, defining GOPATH on my .zshrc file didn't help until i kill tmux and restart iterm. the next time i opened vim, it start installing the binaries as expected..

ghost commented 10 years ago

@juanolon I have bash and i am not using tmux for now.I have simple terminal as default by OS.Any other way i can get through problem you know?

juanolon commented 10 years ago

mmh well, the only thing i did, was setting GOPATH and restarting everything ^^ but i guess, you already define the $GOPATH variable on bashrc, right? see here: http://golang.org/doc/code.html#GOPATH

ghost commented 10 years ago

Yes i have done by following command.

export GOPATH=$HOME/golang export PATH=$PATH:$GOPATH/bin

even i installed mercurial for it.

fatih commented 10 years ago

Hey, what shell are you using? Without GOPATH you are going to experience a bad experience with the plugin. You can disable autoinstall if you want, but remember that is a bad idea:

  let g:go_disable_autoinstall = 1
ghost commented 10 years ago

I am using bash shell.And every time i set GOPATH after restart it goes way and even i tried to put the GOPATH in .bashrc.After that it tries to download but so download fail.

fatih commented 10 years ago

Yeah but really that's not a plugin error. vim-go only tries to read the value from the environment. I think there is a fundamental problem with your environment. An environment variable shouldn't be get lost when you restart your machine.

ghost commented 10 years ago

Yes.But till termial is live the packages start to download and gives list of errors

fatih commented 10 years ago

What are the errors ? Probably you see them because there is no GOPATH available.

ghost commented 10 years ago

Ya after setting up GOPATH when i try to load vim it says.. Installing github.com/nsf/gocode Error installing github.com/nsf/gocode: Installing code.google.com/p/go.tools/cmd/goimports

and the message keeps up going on with error.

ghost commented 10 years ago

@fatih Any idea how could i solve above problem?

casimir commented 10 years ago

Is there any error when you try something like go get -v github.com/nsf/gocode in your terminal?

ghost commented 10 years ago

Yes ....

github.com/nsf/gocode (download) cd .; git clone https://github.com/nsf/gocode /home/travis/golang/src/github.com/nsf/gocode Cloning into '/home/travis/golang/src/github.com/nsf/gocode'... fatal: unable to access 'https://github.com/nsf/gocode/': Failed connect to github.com:4242; Connection timed out package github.com/nsf/gocode: exit status 128

ghost commented 10 years ago

Ok these problem was due to my proxy setting i got that but only few packages got installed and some didn't why so @casimir

Installing github.com/nsf/gocode Installing code.google.com/p/go.tools/cmd/goimports Error installing code.google.com/p/go.tools/cmd/goimports: Installing code.google.com/p/rog-go/exp/cmd/godef Installing code.google.com/p/go.tools/cmd/oracle Error installing code.google.com/p/go.tools/cmd/oracle: Installing github.com/golang/lint/golint Installing github.com/kisielk/errcheck Error installing github.com/kisielk/errcheck: Installing github.com/jstemmer/gotags Press ENTER or type command to continue

casimir commented 10 years ago

Do you use some custom ssh config? Like in ~/.ssh/config. Sometimes you just configure a custom port or domain alias that change the default behavior and just forget it (I plead guilty...) Anyway you can get every package by hand once and for all with go get -v <package>. The silver lining here is that you can diagnose problems more easily this way.

ghost commented 10 years ago

Yup i treid doing on of the link..... go get -v code.google.com/p/go.tools/cmd/goimports

code.google.com/p/go.tools/astutil code.google.com/p/go.tools/astutil ../../code.google.com/p/go.tools/astutil/enclosing.go:434: n.Lparen undefined (type ast.TypeAssertExpr has no field or method Lparen) ../../code.google.com/p/go.tools/astutil/enclosing.go:435: n.Lparen undefined (type ast.TypeAssertExpr has no field or method Lparen) ../../code.google.com/p/go.tools/astutil/enclosing.go:436: n.Rparen undefined (type *ast.TypeAssertExpr has no field or method Rparen)

casimir commented 10 years ago

Which version of go are you using? At least 1.2 might be needed.

bobishh commented 10 years ago

For those of you who still having this: I had encountered the same problem, and in my case the reason for that error was invalid exports of vars - I use fish-shell and used 'set GOPATH blablabla' instead of 'set -x GOPATH blablabla'.

You can check environment vars with env or go env (for go vars) to find a way to export it correctly. I simply switched to bash and exported it as usual, and then realized what I was doing wrong.

Slava commented 10 years ago

@bobishh Thanks Bogdan, your advice worked perfectly for someone who had problems with this plugin + fish shell. Even though I had 'bash' as my set shell for vim (in .vimrc), it looks like vim-go looks up GOPATH from the parent shell.

patrickocoffeyo commented 10 years ago

@bobishh :+1: Thank you, your comment was very helpful.

mildred commented 8 years ago

I'm having the same problem and I set my GOPATH in my shell initialisation files using backticks. When I run :echo $GOPATH I get the value I expect. However vim-go still tells me $GOPATH not set.

edit: my issue was that the script I was invoking had a bu that caused it to return an empty string on some occurrences. I debugged it by using the standard error output.

heipacker commented 8 years ago

i encounter thiis problem too, but when i config the GOBIN var, this solved.

netdigger commented 8 years ago

In fact, user should use "export GOPATH=xxxx" in ~/.profile to set GOPATH. If you use "GOPATH=xxxx" and run echo $GOPATH, you can get the expect value, but vim-go can't get GOPATH

bpo217 commented 7 years ago

@netdigger This is important, and I didn't catch it for a while... But this was my problem initially. If you don't do this there is some strange behavior with $GOPATH in vim.

rcdosado commented 6 years ago

i did what netdigger had advised but still it doesnt work, here are my go environment vars: GOARCH="amd64" GOBIN="/usr/bin/go" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/m1k3y/go" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build731985509=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" is there a step by step proper installation of this?

arp242 commented 6 years ago

You'll need to be clearer than "it doesn't work" @rcdosado. What did you do? What "doesn't work"?

Also note that a few things have changed since this issue was first created. $HOME/go is now used as GOPATH if it's not explicitly set, and you don't need to set GOPATH yourself anymore.

zipizap commented 6 years ago

The error vim.go: $GOPATH is not set and 'go env GOPATH' returns empty happened to me too when trying ":GoInstallBinaries" I am not certain that my vim installation is in good shape, and I have go via a snap package in ubuntu 18.04 What seemed to make it work, was to:

Just sharing the experience

arumals commented 5 years ago

The error vim.go: $GOPATH is not set and 'go env GOPATH' returns empty happened to me too when trying ":GoInstallBinaries" I am not certain that my vim installation is in good shape, and I have go via a snap package in ubuntu 18.04 What seemed to make it work, was to:

  • exit tmux or screen
  • in a bash session, call vim with GOPATH=$HOME/go vim - and then :GoInstallBinaries worked this time

Just sharing the experience

This worked for me.