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

go/types: Config.Check tries to create go.sum #33541

Open
vaind opened this issue Aug 8, 2019 · 4 comments
Open

go/types: Config.Check tries to create go.sum #33541

vaind opened this issue Aug 8, 2019 · 4 comments
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@vaind
Copy link

vaind commented Aug 8, 2019

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

$ go version
go version go1.12.7 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
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=/tmp/go-build824852661=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Using type types.Config.Check() on a file importing a package with go.mod but without go.sum causes an attempt to write the missing go.sum file. I realize not having go.sum is a mistake on the repo maintainer side, but there are projects like that out there and they're used. This in turns causes problems in applications that depend on the type-checker to find out some information about source code (e.g. ObjectBox code generator).

See https://github.com/vaind/go-type-checker-issues for a minimal example that shows the issue. Try running the following code as a non-root user on linux:

$ git clone git@github.com:vaind/go-type-checker-issues.git
$ cd go-type-checker-issues/gosum
$ go test ./...
--- FAIL: TestGoSumPermissions (0.71s)
    gosum_test.go:39: gosum.go:5:4: could not import github.com/anacrolix/missinggo (type-checking package "github.com/anacrolix/missinggo" failed (/home/user/go/pkg/mod/github.com/anacrolix/missinggo@v0.0.0-20180725070939-60ef2fbf63df/strcase.go:6:2: could not import github.com/huandu/xstrings (go/build: importGo github.com/huandu/xstrings: exit status 1
        go: writing go.sum: open /home/user/go/pkg/mod/github.com/anacrolix/missinggo@v0.0.0-20180725070939-60ef2fbf63df/go.sum439740474.tmp: permission denied
        
        )))
FAIL
FAIL	github.com/vaind/go-type-checker-issues/gosum	0.711s

Interestingly a combination of go get & go test works fine, but unfortunately that doesn't solve the problem if you have such imports in your own project...

What did you expect to see?

I expect the type checker wouldn't try to create a missing go.sum file.

@andybons
Copy link
Member

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 12, 2019
@andybons andybons added this to the Unplanned milestone Aug 12, 2019
@griesemer
Copy link
Contributor

This is not a type-checker issue - go/types doesn't know anything about Go modules or checksums. Perhaps the importer causes this, but it needs investigation. Re-title once root cause is known.

@vaind
Copy link
Author

vaind commented Oct 16, 2019

Any progress? It's still an issue even with Go 1.13

@griesemer griesemer modified the milestones: Unplanned, Backlog Oct 16, 2019
@griesemer griesemer added the Tools This label describes issues relating to any tools in the x/tools repository. label Oct 16, 2019
@griesemer
Copy link
Contributor

Possibly related to #34860.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants