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

Unable to generate glide.lock when testImport is being used #597

Open
HelloGrayson opened this issue Sep 2, 2016 · 8 comments
Open

Unable to generate glide.lock when testImport is being used #597

HelloGrayson opened this issue Sep 2, 2016 · 8 comments

Comments

@HelloGrayson
Copy link
Contributor

I'm trying to move my libs test deps out of import and into testImport, so that my lib doesn't impose constraints on my users test dependencies.

I've updated my glide.yaml to move the test deps into testImport:

package: github.com/yarpc/yarpc-go

import:
- package: golang.org/x/net
  version: master
  subpackages:
  - context
  - context/ctxhttp
- package: github.com/thriftrw/thriftrw-go
  version: ~0.1
- package: github.com/uber/tchannel-go
  version: ^1.0.9

testImport:
- package: github.com/stretchr/testify
  version: master
  subpackages:
  - assert
  - require
- package: github.com/golang/mock
  version: master
  subpackages:
  - gomock
- package: github.com/crossdock/crossdock-go
  version: master

But when I run glide up I get the error Failed to generate lock file: Generating lock produced conflicting versions of github.com/golang/mock. import (), testImport (master):

yarpc/yarpc-go - [move-test-deps] » rm -rf vendor
yarpc/yarpc-go - [move-test-deps] » rm -rf glide.lock
yarpc/yarpc-go - [move-test-deps] » glide up
[INFO]  Downloading dependencies. Please wait...
[INFO]  --> Fetching updates for github.com/uber/tchannel-go.
[INFO]  --> Fetching updates for github.com/thriftrw/thriftrw-go.
[INFO]  --> Fetching updates for golang.org/x/net.
[INFO]  --> Fetching updates for github.com/crossdock/crossdock-go.
[INFO]  --> Fetching updates for github.com/stretchr/testify.
[INFO]  --> Fetching updates for github.com/golang/mock.
[INFO]  --> Setting version for github.com/golang/mock to master.
[INFO]  --> Setting version for github.com/stretchr/testify to master.
[INFO]  --> Setting version for github.com/crossdock/crossdock-go to master.
[INFO]  --> Detected semantic version. Setting version for github.com/thriftrw/thriftrw-go to v0.1.0.
[INFO]  --> Detected semantic version. Setting version for github.com/uber/tchannel-go to v1.1.0.
[INFO]  --> Setting version for golang.org/x/net to master.
[INFO]  Resolving imports
[INFO]  --> Fetching updates for github.com/opentracing/opentracing-go.
[INFO]  --> Fetching updates for github.com/uber-go/atomic.
[INFO]  --> Fetching updates for github.com/apache/thrift.
[INFO]  --> Setting version for github.com/apache/thrift to master.
[INFO]  --> Fetching updates for github.com/davecgh/go-spew.
[INFO]  --> Setting version for github.com/davecgh/go-spew to master.
[INFO]  --> Setting version for github.com/stretchr/testify to master.
[INFO]  --> Fetching updates for github.com/pmezard/go-difflib.
[INFO]  --> Setting version for github.com/pmezard/go-difflib to master.
[INFO]  Downloading dependencies. Please wait...
[INFO]  Setting references for remaining imports
[INFO]  Exporting resolved dependencies...
[INFO]  --> Exporting github.com/thriftrw/thriftrw-go
[INFO]  --> Exporting github.com/crossdock/crossdock-go
[INFO]  --> Exporting github.com/uber-go/atomic
[INFO]  --> Exporting github.com/uber/tchannel-go
[INFO]  --> Exporting github.com/apache/thrift
[INFO]  --> Exporting github.com/stretchr/testify
[INFO]  --> Exporting github.com/davecgh/go-spew
[INFO]  --> Exporting github.com/pmezard/go-difflib
[INFO]  --> Exporting github.com/golang/mock
[INFO]  --> Exporting github.com/opentracing/opentracing-go
[INFO]  --> Exporting golang.org/x/net
[INFO]  --> Exporting github.com/stretchr/testify
[INFO]  --> Exporting github.com/crossdock/crossdock-go
[INFO]  --> Exporting github.com/golang/mock
[INFO]  Replacing existing vendor dependencies
[ERROR] Failed to generate lock file: Generating lock produced conflicting versions of github.com/golang/mock. import (), testImport (master)

The version of glide at hand is 0.12.0:

$ glide --version
glide version 0.12.0-dev

And there is a branch to reproduce this here, just run this:

$ git clone git@github.com:yarpc/yarpc-go.git
$ git co move-test-deps
$ glide up

Is there a way to dump more info about the error?

@aeneasr
Copy link

aeneasr commented Sep 29, 2016

I can confirm this. I am using the latest master (because no easy way to install binaries on windows).

glide.yaml

package: github.com/ory-am/editor-platform/firewall-reverse-proxy
import:
- package: github.com/Sirupsen/logrus
  version: ~0.10.0
- package: github.com/golang/mock
  subpackages:
  - gomock
- package: github.com/ory-am/common
  subpackages:
  - compiler
  - env
- package: github.com/ory-am/fosite
  version: ~0.3.2
- package: github.com/ory-am/hydra
  version: ~0.5.2
  subpackages:
  - firewall
  - sdk
- package: github.com/ory-am/ladon
  version: ~0.2.0
- package: github.com/pkg/errors
  version: ~0.7.0
- package: golang.org/x/net
  subpackages:
  - context
testImport:
- package: github.com/stretchr/testify
  version: ~1.1.0
  subpackages:
  - assert
  - require

log:

...
[INFO]  --> Exporting gopkg.in/yaml.v2
[INFO]  --> Exporting github.com/spf13/jwalterweatherman
[INFO]  --> Exporting github.com/stretchr/testify
[INFO]  --> Exporting github.com/spf13/cast
[INFO]  --> Exporting gopkg.in/dancannon/gorethink.v2
[INFO]  --> Exporting github.com/kr/fs
[INFO]  --> Exporting gopkg.in/fatih/pool.v2
[INFO]  --> Exporting golang.org/x/text
[INFO]  --> Exporting gopkg.in/square/go-jose.v1
[INFO]  Replacing existing vendor dependencies
[ERROR] Failed to generate lock file: Generating lock produced conflicting versions of github.com/stretchr/testify. import (~1.1.3), testImport (~1.1.0)

@novas0x2a
Copy link

novas0x2a commented Nov 24, 2016

Neither of these two above yaml files produce an error for me with the current release of glide (0.12.3); however, I ran into a very similar problem. I'm not sure if this is the entire problem or not, but I think what is happening is that:

  1. Top-level glide.yaml indicates that pkg-A and pkg-B are testImport
  2. During glide update, glide notices that pkg-B has a Godeps.json that depends on pkg-A
  3. Glide loads pkg-A as an import even though it came in via a testImport Godeps
  4. Conflict if pkg-B -> pkg-A (import) is a different version from pkg-A (testImport).

I think common packages are almost certain to cause this problem; my conflict was on go-diff, which is a dep of testify, and my workaround was to move go-diff from a testImport to an import in my glide.yaml since import package versions trump testImport package versions.

@glibsm
Copy link

glibsm commented Jan 18, 2017

Ran into the same problem.
Can confirm that moving to regular import works (@novas0x2a solution)

@mwf
Copy link

mwf commented Mar 13, 2017

I ran into the same problem.

It's interesting.
After moving testImport to import and making glide up I moved the dependencies back to testImport. Then ran glide up again, and it ran without errors!

@stevenroose
Copy link
Contributor

stevenroose commented Mar 28, 2017

I think the best solution easiest workaround is to don't have a version constraint on your test dependencies.

@aeneasr
Copy link

aeneasr commented Mar 28, 2017

I think the best solution is to don't have a version constraint on your test dependencies.

I strongly disagree

@stevenroose
Copy link
Contributor

@arekkas well, "best solution" might have been a bad expression of what I meant. Let me rephrase to "easiest workaround".

@hoshsadiq
Copy link

Not having a version constraint doesn't work either:

package: company/team/myapp
testImport:
- package: github.com/imdario/mergo

resulting in the following error

[INFO]	Replacing existing vendor dependencies
[ERROR]	Failed to generate lock file: Generating lock produced conflicting versions of github.com/imdario/mergo. import (6633656539c1639d9d78127b7d47c622b5d7b6dc), testImport ()

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