-
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: emit an explicit error when packages in GOPATH/src/vendor overlap with GOROOT/src/vendor #34068
Comments
Please provide full instructions to show that this worked on 1.12, and broke in 1.13. For example, using the official Docker images. |
@javasgl, to amplify what @mvdan said: In particular, do the This change probably relates to CL 164619, but we did add a regression test in that CL to try to avoid any change in behavior for existing code using the correct import paths. |
I think I ran into the same issue. I made an example repo here to demonstrate the issue: https://github.com/psanford/gobug34068 If you checkout that repo and set your GOPATH to the git working directory you can try building package Grpc and its dependencies were vendored in src/vendor via gvt. |
Found a much smaller reproducer.
|
I looked into this today, but I'm not sure that it's feasible to fix. The trouble is that a number of caches within The simple failure mode is this:
A similar failure mode occurs with the relative ordering of A long-term fix would be to have all of the caches track packages by directory instead of import path. That change is fairly invasive, and in general we are not pursuing long-term fixes in |
Fortunately, there are (at least) two workarounds available:
|
Finally, I will note that this issue does not reproduce for any project compatible with |
Hi @bcmills , I have a git repository that use a submodule at GOPATH/src/vendor to store others' repository code, then I come across this bug. I think I have two solutions for this problem now for me to continue work with go1.13 and go1.9:
|
Generally the You could also consider copying the files instead of symlinking them. |
Given that Go 1.9 is no longer receiving security updates, I would recommend that you reconsider that approach. (Have you filed an issue for the increase in memory footprint? Can you rework other parts of the application to make it work within the desired footprint with a supported Go version?) |
Finally, is there a reason you need to map in the submodule at |
Hi @bcmills ,
I tried to create directory symlinks in windows 10, so it do not work. Copying the files on windows 10 should be a good idea, but the build script and .gitignore file maybe another story.
Another consideration of not using module mode is I do not know how to copy all the source code of dependencies of my project into one directory and then compile there right now.(looks like that is GOPATH mode.) The only way I can sure that my project can recompile success in a long time when I have all the dependencies in my git repository or in my own storage.(The network may fail, but my local disk will work in a long time.)
I have a lots of packages in GOPATH/src/app/ep/main.go or GOPATH/src/make/main.go, they all need import same package in vendor, If I add vendor to GOPATH/src/config/vendor and GOPATH/src/app/ep/main.go. The binary size will increase and I will need symlinks or copy or vendor directories. I have another workaround of this bug:
|
Per https://golang.org/doc/code.html#ImportPaths:
Package paths that do not start with a domain name are in general reserved for the standard library. That rules out dotless names like You should start your package paths with a domain or prefix that you control, and then you can root your |
See https://golang.org/cmd/go/#hdr-Make_vendored_copy_of_dependencies and https://golang.org/cmd/go/#hdr-Modules_and_vendoring. |
Given the existence of workarounds, I think the way forward on this is to change the |
So here is my new workaround(which is less hard work for me right now):
I think modify golang source code should be the best workaround for me now. It is I only need to modify once every golang release. Here is the workaround bash script(in case me or someone need it again):
|
@bronze1man, forking the entire Go toolchain seems a lot more invasive than prefixing your import path with a domain name, or copying your If the problem is an increase in binary size, have you filed an issue about that? |
I do not agree that, our team have 3 huge golang projects, each one have 100+ golang packages and 4000+ golang files, prefixing the import path into one a domain name means I need to rename almost all of the golang files. I do have a tool to do it automatic, but there will be a lot of path relative bugs to fix manually. That is a lot more invasive than modify and forking the entire Go toolchain. By the way, I have modified the golang source code 1.13.1, and upload to our cdn , this workaround works great.
It looks like the using of GOPATH/src/vendor has calcified within our team. If golang do not forbidden it in the begin (like version go1.0), then there will be a lot of usage of it, make it very hard to change. |
Source: meta-virtualization MR: 00000 Type: Integration Disposition: Merged from meta-virtualization ChangeID: 00cc8af Description: Since go was upgraded to 1.13, there is a failure: ... | src/vendor/golang.org/x/net/http2/frame.go:17:2: use of vendored package not allowed | ../../../recipe-sysroot/usr/lib64/go/src/net/http/h2_bundle.go:49:2: use of vendored package not allowed ... Refer upstream suggestion [1]: `or copying your vendor contents into GOPATH/src rather than mapping them in to GOPATH/src/vendor.' [1] golang/go#34068 Signed-off-by: Hongxu Jia <[email protected]> Signed-off-by: Bruce Ashfield <[email protected]> Signed-off-by: Jeremy Puhlman <[email protected]>
Since go was upgraded to 1.13, there is a failure: ... | src/vendor/golang.org/x/net/http2/frame.go:17:2: use of vendored package not allowed | ../../../recipe-sysroot/usr/lib64/go/src/net/http/h2_bundle.go:49:2: use of vendored package not allowed ... Refer upstream suggestion [1]: `or copying your vendor contents into GOPATH/src rather than mapping them in to GOPATH/src/vendor.' [1] golang/go#34068 Signed-off-by: Hongxu Jia <[email protected]> Signed-off-by: Bruce Ashfield <[email protected]>
@bronze1man, it occurs to me that there is one more possible workaround in GOPATH mode: namely, you can promote the top-level So you might do something like:
Then you can keep building in (That said, at this point I would strongly encourage you to migrate to module mode, and then the semantics of |
@bcmills thanks for your explanation.
I do not even notice this document when I first use GOPATH/src/vender since go1.6 I think I am trying to choose to do things with cheap cost i think, but this choose is not the same as golang project. |
…o 1.13 Since go was upgraded to 1.13, there is a failure: ... | src/vendor/golang.org/x/net/http2/frame.go:17:2: use of vendored package not allowed | ../../../recipe-sysroot/usr/lib64/go/src/net/http/h2_bundle.go:49:2: use of vendored package not allowed ... Refer upstream suggestion [1]: `or copying your vendor contents into GOPATH/src rather than mapping them in to GOPATH/src/vendor.' [1] golang/go#34068 Signed-off-by: Hongxu Jia <[email protected]> Signed-off-by: Bruce Ashfield <[email protected]>
…o 1.13 Since go was upgraded to 1.13, there is a failure: ... | src/vendor/golang.org/x/net/http2/frame.go:17:2: use of vendored package not allowed | ../../../recipe-sysroot/usr/lib64/go/src/net/http/h2_bundle.go:49:2: use of vendored package not allowed ... Refer upstream suggestion [1]: `or copying your vendor contents into GOPATH/src rather than mapping them in to GOPATH/src/vendor.' [1] golang/go#34068 Signed-off-by: Hongxu Jia <[email protected]> Signed-off-by: Bruce Ashfield <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
only in go1.13 happened, back to go1.12.9 can fix this
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go install -v ./...
What did you expect to see?
no errrors
What did you see instead?
src/vendor/golang.org/x/net/http2/frame.go:17:2: use of vendored package not allowed
src/vendor/google.golang.org/grpc/internal/transport/controlbuf.go:28:2: use of vendored package not allowed
src/vendor/golang.org/x/net/http2/transport.go:35:2: use of vendored package not allowed
The text was updated successfully, but these errors were encountered: