Closed benbarbour closed 6 years ago
Unfortunately godoc gets confused by the symlinks in $GOROOT. The debian packaging of godoc carries a patch that hacks around this, I guess some kind of better solution would be, well, better.
Hmmm... in the meantime, could you point me to the patch and/or package with the fix? Might help other people searching for this bug too.
Here's a partially functioning workaround for anyone who cares.
If I run godoc -http=":8080 -goroot /usr/share/go
(where /usr/share/go is the path that some of the symlinks in GOROOT point to) the server starts. It can't find the "Documents" page so I can't view "Effective Go" and friends locally, but at least I can navigate around package docs, including my own packages.
I got this working by removing the docs symlink and taking a copy of the docs source..
in /usr/lib/go-1.6
sudo mv doc doc.old
sudo cp -ra ../../share/doc/golang-1.6-doc/html doc
CL https://golang.org/cl/45096 mentions this issue.
Repro instructions:
$ mkdir $HOME/gorootsym_under
$ cd $HOME/gorootsym_under
$ ln -s $GOROOT/bin
$ ln -s $GOROOT/src
$ ln -s $GOROOT/pkg
$ ls -l $HOME/gorootsym_under/
total 0
lrwxrwxrwx 1 bradfitz bradfitz 21 Jul 14 19:06 bin -> /home/bradfitz/go/bin
lrwxrwxrwx 1 bradfitz bradfitz 21 Jul 14 19:06 pkg -> /home/bradfitz/go/pkg
lrwxrwxrwx 1 bradfitz bradfitz 21 Jul 14 19:06 src -> /home/bradfitz/go/src
$ GOROOT=$HOME/gorootsym_under GOPATH= godoc -http=:6060 -v
2017/07/14 19:06:44 godoc: corpus fstree is nil
Change https://golang.org/cl/53634 mentions this issue: godoc: don't try to follow all symlinks
Change https://golang.org/cl/57870 mentions this issue: [release-branch.go1.9] godoc: don't try to follow all symlinks
I think this is basically working as intended. Every time anyone tries to make godoc do more with symlinks it ends up chasing its own tail. Symlinks in Go file trees should just be disallowed, honestly.
so this will be fixed in go 1.10?
1.10 will work as well or as poorly as 1.9.
It is not even poorly. It doesn't work at all now.
I don't know what have changed in the past several months.
I often used godoc -http :9999
to open a local doc server several months ago.
But yesterday, I re-run this command again, I found it didn't work any more.
Here is the the command log:
myname@localhost:~$ godoc -http=:8080
2017/11/30 07:16:39 newDirectory(/): stat /usr/local/go: no such file or directory
2017/11/30 07:16:39 godoc: corpus fstree is nil
myname@localhost:~$
myname@localhost:~$ godoc -http=:8080 -goroot /home/myname/gosdk
(will stuck here for ever, cpu usage is 0%, http://localhost:8080/ is unable to connect. I must use ctrl-c to stop it)
^C
myname@localhost:~$
myname@localhost:~$ GOROOT=/home/myname/gosdk
myname@localhost:~$ GOPATH=/home/myname/go
myname@localhost:~$ godoc -http=:8080
2017/11/30 07:21:35 newDirectory(/): stat /usr/local/go: no such file or directory
2017/11/30 07:21:35 godoc: corpus fstree is nil
The only change from my side is I removed the GOPATH and GOROOT envs from .bashrc
.
But it still doesn't work when I set the two envs back.
There is not any symlink involved in my Go setup.
Is there a workable workaround?
guess: go install .../cmd/godoc to rebuild godoc. It looks like the value encoded in your current godoc command is hard coded to look for GOROOT at /usr/local/go
On Thu, Nov 30, 2017 at 11:24 PM, Go101 notifications@github.com wrote:
It is not even poorly. It doesn't work at all now. I don't know what have changed in the past several months. I often used `godoc -http :9999" to open a local doc server several months ago. But I yesterday, I re-run this command again, I found it didn't work any more.
Here is the the command log:
myname@localhost:~$ godoc -http=:8080 2017/11/30 07:16:39 newDirectory(/): stat /usr/local/go: no such file or directory 2017/11/30 07:16:39 godoc: corpus fstree is nil myname@localhost:~$ myname@localhost:~$ godoc -http=:8080 -goroot /home/myname/gosdk (will stuck here for ever, cpu usage is 0%, I must use ctrl-c to stop it) ^C myname@localhost:~$ myname@localhost:~$ GOROOT=/home/myname/sdks/go myname@localhost:~$ GOPATH=/home/myname/go myname@localhost:~$ godoc -http=:8080 2017/11/30 07:21:35 newDirectory(/): stat /usr/local/go: no such file or directory 2017/11/30 07:21:35 godoc: corpus fstree is
The only change from my side is I removed the GOPATH and GOROOT envs from .bashrc. But it still doesn't work when I set the two envs back.
There is not any symlink involved in my Go setup.
Is there a workable workaround?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/golang/go/issues/15049#issuecomment-348173734, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA3v12E_6F8Qm4euAw_XvHEl4Z25kks5s7p6CgaJpZM4H9CU1 .
OK, add export
when setting back the GOROOT env works.
myname@localhost:~$ export GOROOT=/home/myname/gosdk
myname@localhost:~$ godoc -http=:8080
It looks godoc -http :8080 -goroot /home/myname/gosdk
also works.
I don't know why the last run is stuck.
So, godoc
doesn't work if GOROOT is not set. Bug? And will be fixed on 1.10?
@davecheney
I never built godoc.
which godoc
prints /home/myname/gosdk/bin/godoc
.
So, godoc doesn't work if GOROOT is not set. Bug? And will be fixed on 1.10?
A some point my guess is the value of runtime.GOROOT() is going to be used, and the fallback for that function is the GOROOT that the Go compiler that built this program knew at the time it was compiled.
On Thu, Nov 30, 2017 at 11:44 PM, Go101 notifications@github.com wrote:
OK, add export when setting back the GOROOT env works.
myname@localhost:~$ export GOROOT=/home/myname/gosdk myname@localhost:~$ godoc -http=:8080
It looks godoc -http :8080 -goroot /home/myname/gosdk also works. I don't know why the last run is stuck.
So, godoc doesn't work if GOROOT is not set. Bug? And will be fixed on 1.10?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/golang/go/issues/15049#issuecomment-348177925, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA8sCRZiUnxcuQhDJjgf9WA_wBDLrks5s7qMsgaJpZM4H9CU1 .
I can confirm godoc
doesn't work if GOROOT
isn't set with go1.10.1.
@tsuna if that's true, please open a separate issue with the details of your environment and how to reproduce the issue. This issue is old and closed, so it's not the best place to discuss it.
This is tracked under #23445.
Please answer these questions before submitting your issue. Thanks!
go version
)? go version go1.6 linux/amd64go env
)? GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/me/Code/go" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GO15VENDOREXPERIMENT="1" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"go get golang.org/x/tools/cmd/godoc
sudo -E go install golang.org/x/tools/cmd/godoc
godoc -http=":8080"
which godoc
gives "/usr/lib/go/bin/godoc"godoc net/http
prints the documentation on the command line, as expected.