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

Pop doesn't build with vgo #109

Closed
markbates opened this issue May 24, 2018 · 7 comments · Fixed by #111
Closed

Pop doesn't build with vgo #109

markbates opened this issue May 24, 2018 · 7 comments · Fixed by #111
Labels
bug Something isn't working

Comments

@markbates
Copy link
Member

$ pwd
$GOPATH/src/github.com/gobuffalo/pop

$ cat go.mod
module "github.com/gobuffalo/pop"

$ vgo build -v
vgo: resolving import "github.com/cockroachdb/cockroach-go/crdb"
vgo: finding github.com/cockroachdb/cockroach-go (latest)
vgo: adding github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
vgo: resolving import "github.com/fatih/color"
vgo: finding github.com/fatih/color (latest)
vgo: adding github.com/fatih/color v1.7.0
vgo: resolving import "github.com/go-sql-driver/mysql"
vgo: finding github.com/go-sql-driver/mysql (latest)
vgo: adding github.com/go-sql-driver/mysql v1.3.0
vgo: resolving import "github.com/gobuffalo/envy"
vgo: finding github.com/gobuffalo/envy (latest)
vgo: adding github.com/gobuffalo/envy v1.6.2
vgo: resolving import "github.com/gobuffalo/makr"
vgo: finding github.com/gobuffalo/makr (latest)
vgo: adding github.com/gobuffalo/makr v1.1.0
vgo: resolving import "github.com/gobuffalo/packr"
vgo: finding github.com/gobuffalo/packr (latest)
vgo: adding github.com/gobuffalo/packr v1.11.0
vgo: resolving import "github.com/gobuffalo/uuid"
vgo: finding github.com/gobuffalo/uuid (latest)
vgo: adding github.com/gobuffalo/uuid v1.2.0
vgo: resolving import "github.com/pkg/errors"
vgo: finding github.com/pkg/errors (latest)
vgo: adding github.com/pkg/errors v0.8.0
vgo: resolving import "github.com/markbates/inflect"
vgo: finding github.com/markbates/inflect (latest)
vgo: adding github.com/markbates/inflect v0.0.0-20180514174915-dd7de90c06bc
vgo: resolving import "github.com/mattn/anko/core"
vgo: finding github.com/mattn/anko (latest)
vgo: adding github.com/mattn/anko v0.0.4
vgo: resolving import "github.com/jmoiron/sqlx"
vgo: finding github.com/jmoiron/sqlx (latest)
vgo: adding github.com/jmoiron/sqlx v0.0.0-20180406164412-2aeb6a910c2b
vgo: resolving import "github.com/gobuffalo/validate"
vgo: finding github.com/gobuffalo/validate (latest)
vgo: adding github.com/gobuffalo/validate v1.0.0
vgo: resolving import "github.com/markbates/going/defaults"
vgo: finding github.com/markbates/going (latest)
vgo: adding github.com/markbates/going v0.0.0-20170113214412-0576708c56ce
vgo: resolving import "golang.org/x/sync/errgroup"
vgo: finding golang.org/x/sync (latest)
vgo: adding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
vgo: resolving import "gopkg.in/yaml.v2"
vgo: finding gopkg.in/yaml.v2 (latest)
vgo: adding gopkg.in/yaml.v2 v2.2.1
vgo: resolving import "github.com/lib/pq"
vgo: finding github.com/lib/pq (latest)
vgo: adding github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
vgo: resolving import "github.com/joho/godotenv"
vgo: finding github.com/joho/godotenv (latest)
vgo: adding github.com/joho/godotenv v1.2.0
vgo: resolving import "golang.org/x/net/context"
vgo: finding golang.org/x/net (latest)
vgo: adding golang.org/x/net v0.0.0-20180522190444-9ef9f5bb98a1
github.com/gobuffalo/pop/associations
# github.com/gobuffalo/pop/associations
associations/many_to_many_association.go:135:10: assignment mismatch: 2 variables but 1 values
$ vgo get -u
vgo: finding github.com/cockroachdb/cockroach-go latest
vgo: finding github.com/fatih/color latest
vgo: finding github.com/go-sql-driver/mysql latest
vgo: finding github.com/gobuffalo/envy latest
vgo: finding github.com/gobuffalo/makr latest
vgo: finding github.com/gobuffalo/packr latest
vgo: finding github.com/gobuffalo/uuid latest
vgo: finding github.com/gobuffalo/validate latest
vgo: finding github.com/jmoiron/sqlx latest
vgo: finding github.com/joho/godotenv latest
vgo: finding github.com/lib/pq latest
vgo: finding github.com/markbates/going latest
vgo: finding github.com/markbates/inflect latest
vgo: finding github.com/mattn/anko latest
vgo: finding github.com/pkg/errors latest
vgo: finding golang.org/x/net latest
vgo: finding golang.org/x/sync latest
vgo: finding gopkg.in/yaml.v2 latest
vgo: finding github.com/mattn/go-colorable latest
vgo: finding github.com/mattn/go-isatty latest
vgo: finding golang.org/x/sys latest
vgo: finding gopkg.in/check.v1 latest

$ cat go.mod
module github.com/gobuffalo/pop

require (
	github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
	github.com/fatih/color v1.7.0
	github.com/go-sql-driver/mysql v1.3.0
	github.com/gobuffalo/envy v1.6.2
	github.com/gobuffalo/makr v1.1.0
	github.com/gobuffalo/packr v1.11.0
	github.com/gobuffalo/uuid v1.2.0
	github.com/gobuffalo/validate v1.0.0
	github.com/jmoiron/sqlx v0.0.0-20180406164412-2aeb6a910c2b
	github.com/joho/godotenv v1.2.0
	github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
	github.com/markbates/going v0.0.0-20170113214412-0576708c56ce
	github.com/markbates/inflect v0.0.0-20180514174915-dd7de90c06bc
	github.com/mattn/anko v0.0.4
	github.com/mattn/go-colorable v0.0.9
	github.com/mattn/go-isatty v0.0.3
	github.com/pkg/errors v0.8.0
	golang.org/x/net v0.0.0-20180522190444-9ef9f5bb98a1
	golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
	golang.org/x/sys v0.0.0-20180524125335-e2c7578ad1a9
	gopkg.in/check.v1 v1.0.0-20161208181325-20d25e280405
	gopkg.in/yaml.v2 v2.2.1
)

$ vgo build -v
github.com/gobuffalo/pop/associations
# github.com/gobuffalo/pop/associations
associations/many_to_many_association.go:135:10: assignment mismatch: 2 variables but 1 values
@markbates
Copy link
Member Author

Related to gobuffalo/buffalo#1074

/cc @rsc

@stanislas-m stanislas-m added the bug Something isn't working label May 24, 2018
@rsc
Copy link
Contributor

rsc commented May 24, 2018

This is what I see on github.com/gobuffalo/pop:

$ vgo build
vgo: downloading github.com/lib/pq v0.0.0-20180201184707-88edab080323
vgo: downloading github.com/fatih/color v1.6.0
vgo: downloading github.com/gobuffalo/envy v1.4.1
vgo: downloading github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747
vgo: downloading github.com/markbates/inflect v0.0.0-20180226203100-3e32b42850a9
vgo: downloading github.com/gobuffalo/packr v1.10.4
vgo: downloading github.com/mattn/anko v0.0.0-20180212145248-d5441ca3f0c7
vgo: import "github.com/gobuffalo/pop" ->
	import "github.com/gobuffalo/pop/fizz" ->
	import "github.com/mattn/anko/core" [/tmp/gopath/src/v/github.com/mattn/anko@v0.0.0-20180212145248-d5441ca3f0c7/core]: open /tmp/gopath/src/v/github.com/mattn/anko@v0.0.0-20180212145248-d5441ca3f0c7/core: no such file or directory
vgo: downloading github.com/jmoiron/sqlx v0.0.0-20180228184624-cf35089a1979
vgo: downloading golang.org/x/sync v0.0.0-20171101214715-fd80eb99c8f6
vgo: downloading golang.org/x/net v0.0.0-20180301190904-22ae77b79946
vgo: downloading gopkg.in/yaml.v2 v2.1.1
$ 

If Gopkg.lock exists, then vgo assumes it lists the right versions to use when bootstrapping a go.mod. But in this repo (at least on master, which is what "go get" downloaded for me), Gopkg.lock says to use github.com/mattn/anko@d5441ca3f0c, but that commit did not have a "core" package, so the import in github.com/gobuffalo/pop/fizz of github.com/mattn/anko/core fails during "vgo build".

If I run dep ensure, it revises Gopkg.lock to change github.com/mattn/anko to v0.0.4. After that, vgo build works:

$ ls -l go.mod
ls: go.mod: No such file or directory
$ vgo build
$ cat go.mod
module github.com/gobuffalo/pop

require (
	github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
	github.com/fatih/color v1.6.0
	github.com/go-sql-driver/mysql v0.0.0-20161201115036-a0583e0143b1
	github.com/gobuffalo/envy v1.4.1
	github.com/gobuffalo/makr v1.1.0
	github.com/gobuffalo/packr v1.10.4
	github.com/gobuffalo/uuid v0.0.0-20180207211247-3a9fb6c5c481
	github.com/gobuffalo/validate v0.0.0-20180210182920-42d8db6e06e6
	github.com/inconshreveable/mousetrap v0.0.0-20141017200713-76626ae9c91c
	github.com/jmoiron/sqlx v0.0.0-20180228184624-cf35089a1979
	github.com/joho/godotenv v1.2.0
	github.com/lib/pq v0.0.0-20180201184707-88edab080323
	github.com/markbates/going v0.0.0-20170113214412-0576708c56ce
	github.com/markbates/grift v0.0.0-20180108173051-5499956ce4d9
	github.com/markbates/inflect v0.0.0-20180226203100-3e32b42850a9
	github.com/mattn/anko v0.0.4
	github.com/mattn/go-sqlite3 v1.6.0
	github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747
	github.com/pkg/errors v0.8.0
	github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516
	github.com/spf13/cobra v0.0.1
	github.com/spf13/pflag v1.0.0
	github.com/stretchr/testify v1.2.1
	golang.org/x/net v0.0.0-20180301190904-22ae77b79946
	golang.org/x/sync v0.0.0-20171101214715-fd80eb99c8f6
	golang.org/x/sys v0.0.0-20180302081741-dd2ff4accc09
	gopkg.in/yaml.v2 v2.1.1
)
$

If I remove Gopkg.lock before running vgo build, then I do get your assignment mismatch error in pop/associations. The dep config has valuable information in it - vgo needs it to understand your intended start state.

In general if you find that vgo build is not working but you were happy with dep, then you should be able to

rm go.mod
dep ensure
vgo build

to convert over to vgo.

rsc added a commit to rsc/pop that referenced this issue May 24, 2018
The Gopkg.lock is broken if you use it with dep without an automatic update:

```
$ git clone https://github.com/gobuffalo/pop
Cloning into 'pop'...
remote: Counting objects: 5500, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 5500 (delta 6), reused 12 (delta 5), pack-reused 5481
Receiving objects: 100% (5500/5500), 4.47 MiB | 13.12 MiB/s, done.
Resolving deltas: 100% (3129/3129), done.
$ cd pop
$ dep ensure -vendor-only
$ go build
fizz/bubbler.go:31:30: cannot use "github.com/gobuffalo/pop/vendor/github.com/mattn/anko/vm".NewEnv() (type *"github.com/gobuffalo/pop/vendor/github.com/mattn/anko/vm".Env) as type *"github.com/mattn/anko/vm".Env in argument to core.Import
$
```

This CL fixes the Gopkg.lock:

```
$ dep ensure
$ go build
$
```

Fixes gobuffalo#109.
Fixes gobuffalo#110.
Probably also gobuffalo/buffalo#1075.
markbates pushed a commit that referenced this issue May 24, 2018
The Gopkg.lock is broken if you use it with dep without an automatic update:

```
$ git clone https://github.com/gobuffalo/pop
Cloning into 'pop'...
remote: Counting objects: 5500, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 5500 (delta 6), reused 12 (delta 5), pack-reused 5481
Receiving objects: 100% (5500/5500), 4.47 MiB | 13.12 MiB/s, done.
Resolving deltas: 100% (3129/3129), done.
$ cd pop
$ dep ensure -vendor-only
$ go build
fizz/bubbler.go:31:30: cannot use "github.com/gobuffalo/pop/vendor/github.com/mattn/anko/vm".NewEnv() (type *"github.com/gobuffalo/pop/vendor/github.com/mattn/anko/vm".Env) as type *"github.com/mattn/anko/vm".Env in argument to core.Import
$
```

This CL fixes the Gopkg.lock:

```
$ dep ensure
$ go build
$
```

Fixes #109.
Fixes #110.
Probably also gobuffalo/buffalo#1075.
@markbates markbates reopened this May 24, 2018
@markbates
Copy link
Member Author

Even after #111 was merged vgo still can't build this correctly:

$ cat go.mod
module github.com/gobuffalo/pop

$ vgo build -v
vgo: finding gopkg.in/yaml.v2 v2.2.1
vgo: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
vgo: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
vgo: finding golang.org/x/net v0.0.0-20180522190444-9ef9f5bb98a1
vgo: finding github.com/pkg/errors v0.8.0
vgo: finding github.com/mattn/anko v0.0.4
vgo: finding github.com/markbates/inflect v0.0.0-20180514174915-dd7de90c06bc
vgo: finding github.com/markbates/going v0.0.0-20170113214412-0576708c56ce
vgo: finding github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
vgo: finding github.com/joho/godotenv v1.2.0
vgo: finding github.com/jmoiron/sqlx v0.0.0-20180406164412-2aeb6a910c2b
vgo: finding github.com/gobuffalo/validate v1.0.0
vgo: finding github.com/gobuffalo/uuid v1.2.0
vgo: finding github.com/gobuffalo/packr v1.11.0
vgo: finding github.com/gobuffalo/makr v1.1.0
vgo: finding github.com/gobuffalo/envy v1.6.2
vgo: finding github.com/go-sql-driver/mysql v1.3.0
vgo: finding github.com/fatih/color v1.7.0
vgo: finding golang.org/x/sys v0.0.0-20180202135801-37707fdb30a5
vgo: finding github.com/mattn/go-isatty v0.0.3
vgo: finding github.com/mattn/go-colorable v0.0.9
vgo: finding github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
vgo: downloading github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
vgo: downloading github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
vgo: downloading github.com/fatih/color v1.7.0
vgo: downloading github.com/mattn/go-colorable v0.0.9
vgo: downloading github.com/mattn/go-isatty v0.0.3
vgo: downloading github.com/go-sql-driver/mysql v1.3.0
vgo: downloading github.com/gobuffalo/envy v1.6.2
vgo: downloading github.com/joho/godotenv v1.2.0
vgo: downloading github.com/gobuffalo/makr v1.1.0
vgo: downloading github.com/markbates/inflect v0.0.0-20180514174915-dd7de90c06bc
vgo: downloading github.com/pkg/errors v0.8.0
vgo: downloading github.com/gobuffalo/packr v1.11.0
vgo: downloading github.com/gobuffalo/uuid v1.2.0
vgo: downloading github.com/mattn/anko v0.0.4
vgo: downloading github.com/jmoiron/sqlx v0.0.0-20180406164412-2aeb6a910c2b
vgo: downloading github.com/gobuffalo/validate v1.0.0
vgo: downloading github.com/markbates/going v0.0.0-20170113214412-0576708c56ce
vgo: downloading golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
vgo: downloading golang.org/x/net v0.0.0-20180522190444-9ef9f5bb98a1
vgo: downloading gopkg.in/yaml.v2 v2.2.1
github.com/gobuffalo/pop/associations
# github.com/gobuffalo/pop/associations
associations/many_to_many_association.go:135:10: assignment mismatch: 2 variables but 1 values

The problem, @rsc, that I can is MVS keeps choosing this:

vgo: finding github.com/gobuffalo/uuid v1.2.0

when it should be:

vgo: finding github.com/gobuffalo/uuid v2.0.0

When making the change everything compiles correctly.

Some history behind that package, since I think it sheds some light on what's happening here.

The package is a fork of satori/go-uuid. They broke their API in release v1.2.0. The package was forked to gobuffalo/uuid and a v2.0.0 was issued.

@rsc
Copy link
Contributor

rsc commented May 24, 2018

If you rm go.mod first, then it works OK, because it will use Gopkg.lock to understand where you are starting from. With the 1-line go.mod, Gopkg.lock is not consulted. Maybe that's a bug; I need to think a bit about that. But that aside, because vgo thinks that go.mod need not be auto-migrated from dep, instead the build proceeds in its usual mode, which is to start with go.mod and then only make changes as new imports are found during the build. When it does find a new import, it looks for the latest of the corresponding module, and that's not right for github.com/gobuffalo/uuid.

Semantic import versioning means that v2 of github.com/gobuffalo/uuid needs to be imported as github.com/gobuffalo/uuid/v2, but this code is importing plain github.com/gobuffalo/uuid, so it only considers v1 tags. In the long term, once we've issued point releases for older Go versions so that everything will accept the /v2/ in the import path, the fix would be to change your source code to import github.com/gobuffalo/uuid/v2, and then vgo's defaults and the code would line up and all would be well. That's not something you should do today, though, since you want things to keep working with non-vgo users.

The way to import the v2.0.0 tag of the (non-v2) github.com/gobuffalo/uuid module is to use a pseudo-version, in this case v0.0.0-20180207211247-3a9fb6c5c481. But you don't need to figure out that syntax. If you edit go.mod to change the chosen v1.2.0 to v2.0.0, the next vgo run will understand that you're asking for the v2.0.0 tag in a non-semantic-import-versioning repo and replace the v2.0.0 with the pseudo-version:

$ echo module github.com/gobuffalo/pop >go.mod
$ vgo build -v
vgo: resolving import "github.com/cockroachdb/cockroach-go/crdb"
vgo: finding github.com/cockroachdb/cockroach-go (latest)
...
github.com/gobuffalo/pop/associations
# github.com/gobuffalo/pop/associations
associations/many_to_many_association.go:135:10: assignment mismatch: 2 variables but 1 values
$ ed go.mod
830
/uuid
	github.com/gobuffalo/uuid v1.2.0
s/v1.2.0/v2.0.0
	github.com/gobuffalo/uuid v2.0.0
w
830
q
$ vgo build -v
$ grep uuid go.mod
	github.com/gobuffalo/uuid v0.0.0-20180207211247-3a9fb6c5c481
$ 

Instead of editing go.mod directly, it's supposed to work to run vgo get github.com/gobuffalo/uuid@v2.0.0, but that didn't work for me. I filed golang/go#25542 for that.

@rsc
Copy link
Contributor

rsc commented May 24, 2018

I submitted a fix to vgo to still convert Gopkg.lock even when there is a 1-line go.mod with only a module line. The "vgo build -v" with the 1-line go.mod should work for you now (if you go get -u golang.org/x/vgo).

@stanislas-m
Copy link
Member

@markbates Do you still have issues to use Pop with vgo?

@stanislas-m
Copy link
Member

Closing as a dup of #110.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants