Skip to content

cmd/go: TestScript/mod_convert_git fails if GOROOT is in a subdirectory of a git repository #34191

@Toasterson

Description

@Toasterson

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

$ go version
go 1.13 illumos/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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="illumos"
GONOPROXY=""
GONOSUMDB=""
GOOS="illumos"
GOPATH="/root/workspace/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/golang/1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/1.13/pkg/tool/illumos_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build649593032=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I am currently packaging go 1.13 for Openindiana. Our buildsystem is a git repository with Makefiles which run standardized build commands to ensure the correct compiler and linker are used for our OS. You can find the Repository in Github at https://github.com/OpenIndiana/oi-userland

When running the tests for go 1.13 we noticed that one test fails when calling the git comand.

Our scripts basically run

export GOROOT=$REPOSITORY/components/developer/golang-113/build/amd64
cd $GOROOT/src
./run.bash

The Pull Request for go 1.13 is located at OpenIndiana/oi-userland#5297

If we however copy the directory out of the git repository into any other location the tests pass.

This issue is not blocking for Packaging but it would be nice to have it be fixed. go 1.12 did succeed with all tests

What did you expect to see?

<snip>
##### API check
Go version is "go1.13", ignoring -next /root/workspace/openindiana/golang-113/build/amd64/api/next.txt

ALL TESTS PASSED

What did you see instead?

go test proxy running at GOPROXY=http://127.0.0.1:62476/mod
go proxy: no archive rsc.io v1.5.2: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.0.0: file does not exist
go proxy: no archive rsc.io v1.1.0: file does not exist
go proxy: no archive rsc.io v1.5.1: file does not exist
go proxy: no archive example.com/newcycle v1.0.0: file does not exist
--- FAIL: TestScript (0.01s)
    --- FAIL: TestScript/mod_convert_git (0.12s)
        script_test.go:191: 
            # We should not create a go.mod file unless the user ran 'go mod init' explicitly.
            # However, we should suggest 'go mod init' if we can find an alternate config file. (0.025s)
            # The command we suggested should succeed. (0.057s)
            # We should not suggest creating a go.mod file in $GOROOT, even though there may be a .git/config there. (0.031s)
            > cd $GOROOT
            /export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64
            > ! go list .
            [stderr]
            goroutine 1 [running]:
            runtime/debug.Stack(0xc00015f230, 0xc0001f05b0, 0xc000173748)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/runtime/debug/stack.go:24 +0x9d
            runtime/debug.PrintStack()
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/runtime/debug/stack.go:16 +0x22
            cmd/go/internal/modload.die()
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/modload/init.go:274 +0x2fe
            cmd/go/internal/modload.ModRoot(0xc0001861e0, 0x4e)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/modload/init.go:253 +0x50
            cmd/go/internal/modload.ImportPathsQuiet.func1(0xc0001a4048, 0x1, 0x1, 0x1)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/modload/load.go:109 +0x9e3
            cmd/go/internal/modload.ImportPathsQuiet.func2(0x9abd40, 0xc00015f110, 0x0)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/modload/load.go:205 +0x62
            cmd/go/internal/modload.(*loader).load(0xc0001e8120, 0xc0001f0f30)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/modload/load.go:601 +0x115f
            cmd/go/internal/modload.ImportPathsQuiet(0xc0000a4050, 0x1, 0x1, 0xc00015efc0, 0x8, 0x0, 0xc0001b9200)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/modload/load.go:203 +0x2f4
            cmd/go/internal/modload.ImportPaths(0xc0000a4050, 0x1, 0x1, 0x0, 0xa3acec, 0x2)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/modload/load.go:57 +0x5d
            cmd/go/internal/load.ImportPaths(0xc0000a4050, 0x1, 0x1, 0x9dd9e0, 0x10, 0xc000000300)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/load/pkg.go:2014 +0x5f
            cmd/go/internal/load.PackagesAndErrors(0xc0000a4050, 0x1, 0x1, 0x0, 0x0, 0x0)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/load/pkg.go:1961 +0xcd
            cmd/go/internal/load.Packages(0xc0000a4050, 0x1, 0x1, 0xc00018b500, 0x0, 0x0)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/load/pkg.go:1938 +0x5a
            cmd/go/internal/list.runList(0xea87e0, 0xc0000a4050, 0x1, 0x1)
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/internal/list/list.go:425 +0x21bc
            main.main()
            	/export/home/newman/ws/oi-userland/components/developer/golang-113/build/amd64/src/cmd/go/main.go:189 +0x57f
            go: cannot find main module, but found .git/config in /export/home/newman/ws/oi-userland
            	to create a module there, run:
            	cd ../../../../.. && go mod init
            [exit status 1]
            > ! stderr 'go mod init'
            FAIL: testdata/script/mod_convert_git.txt:19: unexpected match for `(?m)go mod init` found in stderr: go mod init
            
FAIL
FAIL	cmd/go	90.752s

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions