Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installed go for first time $GOHOME not defined, go not in path #34132

Closed
deritchie opened this issue Sep 6, 2019 · 10 comments
Closed

installed go for first time $GOHOME not defined, go not in path #34132

deritchie opened this issue Sep 6, 2019 · 10 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@deritchie
Copy link

deritchie commented Sep 6, 2019

What version of Go are you using (go version)?

$ go version
(base) C02PVMF5G8WP:hello dritchie$ /usr/local/go/bin/go version
go version go1.13 darwin/amd64
(base) C02PVMF5G8WP:hello dritchie$ 

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
(base) C02PVMF5G8WP:hello dritchie$ /usr/local/go/bin/go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dritchie/Library/Caches/go-build"
GOENV="/Users/dritchie/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/dritchie/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/38/3rk6gz9d369954pq2hdy0j48d0g28s/T/go-build833540803=/tmp/go-build -gno-record-gcc-switches -fno-common"
(base) C02PVMF5G8WP:hello dritchie$ 

What did you do?

did the standard 'go build' after creating hello.go in directory /Users/dritchie/go/src/hello
but it didn't find add go to $PATH or create $GOPATH.

(base) C02PVMF5G8WP:hello dritchie$ /usr/local/go/bin/go build
(base) C02PVMF5G8WP:hello dritchie$ hello
hello, world
(base) C02PVMF5G8WP:hello dritchie$ go build
-bash: go: command not found
(base) C02PVMF5G8WP:hello dritchie$ echo $GOPATH

(base) C02PVMF5G8WP:hello dritchie$

What did you expect to see?

a prompt after a successful compile of hello.go

What did you see instead?

could not find the go executable.

Did I miss a step on install? I just installed the go pkg that I downloaded.

@johnaoss
Copy link

johnaoss commented Sep 6, 2019

The installer should have created the PATH entry at /etc/paths.d/go. If that file exists, could you post what it contains? As a temporary fix if it doesn't exist, you can run the following:

echo "/usr/local/go/bin" > /etc/paths.d/go

FWIW I couldn't reproduce this (I'm running macOS Catalina if that's any help).

@deritchie
Copy link
Author

(base) C02PVMF5G8WP:hello dritchie$ more /etc/paths.d/go
/usr/local/go/bin
(base) C02PVMF5G8WP:hello dritchie$

@deritchie deritchie reopened this Sep 6, 2019
@agnivade
Copy link
Contributor

agnivade commented Sep 6, 2019

@deritchie - Please restart your shell for the PATH change to take effect. Let us know if that works.

@agnivade agnivade added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 6, 2019
@deritchie
Copy link
Author

I rebooted the machine (Macbook) and I am still seeing the same issue. Note
that this is a new install of go on this particular laptop.
Note that this machine does have Docker installed and also has xcode tools loaded.
(base) C02PVMF5G8WP:~ dritchie$ echo $GOPATH

(base) C02PVMF5G8WP:~ dritchie$ echo $PATH | grep go
(base) C02PVMF5G8WP:~ dritchie$ bash
bash-3.2$ echo $GOPATH

bash-3.2$ echo $PATH | grep go
bash-3.2$ echo $PATH | grep -i go
bash-3.2$

@deritchie
Copy link
Author

Is there some script that would normally do this setup that would normally be ran as part of the package install? It looks like that may not have ran correctly.

@deritchie
Copy link
Author

let me also ask explicitly... when you say 'restart your shell', are you asking for something that would not occur as a result of a power off/power on of the laptop?

@johnaoss
Copy link

johnaoss commented Sep 6, 2019

@deritchie No, your shell would definitely be restarted with a power off. Can you still not find a go binary on your machine? The only reason I can think of that as to why /etc/paths.d/ isn't being respected is if you're in a non-login shell.

If after restarting and you still can't use the go command, try running:

eval `/usr/libexec/path_helper -s`

And try again. (From: https://apple.stackexchange.com/questions/128897/how-to-use-etc-paths-d-to-add-executable-files-to-my-path). If this works, it's most likely an OS level issue rather than a go specific one.

Additionally, your GOPATH seems to already be in it's default location, so the $GOPATH environment variable doesn't necessarily need to be set, and you can see it already has a value in your go env output. More info: https://golang.org/doc/code.html#GOPATH

@agnivade
Copy link
Contributor

agnivade commented Sep 7, 2019

Hi @deritchie - This sounds like some issue with your shell/machine. I would suggest you to ask for help in one of the forums here:

You will get better help there. This issue tracker is only for tracking bugs and feature proposals.

Thanks

@dolmen
Copy link
Contributor

dolmen commented Sep 9, 2019

MacOS X version is not mentionned.

Otherwise, might be a permission issue?

ls -l /etc/paths.d/go

@agnivade agnivade added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 9, 2019
@andybons
Copy link
Member

As @agnivade mentioned, this seems to be a question and not a bug or feature request for Go itself.

@golang golang locked and limited conversation to collaborators Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants