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/godoc: confused by symlinks in GOROOT: godoc: corpus fstree is nil #15049

Closed
benbarbour opened this issue Mar 31, 2016 · 19 comments
Closed
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@benbarbour
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6 linux/amd64
  2. What operating system and processor architecture are you using (go 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"
  3. What did you do?
    go get golang.org/x/tools/cmd/godoc
    sudo -E go install golang.org/x/tools/cmd/godoc
    godoc -http=":8080"
  4. What did you expect to see?
    godoc running on the command line, listening to HTTP requests
  5. What did you see instead?
    "2016/03/31 11:15:45 godoc: corpus fstree is nil", followed by program exit with status code -1
  6. Other notes
    • It was working when I was running go 1.5, I added the ubuntu-lxc/lxd-stable ppa and upgraded to go 1.6.
    • I tried running go get with --update, and then tried removing all references I could find to godoc and the installing again using the commands from question # 3.
    • which godoc gives "/usr/lib/go/bin/godoc"
    • godoc net/http prints the documentation on the command line, as expected.
@benbarbour benbarbour changed the title godoc -http=":8080" exits with "godoc: corpus fstree is nil" godoc -http=":8080" exits with "godoc: corpus fstree is nil". Using go 1.6. Mar 31, 2016
@bradfitz bradfitz added this to the Go1.7 milestone Apr 7, 2016
@bradfitz bradfitz changed the title godoc -http=":8080" exits with "godoc: corpus fstree is nil". Using go 1.6. cmd/godoc: -http=":8080" exits with "godoc: corpus fstree is nil" Apr 7, 2016
@mwhudson
Copy link
Contributor

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.

@benbarbour
Copy link
Author

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.

@benbarbour
Copy link
Author

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.

@rsc rsc changed the title cmd/godoc: -http=":8080" exits with "godoc: corpus fstree is nil" cmd/godoc: confused by symlinks in GOROOT: godoc: corpus fstree is nil May 17, 2016
@rsc rsc modified the milestones: Go1.8, Go1.7 May 17, 2016
@tomdee
Copy link

tomdee commented Jul 20, 2016

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

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 6, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8 Nov 11, 2016
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/45096 mentions this issue.

@bradfitz
Copy link
Contributor

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 

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/53634 mentions this issue: godoc: don't try to follow all symlinks

@bradfitz bradfitz reopened this Aug 7, 2017
@bradfitz bradfitz modified the milestones: Go1.10, Go1.9 Aug 7, 2017
gopherbot pushed a commit to golang/tools that referenced this issue Aug 7, 2017
Revert https://golang.org/cl/45096.

Original change description:
    godoc: follow symbolic links to folders in GOROOT

    Directory walking in godoc relies on ReadDir which returns the result
    of os.Lstat.

    Instead make the the OS VFS's ReadDir use os.Stat on symlinks before
    returning.

Updates golang/go#15049
Fixes golang/go#21061

Change-Id: Ieaa7923d85842f3da5696a7f46134d16407dae66
Reviewed-on: https://go-review.googlesource.com/53634
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/57870 mentions this issue: [release-branch.go1.9] godoc: don't try to follow all symlinks

gopherbot pushed a commit to golang/tools that referenced this issue Aug 24, 2017
Revert https://golang.org/cl/45096.

Original change description:
    godoc: follow symbolic links to folders in GOROOT

    Directory walking in godoc relies on ReadDir which returns the result
    of os.Lstat.

    Instead make the the OS VFS's ReadDir use os.Stat on symlinks before
    returning.

Updates golang/go#15049
Fixes golang/go#21061

Change-Id: Ieaa7923d85842f3da5696a7f46134d16407dae66
Reviewed-on: https://go-review.googlesource.com/53634
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/57870
Reviewed-by: Russ Cox <rsc@golang.org>
@rsc
Copy link
Contributor

rsc commented Nov 22, 2017

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.

@rsc rsc closed this as completed Nov 22, 2017
@zigo101
Copy link

zigo101 commented Nov 29, 2017

so this will be fixed in go 1.10?

@ianlancetaylor
Copy link
Contributor

1.10 will work as well or as poorly as 1.9.

@zigo101
Copy link

zigo101 commented Nov 30, 2017

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?

@davecheney
Copy link
Contributor

davecheney commented Nov 30, 2017 via email

@zigo101
Copy link

zigo101 commented Nov 30, 2017

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?

@zigo101
Copy link

zigo101 commented Nov 30, 2017

@davecheney
I never built godoc.
which godoc prints /home/myname/gosdk/bin/godoc.

@davecheney
Copy link
Contributor

davecheney commented Nov 30, 2017 via email

@tsuna
Copy link
Contributor

tsuna commented Apr 16, 2018

I can confirm godoc doesn't work if GOROOT isn't set with go1.10.1.

@mvdan
Copy link
Member

mvdan commented Apr 16, 2018

@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.

@tsuna
Copy link
Contributor

tsuna commented Apr 23, 2018

This is tracked under #23445.

@golang golang locked as resolved and limited conversation to collaborators Apr 23, 2018
henderjon pushed a commit to oggodoc/godoc that referenced this issue Jun 13, 2024
Directory walking in godoc relies on ReadDir which returns the result
of os.Lstat.

Instead make the the OS VFS's ReadDir use os.Stat on symlinks before
returning.

Fixes golang/go#15049

Change-Id: I34d17ca0027b0245f5ef434a000e5a3fe2af11cf
Reviewed-on: https://go-review.googlesource.com/45096
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests