Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Using dep with go-git prevents updates past 4.0.0-rc5. Possible relative import issue? #635

Closed
jlovero-isp opened this issue Nov 3, 2017 · 6 comments

Comments

@jlovero-isp
Copy link

Hello.

My project is using dep for dependency management. When I added the gopkg.in/src-d/go-git.v4 package using dep, I noticed that it had brought down version 4.0.0-rc5, which is quite out of date and does not have the git.PlainOpen function that I would like to use. When I try to force dep to use a more recent version, it gives me the following error:

v4.0.0-rc8: Could not introduce gopkg.in/src-d/[email protected], as its subpackage gopkg.in/src-d/go-git.v4 does not contain usable Go code (*pkgtree.NonCanonicalImportRoot).. (Package is required by (root).)

Doing a little digging, I saw that there's an open issue for a similar error message on the dep GitHub page: golang/dep#899. tl;dr dep does not allow relative imports and never will.

Thing is, though, I can't find any relative imports in go-git, so perhaps that's not the issue here? Or perhaps I'm not doing the proper search. Either way, I imagine that you would like for the official Go dependency management tool to correctly resolve dependencies to your library. Anyone have any ideas about what might be happening here?

Thanks.

@xescugc
Copy link

xescugc commented Nov 15, 2017

I I'll provide more logs about it which may be interesting, this happends when forcing the last verion, or just doing a dep ensure -v whith the import in your code:

(49)  ? attempt gopkg.in/src-d/go-git.v4 with 2 pkgs; 16 versions to try
(49)      try gopkg.in/src-d/[email protected]
(49)  ✗   unable to deduce repository and source type for "srcd.works/go-billy.v1": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://srcd.works/go-billy.v1?go-get=1": Get http://srcd.works/go-billy.v1?go-get=1: EOF
(49)      try gopkg.in/src-d/[email protected]
(50)  ✗   gopkg.in/src-d/go-git.v4 at v4.0.0-rc8 has problem subpkg(s):
(50)    	gopkg.in/src-d/go-git.v4 has err (*pkgtree.NonCanonicalImportRoot); required by (root).
(49)      try gopkg.in/src-d/[email protected]
(49)  ✗   unable to deduce repository and source type for "srcd.works/go-billy.v1": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://srcd.works/go-billy.v1?go-get=1": Get http://srcd.works/go-billy.v1?go-get=1: EOF
(49)      try gopkg.in/src-d/[email protected]
(49)  ✗   unable to deduce repository and source type for "srcd.works/go-billy.v1": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://srcd.works/go-billy.v1?go-get=1": Get http://srcd.works/go-billy.v1?go-get=1: EOF
(49)      try gopkg.in/src-d/[email protected]
(49)  ✓ select gopkg.in/src-d/[email protected] w/29 pkgs

@xescugc
Copy link

xescugc commented Nov 16, 2017

After a little bit of investigation I've found that it may be related to #380 and the solution mentioned for now is:

[[dependencies]]
  name = "gopkg.in/src-d/go-git.v4"
  revision = "727bf94da8e3cebd3ff467d30425b12d671fbca7"
  source = "https://github.com/src-d/go-git"

On revision adding the las commit and instead of dependencies use constraint so:

[[constraint]]
  name = "gopkg.in/src-d/go-git.v4"
  revision = "63f480619b2795a6bb4f7d7d4ebbcc385688c0b4"
  source = "https://github.com/src-d/go-git"

But the Issue is still there IMO

@jlovero-isp
Copy link
Author

Thank you @xescugc. Specifying a specific commit from github did the trick, though I'm not sure why exactly. Part of the problem here is that dep doesn't correctly parse the release candidate version numbers (e.g. it sees 4.0.0-rc2 as being more recent than 4.0.0-rc15), so it misses the most current releases to try when it attempts to resolve a working version.

@jlovero-isp
Copy link
Author

BTW, I just ran a little test to see if the source value pointing at GitHub was necessary. It was not.

[[constraint]]
  name = "gopkg.in/src-d/go-git.v4"
  revision = "f9879dd043f84936a1f8acb8a53b74332a7ae135"

This worked just fine. (That's the commit for v4.0.0-rc15, BTW)

Closing this issue. Thanks again!

@sdboyer
Copy link

sdboyer commented Nov 26, 2017

just confirming that adding the source field is not necessary (or desirable).

@sjansen
Copy link
Contributor

sjansen commented Nov 26, 2017

An alternative solution for dep's Gopkg.toml:

[[constraint]]
  name = "gopkg.in/src-d/go-git.v4"
  version = "=4.0.0-rc15"

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

No branches or pull requests

4 participants