Skip to content

cmd/go: go list can't follow symlink #57754

@zhsj

Description

@zhsj

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

$ go version
go version go1.20rc2 linux/amd64

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
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zsj/.cache/go-build"
GOENV="/home/zsj/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zsj/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zsj/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/usr/lib/go-1.20"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.20/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20rc2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/zsj/Workspaces/debian/package/pkg-go/golang-go.uber-atomic/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build166984776=/tmp/go-build -gno-record-gcc-switches"

What did you do?

zsj@debian:~/golang-go.uber-atomic$ go list go.uber.org/atomic/...
pattern go.uber.org/atomic/...: lstat ../../share/go-1.20/src: no such file or directory

What did you expect to see?

Like go1.19

zsj@debian:~/golang-go.uber-atomic$ /usr/lib/go-1.19/bin/go list go.uber.org/atomic/...
go.uber.org/atomic
go.uber.org/atomic/internal/gen-atomicint
go.uber.org/atomic/internal/gen-atomicwrapper

What did you see instead?

lstat ../../share/go-1.20/src: no such file or directory

The golang package in Debian installs the src at /usr/share/go-1.20/src/, but the go command is at /usr/lib/go-1.20/bin/. The it creates a symlink like

$ l /usr/lib/go-1.20/src
lrwxrwxrwx 1 root root 23 Jan  5 16:01 /usr/lib/go-1.20/src -> ../../share/go-1.20/src/

I'm not sure why we do that, but it has been such layout for a long time. Maybe to conform FHS policy.

A quick debug with strace shows:

[pid 521295] newfstatat(AT_FDCWD, "/usr/lib/go-1.20/src", {st_mode=S_IFLNK|0777, st_size=23, ...}, AT_SYMLINK_NOFOLLOW) = 0
[pid 521295] readlinkat(AT_FDCWD, "/usr/lib/go-1.20/src", "../../share/go-1.20/src", 128) = 23
[pid 521295] newfstatat(AT_FDCWD, "../../share/go-1.20/src", 0xc000498ed8, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
pattern go.uber.org/atomic/...: lstat ../../share/go-1.20/src: no such file or directory

Seems it doesn't follow the symlink with right base?

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeGoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions