-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: "malformed import path" in Go 1.16 for packages with path elements containing a leading dot #43985
Comments
Hmm, this package doesn't have a valid import path in module-aware mode. From
However, I'm guessing this isn't a package that's ever imported. Perhaps the |
Hrm, I'm not sure. We disallow a leading dot in general because it can make code harder to audit: in environments that hide dotfiles by default we don't want to hide the source code for the dependencies of a Go package, and path elements beginning with |
Correct. |
For a bit of context, I'm doing this because having a I'll leave it to @bcmills and @jayconrod to determine whether it's necessary to continue supporting this pattern given it used ti work in |
I think we should keep this open since it used to work, and in most other situations, the go command allows a package with an invalid import path to be named using a file path. Probably not for 1.16 at this point in the freeze though. |
After looking at this a bit further, I think we should close this. It's pretty ambiguous though. If more folks run into this issue in new situations, we can reconsider.
|
Just tried building on 1.16rc1 and this breaks our builds:
Is there any workaround available? |
See previously #34992. |
Change https://golang.org/cl/291389 mentions this issue: |
I did some investigation, and found that the prohibition on leading-dot elements was added in CL 124378, back in July 2018. We attempted to investigate the prevalence of these paths in the wild using the The only specific affected module we know of so far is After discussion with @rsc, @jayconrod, and @matloob, we're planning to leave this validation in place for Go 1.16. If we find more severe examples after the release, we can consider whether to relax the check in Go 1.16.1. If you are affected, please comment on this issue with the affected module path(s) and versions. |
…sallowed For #43985 Change-Id: I1a16f66800c5c648703f0a0d2ad75024525a710f Reviewed-on: https://go-review.googlesource.com/c/go/+/291389 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
Thanks for the report Paul, and thanks for the discourse and debugging everyone. @bcmills you mailed and merged the documentation CL https://go-review.googlesource.com/c/go/+/291389, should we thus move this issue out of Go1.16 and roll it forward for Go1.17 and consider a backport if necessary for Go1.16.1, as you raised in #43985 (comment)? |
This is an unexpected breaking change in Go 1.16 for all our builds using Raised initially here until I've found out that the issue is in All our |
It sounds like this issue is affecting more people than we'd hoped. I'll look at relaxing the constraint that import paths can't have path elements starting with dots. We'll aim to backport that to 1.16.1. We'll continue to disallow trailing dots in import path elements, since those names aren't allowed on Windows. We'll also continue disallowing leading dots in module path elements. |
@gopherbot Please backport to 1.16. |
Backport issue(s) opened: #44647 (for 1.16). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/297089 mentions this issue: |
These were always disallowed, but the restriction wasn't enforced in most cases until Go 1.16. That's broken more projects than we hoped. This change allows leading dots in import path elements. Leading dots are still not allowed in module path elements. Leading dots were always allowed in file path elements. Trailing dots are still forbidden in all cases. For golang/go#43985 Change-Id: Id9cf728a341931565ab9e81f600b2341aa178683 Reviewed-on: https://go-review.googlesource.com/c/mod/+/297089 Trust: Jay Conrod <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
Change https://golang.org/cl/297530 mentions this issue: |
Change https://golang.org/cl/297634 mentions this issue: |
…ents Follow-up to CL 297530. For #43985 For #34992 Change-Id: I2cfa6c41c013e627c3464c383ca42f5c9ebe521a Reviewed-on: https://go-review.googlesource.com/c/go/+/297634 Trust: Jay Conrod <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
Passing test
What did you see instead?
This has the effect of breaking commands like
go generate ./.github/workflows
I bisected this to 3a65abf
cc @bcmills @jayconrod
The text was updated successfully, but these errors were encountered: