Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go install: no install location for directory outside GOPATH

Tags:

path

macos

go

I installed the Go, then added path requirements to my .bash_profile:

  • export PATH=$PATH:/usr/local/go/bin
  • export GOPATH=$HOME/go

I then setup the correct folders:

Folders

I also created a projected called tire. The contents for main.go are simply:

package main  import "fmt"  func main() {   fmt.Println("Hello, world!") } 

I always get the following error when I try to run go install:

go install: no install location for directory /Users/Daryl/go/src/tire outside GOPATH

Here's what I get when I run go env:

GOARCH="amd64" GOBIN="" GOCHAR="6" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/daryl/go" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" TERM="dumb" CC="clang" GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fno-common" CXX="clang++" CGO_ENABLED="1" 

Any help would be appreciated.

like image 897
daryl Avatar asked Oct 01 '14 05:10

daryl


Video Answer


2 Answers

When you run go install Go looks for $GOBIN env variable path. Either you need to set your $GOBIN to $GOPATH/bin

$ export GOBIN=$GOPATH/bin 

and/or add $GOBIN to your OS search path

$ export PATH=$PATH:$GOBIN 

To use the command without getting the error.

like image 131
Pandemonium Avatar answered Sep 19 '22 04:09

Pandemonium


The problem was as James Henstridge commented, for some reason there was an issue with my user directory name case. Even though the directory is lowercase, I had to make it capitalized.

This worked:

GOPATH=/Users/Daryl/go

This didn't:

GOPATH=$HOME/go

However, since moving to a rMBP from my iMac, I had no problems whatsoever setting up Go, so, to this day, I'm not sure what was going on, but in that instance the capitalization fixed it.

like image 38
daryl Avatar answered Sep 19 '22 04:09

daryl