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

Created on 21 Mar 2018  ·  8Comments  ·  Source: golang/go

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.

FrozenDueToAge NeedsFix

Most helpful comment

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.

All 8 comments

Bonus Points

Do not require dependencies to be semantically versioned.

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.

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
)

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.

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

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

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

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

Was this page helpful?
0 / 5 - 0 ratings