-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: build fetches a module that has been replaced #27859
Comments
Possibly related to #26241. |
This seems like a major issue in that every save in IDE causes build and its majorly delayed to get even basic responses on syntax errors to users. Breaks the expected and loved normally very fast compiling of go for engineers. Is there any other work around or standard way to reference local packages rather than ones that need an http fetch? Having to use replace for this instead of a native way in the require statement in go.mod seems like it would be more appropriate. Regardless of general design gap perhaps, can this specific fix be considered for 1.11.1 and not wait until 1.12? Note I'm talking about doing a replace to relative path "../common_package" |
If this issue is hindering your productivity, you can consider this temporary workaround. Include the domain name that Go is trying to fetch in your /etc/hosts file (on Linux/Mac) and point it to your local machine. So something like this for the example above:
Please note that this will not fix the issue, but the fetch will fail instantly which brings the build speed back to what you are used to:
Keep in mind that the above change affects all network operations. Hope this helps short term. |
Very hacky @mibes :) . but thank you for the creative solution, guess thats what I'll do for now. It would require we actually change our package module paths to some fake domain and not our own real one, so slightly disruptive, but doable temporarily |
Change https://golang.org/cl/140860 mentions this issue: |
+1 just hit this exact same problem. mine for local repos with it trying to fetch from the internet without resolving the "replace" first. |
in general it would be great (for security and network policy-related reasons) to have the following guarantee: if all your required dependencies in "external" domains (github.com, golang.org, gopkg.in etc.) have been I know @bcmills mentoned using GOPROXY earlier in related discussions and it's likely another way to do this but would be useful to have the discussed limits of |
go list also seems to download too which makes our build pipeline horrifically slow. For now we can ensure GO111MODULE isn't set to avoid this but moving forward it seems that tools that aren't explicitly doing gets should not attempt to do any of this processing. |
It should always be local processing first then remote. What happens if your in an environment with no network support at all? |
@stevenh - the fix in https://go-review.googlesource.com/c/go/+/140860 will work for all of the |
Thanks @myitcv but still seeing > setenv GO111MODULE on
> /usr/bin/time -h go list -e -f '{{if .TestGoFiles }}{{.ImportPath}}{{end}}' ./... > f
go: finding github.com/multiplay/go-utils/cdata latest
go: finding github.com/multiplay/go-utils latest
1.44s real 1.88s user 1.08s sys
> unsetenv GO111MODULE
> /usr/bin/time -h go list -e -f '{{if .TestGoFiles }}{{.ImportPath}}{{end}}' ./... > f
0.87s real 0.78s user 0.42s sys Should I raise a separate issue to track this? |
Yes, please do raise a separate issue (with steps to reproduce it). The fix in CL 140860 addresses the known source of spurious fetches, but there may be others. |
I had the same problem, fixed by manually compiling and using the latest version of the go sdk. |
What version of Go are you using (
go version
)?go version go1.11 linux/amd64
Does this issue reproduce with the latest release?
Yes, if latest release is 1.11
What operating system and processor architecture are you using (
go env
)?The following was created in the docker container
golang:1.11
withGO111MODULE=on
:What did you do?
I am using the new module functionality to handle my project dependencies. One of my dependencies has an import path that is a
gopkg.in
redirect URL. My corporate network does not allowgopkg.in
for security reasons, so in mygo.mod
file I use a replace statements:My dependency graph only lists the two versions of go-yaml that I included in my replacement statements:
When performing a module based install, the following appears in the output:
The other packages then compile and the executable successfully builds.
What did you expect to see?
No references to any attempt of downloading the gopkg.in/yaml project. Instead, the direct GitHub link provided in the replacement statements should be fetched instead.
What did you see instead?
The go command attempts to reach the gopkg.in/yaml URL each time a build is attempted. It causes a longer than needed build time since the fetch times out. The build succeeds, but it isn't clear why since the fetch failed.
The text was updated successfully, but these errors were encountered: