Skip to content
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

x/vgo: confused by shortened version tags (v1, v1.1) during find of latest #24476

Closed
klingtnet opened this issue Mar 21, 2018 · 8 comments

Comments

@klingtnet
Copy link

commented Mar 21, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 linux/amd64 vgo:2018-02-20.1

Does this issue reproduce with the latest release?

Latest vgo release is installed.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/anli/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/anli/.go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build533228468=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Here is a minimal example application that triggers the error:

package main // import "github.com/klingtnet/vgo-non-semantic-version-issue"
// vgo-non-semantic-version-issue.go

import (
	"log"

	"github.com/coreos/go-systemd/activation"
)

func main() {
	_, err := activation.Listeners(true)
	if err != nil {
		log.Fatalf("cannot retrieve listeners: %s", err)
	}
}

First, create an empty go.mod file to get it populated by vgo on the first run: touch go.mod.
Second, build the application:

$ vgo build vgo-non-semantic-version-issue.go
vgo: resolving import "github.com/coreos/go-systemd/activation"
vgo: finding github.com/coreos/go-systemd (latest)
vgo: adding github.com/coreos/go-systemd v1

Everything is fine, application was build successfully but the generated mod.go refers to a non-existing git tag:

$ cat go.mod 
module "github.com/klingtnet/vgo-non-semantic-version-issue"

require "github.com/coreos/go-systemd" v1

A second build will now fail with a non-descriptive error message:

$ vgo build vgo-non-semantic-version-issue.go
vgo: finding github.com/coreos/go-systemd v1.0.0
vgo: github.com/coreos/go-systemd v1.0.0: unexpected status (https://api.github.com/repos/coreos/go-systemd/git/refs/tags/v1.0.0): 404 Not Found
vgo: finding github.com/coreos/go-systemd v1.0.0
vgo: github.com/coreos/go-systemd v1.0.0: unexpected status (https://api.github.com/repos/coreos/go-systemd/git/refs/tags/v1.0.0): 404 Not Found
vgo: unexpected status (https://api.github.com/repos/coreos/go-systemd/git/refs/tags/v1.0.0): 404 Not Found

What did you expect to see?

An error message like

Dependency uses non-semantic versioning, abort

or something alike.

What did you see instead?

See above.

PS: I looked for a similar issue but couldn't find one so I opened this issue.

@gopherbot gopherbot added this to the vgo milestone Mar 21, 2018

@klingtnet

This comment has been minimized.

Copy link
Author

commented Mar 21, 2018

Bonus Points

Do not require dependencies to be semantically versioned.

@klingtnet

This comment has been minimized.

Copy link
Author

commented Mar 21, 2018

Now I found a similiar issue #23954 which proposes to use this workaround:

require (
	"<import/path>" v0.0.0-<release-date>-<commit-hash>
)

Usually one has no control over the versioning scheme that is used in the dependencies so it would really limit the usability of vgo if it does not support other versioning schemes then semantic versioning.

@sadbox

This comment has been minimized.

Copy link

commented Mar 27, 2018

This also appears to effect things that don't have 3 version numbers, i.e. github.com/go-sql-driver/mysql tags "v1.3", then vgo will search for "v1.3.0" and get a 404 from github.

~/go/src/github.com/sadbox/sadbox.org (master) ❯ cat go.mod
module "github.com/sadbox/sadbox.org"

require (
	"github.com/NYTimes/gziphandler" v1.0.1
	"github.com/go-sql-driver/mysql" v0.0.0-20161201115036-a0583e0143b1
	"github.com/stretchr/testify" v1.2.1
	"golang.org/x/crypto" v0.0.0-20180219163459-432090b8f568
)
~/go/src/github.com/sadbox/sadbox.org (master) ❯ vgo get -u
vgo: finding github.com/NYTimes/gziphandler latest
vgo: finding github.com/go-sql-driver/mysql latest
vgo: finding github.com/stretchr/testify latest
vgo: finding golang.org/x/crypto latest
vgo: finding github.com/davecgh/go-spew latest
vgo: finding github.com/pmezard/go-difflib latest
vgo: finding github.com/stretchr/objx latest
vgo: finding github.com/davecgh/go-spew latest
vgo: finding github.com/pmezard/go-difflib latest
vgo: finding github.com/stretchr/testify latest
~/go/src/github.com/sadbox/sadbox.org (master) ❯ vgo build
vgo: finding github.com/stretchr/objx v0.1.0
vgo: github.com/stretchr/objx v0.1.0: unexpected status (https://api.github.com/repos/stretchr/objx/git/refs/tags/v0.1.0): 404 Not Found
vgo: finding github.com/go-sql-driver/mysql v1.3.0
vgo: github.com/go-sql-driver/mysql v1.3.0: unexpected status (https://api.github.com/repos/go-sql-driver/mysql/git/refs/tags/v1.3.0): 404 Not Found
vgo: finding github.com/go-sql-driver/mysql v1.3.0
vgo: github.com/go-sql-driver/mysql v1.3.0: unexpected status (https://api.github.com/repos/go-sql-driver/mysql/git/refs/tags/v1.3.0): 404 Not Found
vgo: unexpected status (https://api.github.com/repos/go-sql-driver/mysql/git/refs/tags/v1.3.0): 404 Not Found
~/go/src/github.com/sadbox/sadbox.org (master) ❯ cat go.mod
module "github.com/sadbox/sadbox.org"

require (
	"github.com/NYTimes/gziphandler" v1.0.1
	"github.com/davecgh/go-spew" v1.1.0
	"github.com/go-sql-driver/mysql" v1.3.0
	"github.com/pmezard/go-difflib" v1.0.0
	"github.com/stretchr/objx" v0.1.0
	"github.com/stretchr/testify" v1.2.1
	"golang.org/x/crypto" v0.0.0-20180322175230-88942b9c40a4
)

@rsc rsc changed the title x/vgo: Confusing error for non-semantic versioned packages x/vgo: confused by shortened version tags (v1, v1.1) during find of latest Mar 30, 2018

@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2018

This should be fixed. I think vgo should just completely ignore non-canonical semver tags (v1 or v1.0 instead of v1.0.0) in repos.

@gopherbot

This comment has been minimized.

Copy link

commented Apr 4, 2018

Change https://golang.org/cl/104676 mentions this issue: x/vgo: do not accept abbreviated sevmer tags

@gopherbot

This comment has been minimized.

Copy link

commented Apr 5, 2018

Change https://golang.org/cl/104855 mentions this issue: x/vgo: filter non-canonical sevmer tags from repos

@gopherbot

This comment has been minimized.

Copy link

commented Apr 18, 2018

Change https://golang.org/cl/107659 mentions this issue: cmd/go/internal/modfetch: avoid using non-canonical semver tags

@zombiezen

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2018

This appears to not be fixed. Reopen until https://golang.org/cl/107659 is submitted?

gopherbot pushed a commit to golang/vgo that referenced this issue Apr 25, 2018
cmd/go/internal/modfetch: avoid using non-canonical semver tags
We insist that semver tags in repos be fully spelled out,
as required by semver: v1.2.0, not v1.2. In other places,
like go.mod, we do allow saying v1.2 as shorthand for v1.2.0.
Don't confuse the issue by reporting a "v1.2" tag in the
version list, since it's unaddressable. (If you type v1.2 vgo will
look for v1.2.0.)

Similarly, don't report tags that don't match the module path,
and don't report tags that look like pseudo-versions.

Additional fix for golang/go#23954, golang/go#24476.

Change-Id: Iaac0fb36362b25e5faef5271c110d432ec04bc8b
Reviewed-on: https://go-review.googlesource.com/107659
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>

@golang golang locked and limited conversation to collaborators Apr 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.