-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: GOPATH mode rejects directory arguments outside of GOPATH/src that contain '@' characters #45944
Comments
go1.14 is not one of the actively supported versions (go1.15, go1.16). Can you reproduce the issue with one of the supported versions? |
Unfortunately, I have to cope with whats delivered by (stable) distros. Even 1.14 is only delivered by additional backport repos, no 1.15 available. |
Like @cagedmantis said, 1.14.x is no longer supported, so even if a bug was spotted here, at most there would be a backport to 1.15.x. I imagine that what's happening here is that Consider escaping that special character, just like you might usually do for slashes or spaces. @bcmills where are these restrictions documented? I don't see it in |
I believe the current set of restrictions are #45549 and |
Please provide concrete steps to reproduce the observed behavior using a supported version of the The posted |
I'm confused - this wasn't supposed to be a module name, but a plain path name in GOPATH. Meanwhile I've found a workaround (pretty dirty hack) to build moby, but autogenerating go.mod via 'go mod init'. Is there any way for preventing any downloads and remote access completely ? --mtx |
Based on the command you posted earlier, I expect you'll still see this error (with a slightly different message) in Go 1.16 because of this argument:
To avoid confusion and ambiguous commands, This isn't a problem for import paths, since the language spec does not allow
In module-aware mode, |
The
However, in GOPATH mode when outside of
|
This is a huge problem for automated build engines, if a programming language / compiler imposes restrictions on the source root directories. This also applies to the inherent "src" prefix. That's a heavy violation of layers that make maintaining automatic build infrastructures a pretty hard problem. In my case, the generic deb/rpm packaging engine (*1) puts the source trees (git repos) into subdirs that may have '@' in their names, when explicit package versions (note: package versions have nothing do to w/ go module versions). If the go compiler (just one of a dozen different compilers used in a distro context) has it's own funny ideas how source directory names may look like, I have to do invasive changes in the packaging engine and the surrounding infrastructures.
By "import path" you mean the arguments of the import statement ?
I played a lot with GOPATH, but always lead to lots of error messages, some indicate clashes with the standard library (don't recall the exact messages). So, I tried to generate go.mod (via go mod init), which also just works under certain special circumstances. (see below) The upstream builds docker within a docker container (exactly what I CAN NOT do) and copying around their source tree so /go/src. Without having 'src' prefix in the path name does not seem to work - go wont find the correct sources.
My problem here is 'go mod init'. Documentation suggest that this can be used to create a go.mod from vendor.conf (which does exist in the docker/moby source). BUT: it tries to download a lot of stuff (another thing I CAN NOT have in a distro build context) and uses that stuff instead of from vendor dir - which in turn breaks a lot of things. I can prevent that by pointing GOPATH to an unwritable directory - a very weird hack. Is there any way to prevent 'go mod init' from doing any downloads and just take what is already there ? Finally, all I wanna do is building exactly the sources in that tree, using the distro's toolchain (and it's standard library), and no external interactions. --mtx *1) https://github.com/metux/deb-pkg |
For better or worse, cmd/go is a very opinionated tool. This make it easier for different projects to work together, since strong conventions are enforced. However, if you have a lot of external constraints (sounds like that's the case here), you may run into problems. It seems like a fairly simple change is possible: cmd/go could allow |
You can use Then you can set This sort of stitching-together should be easier using Go 1.17 (which is still under development) with a |
Just a note that we should never accept paths that start with |
We could maybe make a more explicit check to reject the pathis with '@'s mode, but we don't plan to work on this because it's a GOPATH mode issue. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Building w/ 'go build' and setting GOPATH to a directory that happens to have @ in its name.
What did you expect to see?
Build w/o errors
What did you see instead?
/usr/lib/go-1.14/bin/go build -ldflags "-s -w" -o /home/nekrad/src/deb-pkg/pkg/moby-engine@master.git/tmp/build/dockerd-linux-i386 /home/nekrad/src/deb-pkg/pkg/moby-engine@master.git/cmd/dockerd
can't load package: package /home/nekrad/src/deb-pkg/pkg/moby-engine@master.git/cmd/dockerd: cannot use path@version syntax in GOPATH mode
It tries to do some magic interpretation on an opaque directory name, which it should NOT do.
The directory names are externally given by some infrastructure.
'go build' just should take it as it is (and cope w/ all characters that are allowed for file names on Linux/Unix platforms).
The text was updated successfully, but these errors were encountered: