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

dep: unable to solve the dependency graph / mod: error loading module requirements #10

Open
universam1 opened this issue Apr 17, 2019 · 10 comments
Labels
upstream-bug wontfix This will not be worked on

Comments

@universam1
Copy link

Describe the bug
When I try to include this library, dep errors because of malformed code

To Reproduce

  1. create new go file
  2. import "github.com/atlassian/go-artifactory/artifactory"
  3. run dep init

Expected behavior
to resolve this library

Log Output

dep init
init failed: unable to solve the dependency graph: Solving failure: No versions of github.com/atlassian/go-artifactory met constraints:
	v2.2.0: "github.com/atlassian/go-artifactory/artifactory" imports "github.com/atlassian/go-artifactory/v2/artifactory/client", which contains malformed code: no package exists at "github.com/atlassian/go-artifactory/v2/artifactory/client"
	v2.1.1: "github.com/atlassian/go-artifactory/artifactory" imports "github.com/atlassian/go-artifactory/v2/artifactory/client", which contains malformed code: unknown error for "github.com/atlassian/go-artifactory/v2/artifactory/client", if you get this error see https://github.com/golang/dep/issues/351
	v2.1.0: "github.com/atlassian/go-artifactory/artifactory" imports "github.com/atlassian/go-artifactory/v2/artifactory/client", which contains malformed code: unknown error for "github.com/atlassian/go-artifactory/v2/artifactory/client", if you get this error see https://github.com/golang/dep/issues/351
	v2.0.0: "github.com/atlassian/go-artifactory/artifactory" imports "github.com/atlassian/go-artifactory/v2/artifactory/client", which contains malformed code: unknown error for "github.com/atlassian/go-artifactory/v2/artifactory/client", if you get this error see https://github.com/golang/dep/issues/351
	v1.2.0: Could not introduce github.com/atlassian/go-artifactory@v1.2.0, as its subpackage github.com/atlassian/go-artifactory/artifactory is missing. (Package is required by (root).)
	v1.1.0: Could not introduce github.com/atlassian/go-artifactory@v1.1.0, as its subpackage github.com/atlassian/go-artifactory/artifactory is missing. (Package is required by (root).)
	v1.0.1: Could not introduce github.com/atlassian/go-artifactory@v1.0.1, as its subpackage github.com/atlassian/go-artifactory/artifactory is missing. (Package is required by (root).)
	v1.0.0: Could not introduce github.com/atlassian/go-artifactory@v1.0.0, as its subpackage github.com/atlassian/go-artifactory/artifactory is missing. (Package is required by (root).)
	v2.0.0-beta: "github.com/atlassian/go-artifactory/artifactory" imports "github.com/atlassian/go-artifactory/v2/artifactory/v2", which contains malformed code: no package exists at "github.com/atlassian/go-artifactory/v2/artifactory/v2"
	v2.0.0-alpha: Could not introduce github.com/atlassian/go-artifactory@v2.0.0-alpha, as its subpackage github.com/atlassian/go-artifactory/artifactory is missing. (Package is required by (root).)
	v2: "github.com/atlassian/go-artifactory/artifactory" imports "github.com/atlassian/go-artifactory/v2/artifactory/client", which contains malformed code: unknown error for "github.com/atlassian/go-artifactory/v2/artifactory/client", if you get this error see https://github.com/golang/dep/issues/351
	master: Could not introduce github.com/atlassian/go-artifactory@master, as its subpackage github.com/atlassian/go-artifactory/artifactory is missing. (Package is required by (root).)

Desktop (please complete the following information):

  • OS: OSX
@dillon-giacoppo
Copy link
Contributor

A known issue is that this repo is at V2 and has interesting behaviour with go.mod, so as a fix I made the main branch V2 which I think may affect dep. I would like to rebase it and make master the main branch but I need to merge all the outstanding PRs before this can happen - this should fix this. I would note however that this repo guarantees compatibility with the go module system only so YMMV with dep.

@dillon-giacoppo
Copy link
Contributor

Looks like it is an upstream bug golang/dep#1962, golang/dep#2139

Note: creating a new branch is not required. If instead you have been previously releasing on master and would prefer to tag v3.0.0 on master, that is a viable option. (However, be aware that introducing an incompatible API change in master can cause issues for non-modules users who issue a go get -u given the go tool is not aware of semver prior to Go 1.11 or when module mode is not enabled in Go 1.11+).
Pre-existing dependency management solutions such as dep currently can have problems consuming a v2+ module created in this way. See for example dep#1962.

https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

@dillon-giacoppo dillon-giacoppo added upstream-bug wontfix This will not be worked on labels Apr 29, 2019
@universam1
Copy link
Author

I'm not sure @dillon-giacoppo how modules should work better, I do get following result
"unknown import path \"github.com/atlassian/go-artifactory/artifactory\": cannot find module providing package github.com/atlassian/go-artifactory/artifactory"

Could you please elaborate how this should work as a module?

@universam1
Copy link
Author

universam1 commented May 1, 2019

if I try to forcefully load the latest module I get the following error:

╰─➤  go get github.com/atlassian/go-artifactory@v2.3.0                                                                                                                                          
go: finding github.com/atlassian/go-artifactory v2.3.0
go: github.com/atlassian/go-artifactory@v0.0.0-20190429001105-3369e1c17e23: go.mod has post-v0 module path "github.com/atlassian/go-artifactory/v2" at revision 3369e1c17e23
go: error loading module requirements

I believe your module setup @dillon-giacoppo is broken

If I start from scratch it only resolves up to 1.2.0

go: finding github.com/atlassian/go-artifactory/artifactory latest
go: extracting github.com/atlassian/go-artifactory v1.2.0

@universam1 universam1 changed the title dep init failed: unable to solve the dependency graph dep: unable to solve the dependency graph / mod: error loading module requirements May 1, 2019
@dillon-giacoppo
Copy link
Contributor

Please checkout my previous comment and attached tickets, dep is not compatible with go modules that use tags to do major versioning (single master branch). This is because the pseudo major version in the module path does not correspond to an actual directory. v1 works because it does not go looking for a v1/ directory.

Modules are now the official way to do dependency management so I don't plan on supporting dep.

@universam1
Copy link
Author

I understand @dillon-giacoppo your point that dep is not supported but you are using module.

Please see above error message that is related to module usage, not dep

@dillon-giacoppo
Copy link
Contributor

Can you please give steps to reproduce. i.e go version, exact command run etc.

@universam1
Copy link
Author

universam1 commented May 6, 2019

compiled a Dockerfile for your convenience, run docker build .

FROM golang:1.12

WORKDIR /src

RUN echo 'package main\n\
import "github.com/atlassian/go-artifactory/artifactory"\n\
func main() { artifactory.NewClient(client, nil) }\n' > test.go

RUN go mod init test

# also try this:
# RUN go get github.com/atlassian/go-artifactory@v2.3.0

RUN go build .

Try the commented statement too, see how module is unable to resolve the latest version

@dillon-giacoppo
Copy link
Contributor

dillon-giacoppo commented May 6, 2019

You are trying to use a major version >= 2 without adding a v2 to the module path. The correct Dockerfile would be

FROM golang:1.12

WORKDIR /src

RUN echo 'package main\n\
import "github.com/atlassian/go-artifactory/v2/artifactory"\n\
func main() { artifactory.NewClient("", nil) }\n' > test.go

RUN go mod init test

# RUN go get github.com/atlassian/go-artifactory/v2 @v2.3.0

RUN go build .

The examples also have correct usage.

@HQ1363
Copy link

HQ1363 commented Aug 18, 2020

I encountered the same problem, really difficult to use, simply unable to install the latest version of the package, directly give up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream-bug wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants