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/go: TestScript/mod_convert_git fails if GOROOT is in a subdirectory of a git repository #34191

Closed
Toasterson opened this issue Sep 9, 2019 · 10 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@Toasterson
Copy link

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
@bcmills bcmills changed the title go 1.13 self tests fail if run inside subdirectory of a git repository cmd/go: TestScript/mod_convert_git fails if GOROOT is in a subdirectory of a git repository Sep 10, 2019
@bcmills bcmills added help wanted NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. modules labels Sep 10, 2019
@bcmills bcmills added this to the Go1.14 milestone Sep 10, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 10, 2019

Probably the check for “within GOROOT” just needs to be fixed to apply whenever the working directory is inside GOROOT, not just when the candidate config file is inside of it. Hopefully an easy fix.

@guillemj
Copy link

This is very inconvenient when you manage your $HOME with git. :)

@bcmills
Copy link
Contributor

bcmills commented Mar 12, 2020

@guillemj, I do manage my $HOME with git. (But my GOROOT is also a Git checkout rather than from a release tarball, so maybe that helps.)

@bcmills
Copy link
Contributor

bcmills commented Mar 12, 2020

At any rate, do note the help wanted label. 😉
(A regression test might be a bit nuanced, but the fix itself is likely pretty straightforward.)

@guillemj
Copy link

@bcmills This was in the context of building the golang-1.14 Debian package (from tarballs) so I'm afraid that does not entirely help. :)

@bcmills bcmills self-assigned this Mar 13, 2020
@bcmills bcmills modified the milestones: Backlog, Go1.15 Mar 13, 2020
@gopherbot
Copy link

Change https://golang.org/cl/223340 mentions this issue: cmd/go/internal/modload: suppress the 'go mod init' hint for GOROOT more aggressively

@bcmills
Copy link
Contributor

bcmills commented Mar 13, 2020

@guillemj, fix is in CL 223340. It should patch in cleanly, but I think it's too esoteric to be worth backporting.

@bcmills bcmills removed the Testing An issue that has been verified to require only test changes, not just a test failure. label Mar 13, 2020
@bcmills
Copy link
Contributor

bcmills commented Mar 13, 2020

(And, FWIW, this turned out to be a very minor bug in cmd/go itself, rather than a bug in the test.)

@guillemj
Copy link

Perfect thanks! I've tested the patch within the Debian package and it builds fine now. I've updated the Debian bug https://bugs.debian.org/953276, and I guess they'll merge that.

@bcmills
Copy link
Contributor

bcmills commented Mar 13, 2020

@guillemj, note that the patch changed a bit before it was merged.

@golang golang locked and limited conversation to collaborators Mar 13, 2021
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants