{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/29410","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/29410/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/29410/comments","events_url":"https://api.github.com/repos/golang/go/issues/29410/events","html_url":"https://github.com/golang/go/issues/29410","id":393871274,"node_id":"MDU6SXNzdWUzOTM4NzEyNzQ=","number":29410,"title":"cmd/go: building requires otherwise-unused .mod files to be present ","user":{"login":"stapelberg","id":55506,"node_id":"MDQ6VXNlcjU1NTA2","avatar_url":"https://avatars2.githubusercontent.com/u/55506?v=4","gravatar_id":"","url":"https://api.github.com/users/stapelberg","html_url":"https://github.com/stapelberg","followers_url":"https://api.github.com/users/stapelberg/followers","following_url":"https://api.github.com/users/stapelberg/following{/other_user}","gists_url":"https://api.github.com/users/stapelberg/gists{/gist_id}","starred_url":"https://api.github.com/users/stapelberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stapelberg/subscriptions","organizations_url":"https://api.github.com/users/stapelberg/orgs","repos_url":"https://api.github.com/users/stapelberg/repos","events_url":"https://api.github.com/users/stapelberg/events{/privacy}","received_events_url":"https://api.github.com/users/stapelberg/received_events","type":"User","site_admin":false},"labels":[{"id":373402289,"node_id":"MDU6TGFiZWwzNzM0MDIyODk=","url":"https://api.github.com/repos/golang/go/labels/NeedsInvestigation","name":"NeedsInvestigation","color":"ededed","default":false},{"id":992189327,"node_id":"MDU6TGFiZWw5OTIxODkzMjc=","url":"https://api.github.com/repos/golang/go/labels/modules","name":"modules","color":"bac2ff","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-24T12:16:36Z","updated_at":"2018-12-24T17:18:57Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!-- Please answer these questions before submitting your issue. Thanks! -->\r\n\r\n### What version of Go are you using (`go version`)?\r\n\r\n<pre>\r\n$ go version\r\ngo version go1.12beta1 linux/amd64\r\n</pre>\r\n\r\n### Does this issue reproduce with the latest release?\r\n\r\nYes.\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n\r\n<details><summary><code>go env</code> Output</summary><br><pre>\r\n$ go env\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOCACHE=\"/home/michael/.cache/go-build\"\r\nGOEXE=\"\"\r\nGOFLAGS=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"linux\"\r\nGOOS=\"linux\"\r\nGOPATH=\"/tmp/gp-repro\"\r\nGOPROXY=\"\"\r\nGORACE=\"\"\r\nGOROOT=\"/home/michael/sdk/go1.12beta1\"\r\nGOTMPDIR=\"\"\r\nGOTOOLDIR=\"/home/michael/sdk/go1.12beta1/pkg/tool/linux_amd64\"\r\nGCCGO=\"/usr/bin/gccgo\"\r\nCC=\"gcc\"\r\nCXX=\"g++\"\r\nCGO_ENABLED=\"1\"\r\nGOMOD=\"/tmp/repro/go.mod\"\r\nCGO_CFLAGS=\"-g -O2\"\r\nCGO_CPPFLAGS=\"\"\r\nCGO_CXXFLAGS=\"-g -O2\"\r\nCGO_FFLAGS=\"-g -O2\"\r\nCGO_LDFLAGS=\"-g -O2\"\r\nPKG_CONFIG=\"pkg-config\"\r\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build500484946=/tmp/go-build -gno-record-gcc-switches\"\r\n\r\n</pre></details>\r\n\r\n### What did you do?\r\n\r\n```\r\n% export GOPATH=/tmp/gp-repro\r\n% mkdir /tmp/repro\r\n% cat > repro.go <<'EOT'\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\r\n\t\"golang.org/x/exp/mmap\"\r\n\t\"gonum.org/v1/gonum/unit\"\r\n)\r\n\r\nfunc main() {\r\n\tfmt.Printf(\"%v, %v\", mmap.ReaderAt{}, unit.Meter)\r\n}\r\nEOT\r\n% go mod init repro\r\n% go build\r\ngo: finding gonum.org/v1/gonum v0.0.0-20181223131727-b545e3e77e9e\r\ngo: finding golang.org/x/exp v0.0.0-20181221233300-b68661188fbf\r\ngo: finding golang.org/x/exp v0.0.0-20180321215751-8460e604b9de\r\ngo: finding golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b\r\ngo: downloading gonum.org/v1/gonum v0.0.0-20181223131727-b545e3e77e9e\r\ngo: downloading golang.org/x/exp v0.0.0-20181221233300-b68661188fbf\r\ngo: extracting golang.org/x/exp v0.0.0-20181221233300-b68661188fbf\r\ngo: extracting gonum.org/v1/gonum v0.0.0-20181223131727-b545e3e77e9e\r\n```\r\n\r\nAs you can see, two versions of `golang.org/x/exp` are involved here: the repro module uses the latest (v0.0.0-20181221233300-b68661188fbf), whereas the `gonum.org/v1/gonum` module specifies an older version (v0.0.0-20180321215751-8460e604b9de).\r\n\r\nIn the build itself, the latest version is picked:\r\n\r\n```\r\n% go list -m -json all\r\n{\r\n\t\"Path\": \"repro\",\r\n\t\"Main\": true,\r\n\t\"Dir\": \"/tmp/repro\",\r\n\t\"GoMod\": \"/tmp/repro/go.mod\",\r\n\t\"GoVersion\": \"1.12\"\r\n}\r\n{\r\n\t\"Path\": \"golang.org/x/exp\",\r\n\t\"Version\": \"v0.0.0-20181221233300-b68661188fbf\",\r\n\t\"Time\": \"2018-12-21T23:33:00Z\",\r\n\t\"Dir\": \"/tmp/gp-repro/pkg/mod/golang.org/x/exp@v0.0.0-20181221233300-b68661188fbf\",\r\n\t\"GoMod\": \"/tmp/gp-repro/pkg/mod/cache/download/golang.org/x/exp/@v/v0.0.0-20181221233300-b68661188fbf.mod\"\r\n}\r\n{\r\n\t\"Path\": \"golang.org/x/tools\",\r\n\t\"Version\": \"v0.0.0-20180525024113-a5b4c53f6e8b\",\r\n\t\"Time\": \"2018-05-25T02:41:13Z\",\r\n\t\"Indirect\": true,\r\n\t\"GoMod\": \"/tmp/gp-repro/pkg/mod/cache/download/golang.org/x/tools/@v/v0.0.0-20180525024113-a5b4c53f6e8b.mod\"\r\n}\r\n{\r\n\t\"Path\": \"gonum.org/v1/gonum\",\r\n\t\"Version\": \"v0.0.0-20181223131727-b545e3e77e9e\",\r\n\t\"Time\": \"2018-12-23T13:17:27Z\",\r\n\t\"Dir\": \"/tmp/gp-repro/pkg/mod/gonum.org/v1/gonum@v0.0.0-20181223131727-b545e3e77e9e\",\r\n\t\"GoMod\": \"/tmp/gp-repro/pkg/mod/cache/download/gonum.org/v1/gonum/@v/v0.0.0-20181223131727-b545e3e77e9e.mod\"\r\n}\r\n```\r\n\r\nHowever, when preventing internet access by pointing `GOPROXY` to an unused port, I can see that the old version of `golang.org/x/exp` needs to be present for the build to succeed:\r\n\r\n```\r\n% rm repro && GOPROXY=http://localhost:1111/ go build\r\n# works\r\n% rm /tmp/gp-repro/pkg/mod/cache/download/golang.org/x/exp/@v/v0.0.0-20180321215751-8460e604b9de.*\r\n% rm repro && GOPROXY=http://localhost:1111/ go build\r\ngo: finding golang.org/x/exp v0.0.0-20180321215751-8460e604b9de\r\ngo: golang.org/x/exp@v0.0.0-20180321215751-8460e604b9de: Get http://localhost:1111/golang.org/x/exp/@v/v0.0.0-20180321215751-8460e604b9de.info: dial tcp [::1]:1111: connect: connection refused\r\ngo: error loading module requirements\r\n% echo 'module golang.org/x/exp' > /tmp/gp-repro/pkg/mod/cache/download/golang.org/x/exp/@v/v0.0.0-20180321215751-8460e604b9de.mod\r\n% GOPROXY=http://localhost:1111/ go build                                                                                         \r\n# works\r\n```\r\n\r\nThis came as a surprise to me, so I wanted to check in and see if this was intentional or an oversight. Given that the .mod file only contains “module golang.org/x/exp”, it seems to me that the file could easily be synthesized?\r\n\r\nI discovered this issue because I was experimenting with packaging Go modules in Linux distributions (e.g. Debian). It would be a significant downside if we needed to provide (and therefore maintain!) all versions that a build ever references, instead of just the versions which are selected in the end.\r\n\r\nThanks,"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/449756730","html_url":"https://github.com/golang/go/issues/29410#issuecomment-449756730","issue_url":"https://api.github.com/repos/golang/go/issues/29410","id":449756730,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTc1NjczMA==","user":{"login":"mvdan","id":3576549,"node_id":"MDQ6VXNlcjM1NzY1NDk=","avatar_url":"https://avatars0.githubusercontent.com/u/3576549?v=4","gravatar_id":"","url":"https://api.github.com/users/mvdan","html_url":"https://github.com/mvdan","followers_url":"https://api.github.com/users/mvdan/followers","following_url":"https://api.github.com/users/mvdan/following{/other_user}","gists_url":"https://api.github.com/users/mvdan/gists{/gist_id}","starred_url":"https://api.github.com/users/mvdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvdan/subscriptions","organizations_url":"https://api.github.com/users/mvdan/orgs","repos_url":"https://api.github.com/users/mvdan/repos","events_url":"https://api.github.com/users/mvdan/events{/privacy}","received_events_url":"https://api.github.com/users/mvdan/received_events","type":"User","site_admin":false},"created_at":"2018-12-24T17:18:57Z","updated_at":"2018-12-24T17:18:57Z","author_association":"MEMBER","body":"It might take a while for this to get a proper reply, as most engineers will be on holiday this week :)\r\n\r\n/cc @bcmills @myitcv @thepudds "}}
{"actor":{"display_login":"mvdan"}}