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

Cannot go get from a fresh machine #155

Closed
mauleyzaola opened this issue Nov 18, 2019 · 18 comments
Closed

Cannot go get from a fresh machine #155

mauleyzaola opened this issue Nov 18, 2019 · 18 comments

Comments

@mauleyzaola
Copy link

mauleyzaola commented Nov 18, 2019

This is a machine which has no golang code on it, like a fresh install

OUTPUT

mau@mbp15:~$ go get -v github.com/rubenv/sql-migrate/...
github.com/rubenv/sql-migrate (download)
get "gopkg.in/gorp.v1": found meta tag get.metaImport{Prefix:"gopkg.in/gorp.v1", VCS:"git", RepoRoot:"https://gopkg.in/gorp.v1"} at //gopkg.in/gorp.v1?go-get=1
gopkg.in/gorp.v1 (download)
github.com/denisenkom/go-mssqldb (download)
github.com/golang-sql/civil (download)
get "golang.org/x/crypto/md4": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at //golang.org/x/crypto/md4?go-get=1
get "golang.org/x/crypto/md4": verifying non-authoritative meta tag
golang.org/x/crypto (download)
github.com/go-sql-driver/mysql (download)
github.com/lib/pq (download)
github.com/mattn/go-sqlite3 (download)
github.com/mitchellh/cli (download)
github.com/armon/go-radix (download)
github.com/bgentry/speakeasy (download)
github.com/fatih/color (download)
github.com/mattn/go-isatty (download)
github.com/posener/complete (download)
github.com/hashicorp/go-multierror (download)
github.com/hashicorp/errwrap (download)
package github.com/rubenv/sql-migrate/sql-migrate
	imports github.com/posener/complete/cmd/install: cannot find package "github.com/posener/complete/cmd/install" in any of:
	/usr/local/Cellar/go/1.13.4/libexec/src/github.com/posener/complete/cmd/install (from $GOROOT)
	/Users/mau/go/src/github.com/posener/complete/cmd/install (from $GOPATH)
github.com/olekukonko/tablewriter (download)
github.com/mattn/go-runewidth (download)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at //gopkg.in/yaml.v2?go-get=1

ENVIRONMENT

mau@mbp15:~$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mau/Library/Caches/go-build"
GOENV="/Users/mau/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mau/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/82/3klc7kss6wgfrx9t54sdd8zw0000gn/T/go-build159606206=/tmp/go-build -gno-record-gcc-switches -fno-common"
@jaimem88
Copy link

I cannot seem to import this library anymore, it seems to be some dependency to https://github.com/mattn/go-sqlite3 which has a recently closed issue here but I don't think it's fixed properly

If i try to go get -u github.com/rubenv/sql-migrate

I see the following error

build github.com/rubenv/sql-migrate/sql-migrate: cannot load github.com/mattn/go-sqlite3: module github.com/mattn/go-sqlite3@latest found (v2.0.0+incompatible), but does not contain package github.com/mattn/go-sqlite3

@martin-flower
Copy link

Looks like github.com/posener/complete latest has been updated with a breaking version change - how does sql-migrate manage its own dependencies?

@drscre
Copy link

drscre commented Nov 18, 2019

TL/DR:
GO111MODULE=on GOPRIVATE=github.com/mattn/go-sqlite3 go get github.com/rubenv/sql-migrate/...

details:
sql-migrate depends on github.com/mitchellh/cli, which in turn depends on github.com/posener/complete

This error happens because you try to go get github.com/rubenv/sql-migrate/... in no-module aware mode, but:
posener/complete was upgraded to v2
while
mitchellh/cli still relies on posener/complete v1

Since in your case go get does not know about modules, it will try to download latest posener/complete v2 from master branch, which does not work with mitchellh/cli.

You can fix this by installing sql-migrate in module-aware mode.

But, then you will bump into another unrelated error described here mattn/go-sqlite3#755.
To temporary work around it you should disable proxy cache for go-sqlite3:

GO111MODULE=on GOPRIVATE=github.com/mattn/go-sqlite3 go get github.com/rubenv/sql-migrate/...

@rubenv
Copy link
Owner

rubenv commented Nov 18, 2019

This sounds like a bug in mattn/go-sqlite3 rather than sql-migrate?

I don't want to require module support (even though it's great), so there's nothing we can do here.

@drscre
Copy link

drscre commented Nov 18, 2019

It is more like go mod nuances.
The trouble here is that github.com/posener/complete decided to release v2 directly into master instead of keeping it in a separate /v2/ subdirectory or branch. Contrary to the recommendation here:
https://blog.golang.org/v2-go-modules (see Major version strategies section)

@martin-flower
Copy link

martin-flower commented Nov 18, 2019

We run Go 1.13 - does that mean we should not use GO111MODULE=on in the workaround?

To answer my own question, yes GO111MODULE=on is necessary

@posener
Copy link
Contributor

posener commented Nov 18, 2019

Hi, I am sorry for causing this bug.

It looks like this project depends on github.com/mitchellh/cli which depends on github.com/posener/complete.

I don't like the v2 directory solution as versioning solution in Go. The v1 is still available through git branch or git tags, also proposed by the strategies in the Go blog.

About solutions:
I can revert the change and push the change to a v2 directory in my project. However, I would prefer if we could add go modules support to this project? I can try to help if this is needed.

@rubenv
Copy link
Owner

rubenv commented Nov 18, 2019

Hi, I am sorry for causing this bug.

No worries, that happens!

@drscre
Copy link

drscre commented Nov 18, 2019

@posener If adding /v2/ subdir feels ugly, maybe you can create a new v2 branch (and make it github default)?
Who knows what other tools depending on github.com/mitchellh/cli can break.

@posener
Copy link
Contributor

posener commented Nov 19, 2019

@drscre good idea!
I've made this PR mitchellh/cli#80 to fix the cli package.
When trying to have go modules in this library there is the error of this issue: mattn/go-sqlite3#755. I think adding go modules support in go-sqlite3 will fix it?
If mitchellh won't merge the PR in the next few days, I'll update my library as you say.

@posener
Copy link
Contributor

posener commented Nov 19, 2019

I'm having troubles there, since the CLI library should also be compatible with older Go versions.
I took you advice, set the master to point on v1 and set v2 to be the default branch.
See if that works for you.
Thanks

@mauleyzaola
Copy link
Author

mauleyzaola commented Nov 19, 2019

This needs more work, just tested it on a fresh linux box and still not building.
As a temporary workaround I forked this repo, grabbed the dependencies via dep ensure and push them all to my forked repo.
That compiles well but has the obvious disadvantages.
Just in case someone else is struggling with this issue.

@posener
Copy link
Contributor

posener commented Nov 19, 2019 via email

@mauleyzaola
Copy link
Author

@posener Yeah

ubuntu@server:~$ go get -v github.com/rubenv/sql-migrate/...
github.com/rubenv/sql-migrate (download)
created GOPATH=/home/ubuntu/go; see 'go help gopath'
get "gopkg.in/gorp.v1": found meta tag get.metaImport{Prefix:"gopkg.in/gorp.v1", VCS:"git", RepoRoot:"https://gopkg.in/gorp.v1"} at //gopkg.in/gorp.v1?go-get=1
gopkg.in/gorp.v1 (download)
github.com/denisenkom/go-mssqldb (download)
github.com/golang-sql/civil (download)
get "golang.org/x/crypto/md4": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at //golang.org/x/crypto/md4?go-get=1
get "golang.org/x/crypto/md4": verifying non-authoritative meta tag
golang.org/x/crypto (download)
github.com/go-sql-driver/mysql (download)
github.com/lib/pq (download)
github.com/mattn/go-sqlite3 (download)
github.com/mitchellh/cli (download)
github.com/armon/go-radix (download)
github.com/bgentry/speakeasy (download)
github.com/fatih/color (download)
github.com/mattn/go-isatty (download)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at //golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
golang.org/x/sys (download)
github.com/posener/complete (download)
github.com/hashicorp/go-multierror (download)
github.com/hashicorp/errwrap (download)
package github.com/rubenv/sql-migrate/sql-migrate
	imports github.com/posener/complete/cmd/install: cannot find package "github.com/posener/complete/cmd/install" in any of:
	/usr/local/go/src/github.com/posener/complete/cmd/install (from $GOROOT)
	/home/ubuntu/go/src/github.com/posener/complete/cmd/install (from $GOPATH)
github.com/olekukonko/tablewriter (download)
github.com/mattn/go-runewidth (download)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at //gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)
ubuntu@server:~$ which sql-migrate
ubuntu@server:~$ go version
go version go1.13.4 linux/amd64

@louisjimenez
Copy link

FYI we are also seeing the indirect dependency through github.com/mitchellh/cli on github.com/posener/complete break the build for Spinnaker's CLI tool. Thank you for opening mitchellh/cli#80

@drscre
Copy link

drscre commented Nov 20, 2019

@posener it turns out that go get uses default branch, not master :/. You should change default branch back to master in GitHub repo settings. Sorry for misleading you.

lukas-brenning added a commit to lukas-brenning/sql-migrate that referenced this issue Nov 20, 2019
rubenv#155
posener/complete#107

Posener introduced breaking changes to the `complete` repository,
`sql-migrate` depends on that repository and can therefore not be built
anymore.
Intermediate solution is to fork repo and push dependencies.
@posener
Copy link
Contributor

posener commented Nov 20, 2019 via email

@posener
Copy link
Contributor

posener commented Nov 22, 2019

I think you can close this issue.
If you are interesting on insights from this journey, I've written a blog post on it :-) https://posener.github.io/branch-strategy/

Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants