gobuffalo / buffalo

Rapid Web Development w/ Go
http://gobuffalo.io
MIT License
8.08k stars 576 forks source link

Buffalo apps don't compile with vgo #1075

Closed markbates closed 6 years ago

markbates commented 6 years ago

Reproducible Dockerfile

FROM gobuffalo/buffalo:development as builder

RUN go get -v golang.org/x/vgo
RUN mkdir -p $GOPATH/src/github.com/markbates

WORKDIR $GOPATH/src/github.com/markbates

RUN buffalo new coke --skip-webpack
WORKDIR $GOPATH/src/github.com/markbates/coke

RUN echo "module github.com/markbates/coke" >> go.mod
RUN vgo build -v
# RUN cat go.mod
#
# RUN vgo get -u
# RUN cat go.mod
#
#
# RUN vgo build -v
Step 8/12 : RUN vgo build -v
 ---> Running in a5966bdedda5
vgo: resolving import "github.com/gobuffalo/buffalo"
vgo: finding github.com/gobuffalo/buffalo (latest)
vgo: adding github.com/gobuffalo/buffalo v0.11.1
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/packr"
vgo: finding github.com/gobuffalo/packr (latest)
vgo: adding github.com/gobuffalo/packr v1.11.0
vgo: resolving import "github.com/gobuffalo/pop"
vgo: finding github.com/gobuffalo/pop (latest)
vgo: adding github.com/gobuffalo/pop v0.0.0-20180521154020-9985012f32f5
vgo: resolving import "github.com/unrolled/secure"
vgo: finding github.com/unrolled/secure (latest)
vgo: adding github.com/unrolled/secure v0.0.0-20180416205222-a1cf62cc2159
vgo: finding github.com/unrolled/secure v0.0.0-20180416205222-a1cf62cc2159
vgo: finding github.com/gobuffalo/pop v0.0.0-20180521154020-9985012f32f5
vgo: finding gopkg.in/yaml.v2 v2.1.1
vgo: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
vgo: finding golang.org/x/sys v0.0.0-20180302081741-dd2ff4accc09
vgo: finding golang.org/x/sync v0.0.0-20171101214715-fd80eb99c8f6
vgo: finding golang.org/x/net v0.0.0-20180301190904-22ae77b79946
vgo: finding github.com/stretchr/testify v1.2.1
vgo: finding github.com/stretchr/objx v0.0.0-20180106011353-facf9a85c22f
vgo: finding github.com/stretchr/testify v1.2.0
vgo: finding github.com/stretchr/objx v0.0.0-20140526180921-cbeaeb16a013
vgo: finding github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0
vgo: finding github.com/spf13/pflag v1.0.0
vgo: finding github.com/spf13/cobra v0.0.1
vgo: finding github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516
vgo: finding github.com/pmezard/go-difflib v1.0.0
vgo: finding github.com/pkg/errors v0.8.0
vgo: finding github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747
vgo: finding github.com/mattn/go-sqlite3 v1.6.0
vgo: finding github.com/mattn/go-isatty v0.0.3
vgo: finding github.com/mattn/go-colorable v0.0.9
vgo: finding github.com/mattn/anko v0.0.0-20180212145248-d5441ca3f0c7
vgo: finding github.com/markbates/inflect v0.0.0-20180226203100-3e32b42850a9
vgo: finding github.com/markbates/grift v0.0.0-20180108173051-5499956ce4d9
vgo: finding github.com/markbates/going v0.0.0-20170113214412-0576708c56ce
vgo: finding github.com/lib/pq v0.0.0-20180201184707-88edab080323
vgo: finding github.com/joho/godotenv v1.2.0
vgo: finding github.com/jmoiron/sqlx v0.0.0-20180228184624-cf35089a1979
vgo: finding github.com/inconshreveable/mousetrap v0.0.0-20141017200713-76626ae9c91c
vgo: finding github.com/gobuffalo/validate v0.0.0-20180210182920-42d8db6e06e6
vgo: finding github.com/gobuffalo/uuid v0.0.0-20180207211247-3a9fb6c5c481
vgo: finding github.com/gobuffalo/packr v1.10.4
vgo: finding github.com/gobuffalo/makr v1.1.0
vgo: finding github.com/gobuffalo/envy v1.4.1
vgo: finding github.com/go-sql-driver/mysql v0.0.0-20161201115036-a0583e0143b1
vgo: finding github.com/fatih/color v1.6.0
vgo: finding golang.org/x/sys v0.0.0-20180202135801-37707fdb30a5
vgo: finding github.com/daviddengcn/go-colortext v0.0.0-20171126034257-17e75f6184bc
vgo: finding github.com/davecgh/go-spew v1.1.0
vgo: finding github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
vgo: finding github.com/gobuffalo/packr v1.11.0
vgo: finding github.com/gobuffalo/envy v1.6.2
vgo: finding github.com/gobuffalo/buffalo v0.11.1
vgo: downloading github.com/gobuffalo/buffalo v0.11.1
vgo: downloading github.com/fatih/color v1.6.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/gobuffalo/pop v0.0.0-20180521154020-9985012f32f5
vgo: downloading github.com/gobuffalo/uuid v0.0.0-20180207211247-3a9fb6c5c481
vgo: downloading github.com/pkg/errors v0.8.0
vgo: downloading github.com/gobuffalo/packr v1.11.0
vgo: downloading github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
vgo: downloading github.com/lib/pq v0.0.0-20180201184707-88edab080323
vgo: downloading github.com/go-sql-driver/mysql v0.0.0-20161201115036-a0583e0143b1
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-20180226203100-3e32b42850a9
vgo: downloading github.com/mattn/anko v0.0.0-20180212145248-d5441ca3f0c7
vgo: import "github.com/markbates/coke" ->
    import "github.com/markbates/coke/actions" ->
    import "github.com/gobuffalo/buffalo" ->
    import "github.com/gobuffalo/buffalo/render" ->
    import "github.com/gobuffalo/pop" ->
    import "github.com/gobuffalo/pop/fizz" ->
    import "github.com/mattn/anko/core" [/go/src/v/github.com/mattn/anko@v0.0.0-20180212145248-d5441ca3f0c7/core]: open /go/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 github.com/gobuffalo/validate v0.0.0-20180210182920-42d8db6e06e6
vgo: downloading github.com/markbates/going v0.0.0-20170113214412-0576708c56ce
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
vgo: downloading github.com/markbates/grift v0.0.0-20180108173051-5499956ce4d9
vgo: downloading github.com/unrolled/secure v0.0.0-20180416205222-a1cf62cc2159
vgo: resolving import "github.com/dustin/go-humanize"
vgo: finding github.com/dustin/go-humanize (latest)
vgo: adding github.com/dustin/go-humanize v0.0.0-20180421182945-02af3965c54e
vgo: resolving import "github.com/gobuffalo/x/httpx"
vgo: finding github.com/gobuffalo/x (latest)
vgo: adding github.com/gobuffalo/x v0.0.0-20180117215853-11ca13c05abd
vgo: resolving import "github.com/monoculum/formam"
vgo: finding github.com/monoculum/formam (latest)
vgo: adding github.com/monoculum/formam v0.0.0-20170814190438-f25191ae7744
vgo: resolving import "github.com/gobuffalo/plush"
vgo: finding github.com/gobuffalo/plush (latest)
vgo: adding github.com/gobuffalo/plush v1.0.0
vgo: resolving import "github.com/gobuffalo/tags"
vgo: finding github.com/gobuffalo/tags (latest)
vgo: adding github.com/gobuffalo/tags v1.9.6
vgo: resolving import "github.com/russross/blackfriday"
vgo: finding github.com/russross/blackfriday (latest)
vgo: adding github.com/russross/blackfriday v1.5.1
vgo: resolving import "github.com/shurcooL/github_flavored_markdown"
vgo: finding github.com/shurcooL/github_flavored_markdown (latest)
vgo: adding github.com/shurcooL/github_flavored_markdown v0.0.0-20171120162553-28433ea3fc83
vgo: resolving import "github.com/sirupsen/logrus"
vgo: finding github.com/sirupsen/logrus (latest)
vgo: adding github.com/sirupsen/logrus v1.0.5
vgo: resolving import "github.com/gorilla/context"
vgo: finding github.com/gorilla/context (latest)
vgo: adding github.com/gorilla/context v1.1.1
vgo: resolving import "github.com/gorilla/mux"
vgo: finding github.com/gorilla/mux (latest)
vgo: adding github.com/gorilla/mux v1.6.2
vgo: resolving import "github.com/gorilla/sessions"
vgo: finding github.com/gorilla/sessions (latest)
vgo: adding github.com/gorilla/sessions v0.0.0-20180514193723-9ee0d62e031e
vgo: resolving import "github.com/gorilla/websocket"
vgo: finding github.com/gorilla/websocket (latest)
vgo: adding github.com/gorilla/websocket v1.2.0
vgo: resolving import "github.com/markbates/refresh/refresh/web"
vgo: finding github.com/markbates/refresh (latest)
vgo: adding github.com/markbates/refresh v1.4.0
vgo: resolving import "github.com/markbates/sigtx"
vgo: finding github.com/markbates/sigtx (latest)
vgo: adding github.com/markbates/sigtx v1.0.0
vgo: resolving import "golang.org/x/crypto/bcrypt"
vgo: finding golang.org/x/crypto (latest)
vgo: adding golang.org/x/crypto v0.0.0-20180524125353-159ae71589f3
vgo: resolving import "github.com/nicksnyder/go-i18n/i18n"
vgo: finding github.com/nicksnyder/go-i18n (latest)
vgo: adding github.com/nicksnyder/go-i18n v1.10.0
The command '/bin/sh -c vgo build -v' returned a non-zero code: 1

Related to #1074 /cc @rsc

rsc commented 6 years ago

I didn't try to reproduce this, because even if I could it's hard to test a fix. But this error is the same error as I saw in gobuffalo/pop#109 and as you saw in gobuffalo/pop#110 (github.com/mattn/anko/core not existing in mattn/anko@d5441ca3f0c7), so I'm fairly confident it's the same as those.

To recap, the problem is that vgo grabs gobuffalo/pop, finds a Gopkg.lock, and assumes it is a correct statement of the versions it should use. In this case, it appears that gobuffalo/pop has specified the wrong version of mattn/anko. Because dep is so aggressive about updating beyond what's in the lock file, no one noticed. But if you tell dep "no really I want to use what's in the lock file", it too will break:

$ cd $GOPATH/src/github.com/gobuffalo
$ 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
# github.com/gobuffalo/pop/fizz
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
$ 

There are two possible ways forward. The simplest is just to fix the Gopkg.lock. I sent you https://github.com/gobuffalo/pop/pull/111 to do that. If you merge that change and get it into the docker environment, then I think your example here will start working.

The next step would be to publish a go.mod in the repo too, but that's not necessary to make vgo start working for users.

rsc commented 6 years ago

Haven't tried inside docker yet (my docker daemon is apparently ill) but running these commands by hand, they work after gobuffalo/pop#111.

markbates commented 6 years ago

I'm re-opening this issue as with 1.11-tip, Go modules still do not work correctly with Buffalo.