I have set following path on my ~/.bashrc
file
export GOPATH=/usr/lib/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
But when i installed ATOM IDE and i tried to install go-plus
package, it tired to download something at the end and i got the error that
package github.com/nsf/gocode: cannot download, $GOPATH not set. For more details see: go help gopath
What I am doing wrong ? Here is my ubunt information as well.
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily
P.S
I have already tried setting my
export GOPATH=/home/<username/go
export PATH=$PATH:$GOPATH/bin
Okay guys, I figured out the problem.
https://github.com/joefitzgerald/go-plus/issues/386
here it has been discussed. I will just copy it from that
Linux folks, particularly those running Ubuntu. I believe I have reproduced your issues and I think they have to do with where you are setting your GOPATH
and PATH
.
~/.profile
: If you set them here, $GOPATH
will be set in Atom when you launch Atom for the first time from the launcher in the toolbar
~/.bashrc
If you set them here, $GOPATH
will be set in Atom when you launch Atom for the first time from the terminal Thus, to ensure GOPATH
and PATH
are set correctly regardless of how you launch Atom, you should put the following (or similar) in both ~/.profile
and ~/.bashrc
:
export GOPATH=$HOME/work export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
Obviously the above doesn't apply exactly if bash isn't your default shell, but I trust that if you're a user of a different shell, you can grok what I am saying above and apply the same principles to your particular environment.
I had the same issue on OSX. Weird in my case was that process.env
showed I am using normal bash. This was strange, because I am using zsh. The environment variables overall were wrong and did not match the environment in my terminal at all.
Turned out I needed to set zsh as default shell. This added zsh to the list of known shells and made it the default for my user. Note that xh3b4sd
is my username.
command -v zsh | sudo tee -a /etc/shells
chsh -s $(which zsh) xh3b4sd
After restarting my mac the environment in the output of process.env
was correct and go-plus
worked as expected.