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

cmd/go: GOROOT not being recognized #11227

Closed
jakirkham opened this issue Jun 16, 2015 · 12 comments
Closed

cmd/go: GOROOT not being recognized #11227

jakirkham opened this issue Jun 16, 2015 · 12 comments

Comments

@jakirkham
Copy link

If I run the following go run hello.go ( https://golang.org/doc/install ), I get the following error.

go: cannot find GOROOT directory: /home/vagrant/miniconda/envs/goenv

This directory does exist and go is within bin below this directory. If I explicitly set GOROOT to that directory before running like so GOROOT=/home/vagrant/miniconda/envs/goenv go run hello.go, I get the expected result.

hello, world

The only line that I could expect would cause this issue is here (

fmt.Fprintf(os.Stderr, "go: cannot find GOROOT directory: %v\n", goroot)
). If I run stat on the directory like so stat /home/vagrant/miniconda/envs/goenv, I get this result.

  File: `/home/vagrant/miniconda/envs/goenv'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd02h/64770d    Inode: 3937024     Links: 9
Access: (0775/drwxrwxr-x)  Uid: (  500/ vagrant)   Gid: (  500/ vagrant)
Access: 2015-06-15 23:24:57.320138356 +0000
Modify: 2015-06-15 23:24:57.663046317 +0000
Change: 2015-06-15 23:24:57.663046317 +0000

I have reproduced this error on Mac and Linux. Any thoughts or suggestions as to why this is happening? For the record, this my first day with go so assume I know nothing. :)

@davecheney
Copy link
Contributor

You don't need to set GOROOT. Instead, unpack the source code to
/home/vagrant/...blah, cd into src/ then run all.bash. once that is
complete add /home/vagrant/...blah/bin to your PATH and you are done.

Sorry for the elided paths, phone

On Tue, 16 Jun 2015 10:04 jakirkham notifications@github.com wrote:

If I run the following go run hello.go ( https://golang.org/doc/install
), I get the following error.

go: cannot find GOROOT directory: /home/vagrant/miniconda/envs/goenv

This directory does exist and go is within bin below this directory. If I
explicitly set GOROOT to that directory before running like so GOROOT=/home/vagrant/miniconda/envs/goenv
go run hello.go, I get the expected result.

hello, world

The only line that I could expect would cause this issue is here (

fmt.Fprintf(os.Stderr, "go: cannot find GOROOT directory: %v\n", goroot)

). If I run stat on the directory like so stat
/home/vagrant/miniconda/envs/goenv, I get this result.

File: `/home/vagrant/miniconda/envs/goenv'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd02h/64770d Inode: 3937024 Links: 9
Access: (0775/drwxrwxr-x) Uid: ( 500/ vagrant) Gid: ( 500/ vagrant)
Access: 2015-06-15 23:24:57.320138356 +0000
Modify: 2015-06-15 23:24:57.663046317 +0000
Change: 2015-06-15 23:24:57.663046317 +0000

I have reproduced this error on Mac and Linux. Any thoughts or suggestions
as to why this is happening? For the record, this my first day with go so
assume I know nothing. :)


Reply to this email directly or view it on GitHub
#11227.

@adg
Copy link
Contributor

adg commented Jun 16, 2015

What does go env print?

@jakirkham
Copy link
Author

go env will make the same complaint unless I have set GOROOT, in which case I get the following.

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/home/vagrant/miniconda/envs/goenv"
GOTOOLDIR="/home/vagrant/miniconda/envs/goenv/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

@ianlancetaylor ianlancetaylor changed the title Strange problem with GOROOT not being recognized cmd/go: Strange problem with GOROOT not being recognized Jun 16, 2015
@jakirkham
Copy link
Author

@davecheney, the all.bash sounded like a good idea, but that did not seem to go well. I got something that looked like this.

# Building C bootstrap tool.
cmd/dist
go tool dist: FAILED: git rev-parse --abbrev-ref HEAD

@davecheney
Copy link
Contributor

@jakirkham unless you absolutely need to build tip, I recommend sticking with the source tarball from the website to try to limit the problems you have in your environment.

@jakirkham
Copy link
Author

Maybe this might help, how does goroot get set in src/cmd/go/main.go? It doesn't appear to be set anywhere. Does it get spliced in somehow?

@jakirkham
Copy link
Author

I did indeed pick a tar ball ( http://storage.googleapis.com/golang/go1.4.2.src.tar.gz ).

@davecheney
Copy link
Contributor

@jakirkham this might be a more appropriate thread for the mailing list, the issue tracker is discouraged as a general support conduit.

@jakirkham
Copy link
Author

Ok, sorry, where should I go then?

@davecheney
Copy link
Contributor

https://groups.google.com/forum/#!forum/golang-nuts

To be clear, you're welcome to raise bugs on the issue tracker, but side conversations about how GOROOT is set are best addressed in the mailing list.

@rsc rsc changed the title cmd/go: Strange problem with GOROOT not being recognized cmd/go: GOROOT not being recognized Jun 16, 2015
@rsc
Copy link
Contributor

rsc commented Jun 16, 2015

Please try two things:

First:

env | grep GOROOT | hexdump -C

Second:

cat >/tmp/x.go <<EOF
package main

import (
    "fmt"
    "runtime"
)

func main() {
    fmt.Printf("GOROOT=%q\n", runtime.GOROOT())
}
EOF

GOROOT=/home/vagrant/miniconda/envs/goenv go build /tmp/x.go
GOROOT="" ./x
./x

If you're using a distributed tar file, I don't understand how it is getting to the "right" GOROOT but not quite. The only thing I can think of is that you do have a GOROOT set, but it has some kind of invisible characters in it. Running the explicit GOROOT=... go run form overrides the not-quite-right GOROOT.

@jakirkham
Copy link
Author

So, I think I have fixed what was causing this problem, but it has resulted in a new problem. As a result, I will open it in a new issue. Thanks for everyone's help.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants