go: cmd/go/internal/modfetch: treat malformed versions as “not found” on the proxy path
For Go 1.11 and 1.12, I have in my go.mod
something like:
replace (
github.com/lxn/walk => golang.zx2c4.com/wireguard/windows pkg/walk
github.com/lxn/win => golang.zx2c4.com/wireguard/windows pkg/walk-win
)
I use this to indicate that usage of github.com/lxn/walk
should be replaced with the latest contents of a branch called pkg/walk
from golang.zx2c4.com/wireguard/windows
.
With 1.13beta1, this now breaks with a message:
/home/zx2c4/Projects/wireguard-windows/go.mod:16: replace golang.zx2c4.com/wireguard/windows: version "pkg/walk" invalid: version "pkg/walk" invalid: disallowed version string
/home/zx2c4/Projects/wireguard-windows/go.mod:17: replace golang.zx2c4.com/wireguard/windows: version "pkg/walk-win" invalid: version "pkg/walk-win" invalid: disallowed version string
This poses a significant problem.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 19
- Comments: 36 (28 by maintainers)
Links to this issue
Commits related to this issue
- fix: go 1.13 avoid go PROXY. Go 1.13 introduced a proxy for go modules versioning. This proxy doesn't allow to `go get` package that have '/' in the version string. eg `go get github.com/go-flutter-... — committed to go-flutter-desktop/hover by pchampio 5 years ago
- fix: go 1.13 avoid go PROXY. (#32) Go 1.13 introduced a proxy for go modules versioning. This proxy doesn't allow to `go get` package that have '/' in the version string. eg `go get github.com/g... — committed to go-flutter-desktop/hover by pchampio 5 years ago
- Use Hash instead of Branch name to replace go.mod Before this patch, We were replacing go.mod in openstack-operator with PR commit using branch name. ex: ~~ go mod edit --replace github.com/openstac... — committed to ci-framework/openstack-k8s-operators-ci by Sandeepyadav93 2 years ago
Any chance that this gets fixed at any point? Slashes in branch names are very common and it’s frustrating to have to work around this limitation all the time.
Yes, extremely common. For example, some projects use it to denote the owner of the branch
jd/something
. Others use it for particular version partions. One of the most common ways of serving git repos to groups is a piece of software calledgitolite
, perhaps you’ve heard of it. One of its key features is that it can give granular permissions to branches based on a / hierarchy. This in turn matches the actual way git stores tags: in a directory hierarchy, with / being the directory separator.To add to my last comment, the convention is even documented here: https://github.com/ipfs/community/blob/master/CONTRIBUTING_GO.md#branch-names
As much as I don’t personally use them, I’m afraid they are common. Where I work, pretty much everyone works in branches like
feat/some-feature
orfix/some-bug
. For example: https://github.com/ipfs/go-ipfs/branches@elgs this issue is about interacting with branches that have a forward slash (
/
) in them - e.g.branch/name
.It seems it works as of go 1.20.1. I created several branches,
all
,mysql
,sqlite3
, and etc., loading only corresponding drivers. And I was able to install the different branches by:I am quite satisfied as it is. But I am not sure if I overlooked anything.
This bug also affects module imports from a subdirectory of another module.
Here’s an example tree for a repo:
If I were to import package
github.com/foo/bar/pkg/baz
then go would try to fetch tagpkg/baz/v1.0.0
automatically (that would fail).What’re the next steps for that one - do we want to fix
go
or proxy (athens
)?I agree that changes here are too subtle for Go 1.13. For Go 1.14 the first question is “should we make direct mode and proxy mode match as far as what they accept for versions” and the second is “if so, how? restrict direct mode or loosen proxy mode?”
Are slashes in git branch names very common?
Set
GOPROXY=direct
works for me:@bcmills @jayconrod I think this is a side-effect of changing GOPROXY.
The problem can be reproducible with go1.12 if GOPROXY is set.
@utrack try the
-x
flag to see how thego
command works with the proxy. That will show the behavior @bcmills described above.go get github.com/foo/bar/pkg/baz@v1.0.0
orgo get github.com/foo/bar/pkg/baz
will work as expected.go get github.com/foo/bar/pkg/baz@pkg/baz/v1.0.0
won’t due to this issue but not sure how often ppl want to fetch a module/package in that way.