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

malformed code: no package exists at [...] #1822

Closed
karalabe opened this issue Apr 20, 2018 · 5 comments
Closed

malformed code: no package exists at [...] #1822

karalabe opened this issue Apr 20, 2018 · 5 comments

Comments

@karalabe
Copy link

What version of dep are you using (dep version)?

dep:
 version     : v0.4.1
 build date  : 2018-01-24
 git hash    : 37d9ea0a
 go version  : go1.9.1
 go compiler : gc
 platform    : linux/amd64

What dep command did you run?

Place this Go file in a folder somewhere:

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"log"

	"github.com/ipsn/go-ipfs/core"
	"github.com/ipsn/go-ipfs/core/coreunix"
)

func main() {
	node, err := core.NewNode(context.TODO(), &core.BuildCfg{Online: true})
	if err != nil {
		log.Fatalf("Failed to start IPFS node: %v", err)
	}
	reader, err := coreunix.Cat(context.TODO(), node, "QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB")
	if err != nil {
		log.Fatalf("Failed to look up IPFS welcome page: %v", err)
	}
	blob, err := ioutil.ReadAll(reader)
	if err != nil {
		log.Fatalf("Failed to retrieve IPFS welcome page: %v", err)
	}
	fmt.Println(string(blob))
}

Initialize dep, which should pull the dependencies:

$ dep init -v

What did you expect to see?

Successfully resolving the dependency tree.

What did you see instead?

Getting direct dependencies...
Checked 1 directories for packages.
Found 1 direct dependencies.
Root project is "github.com/ipsn/demo"
 1 transitively valid internal packages
 2 external packages imported from 1 projects
(0)   ✓ select (root)
(1)	? attempt github.com/ipsn/go-ipfs with 2 pkgs; 2 versions to try
(1)	    try github.com/ipsn/go-ipfs@master
(1)	✗   "github.com/ipsn/go-ipfs/core" transitively (through 6 packages) imports "github.com/ipsn/go-ipfs/gxlibs/github.com/whyrusleeping/go-notifier/Godeps/_workspace/src/github.com/jbenet/goprocess", which contains malformed code: no package exists at "github.com/ipsn/go-ipfs/gxlibs/github.com/whyrusleeping/go-notifier/Godeps/_workspace/src/github.com/jbenet/goprocess"
(1)	    try github.com/ipsn/go-ipfs@ungx
(2)	✗   github.com/ipsn/go-ipfs at ungx has problem subpkg(s):
(2)	  	github.com/ipsn/go-ipfs/core/coreunix is missing; required by (root).	github.com/ipsn/go-ipfs/core is missing; required by (root).
(1)	  ← no more versions of github.com/ipsn/go-ipfs to try; begin backtrack
  ✗ solving failed

Solver wall times by segment:
     b-source-exists: 7.740598652s
         b-list-pkgs:  498.04682ms
              b-gmal: 286.891942ms
             satisfy:   11.97477ms
            new-atom:     68.956µs
         select-root:     40.254µs
               other:     14.663µs
     b-list-versions:      9.488µs
  b-deduce-proj-root:      2.318µs

  TOTAL: 8.537647863s

init failed: unable to solve the dependency graph: Solving failure: No versions of github.com/ipsn/go-ipfs met constraints:
	master: "github.com/ipsn/go-ipfs/core" transitively (through 6 packages) imports "github.com/ipsn/go-ipfs/gxlibs/github.com/whyrusleeping/go-notifier/Godeps/_workspace/src/github.com/jbenet/goprocess", which contains malformed code: no package exists at "github.com/ipsn/go-ipfs/gxlibs/github.com/whyrusleeping/go-notifier/Godeps/_workspace/src/github.com/jbenet/goprocess"
	ungx: Could not introduce github.com/ipsn/go-ipfs@ungx due to multiple problematic subpackages:
	Subpackage github.com/ipsn/go-ipfs/core is missing. (Package is required by (root).)	Subpackage github.com/ipsn/go-ipfs/core/coreunix is missing. (Package is required by (root).)

The interesting error here is no package exists at "github.com/ipsn/go-ipfs/gxlibs/github.com/whyrusleeping/go-notifier/Godeps/_workspace/src/github.com/jbenet/goprocess". I'm fairly sure there's nothing wrong with that package: https://github.com/ipsn/go-ipfs/tree/master/gxlibs/github.com/whyrusleeping/go-notifier/Godeps/_workspace/src/github.com/jbenet/goprocess .

Note, vendoring the dependencies via govendor works correctly. https://github.com/ipsn/go-ipfs#proper-dependencies

@mattayes
Copy link
Contributor

@karalabe Good find, I'm able to recreate the issue with a simpler example:

package main

import (
	_ "github.com/ipsn/go-ipfs/core"
)

func main() {}

Do you have any interest in submitting a PR for this?

@karalabe
Copy link
Author

I don't think I have too much time now to really dig into it to be honest. I might try at some point, but since I'm not really familiar with dep, I won't get angry if someone else fixes it :D

@bonedaddy
Copy link

Any resolution to this? Just ran into this issue

@jonstacks
Copy link
Contributor

Just ran into this as well.

Some repos vendor their dependencies under a Godeps/_workspace directory and import using the full path with the Godeps/_workspace relative to their package. In my case, I'm hitting this in a really old fleet commit that I'm locked to: https://github.com/coreos/fleet/blob/f1d86c7bd0ec00162682024336d898d5838cc9a4/server/server.go#L23

I think what is happening is that the following block is ignoring the Godeps directory:

// Skip dirs that are known to hold non-local/dependency code.
//
// We don't skip _*, or testdata dirs because, while it may be poor
// form, importing them is not a compilation error.
switch fi.Name() {
case "vendor", "Godeps":
return filepath.SkipDir
}

I'm going to see if I can't build a dep binary that includes the Godeps directory. If that fails, I might try adding a required to my Gopkg.toml files

@jonstacks
Copy link
Contributor

jonstacks commented Jul 4, 2018

Hmm....So removing Godeps from that line and re-building dep worked for me in that it was able to solve. Not familiar enough with dep to know what other errors it might introduce though. Here is my Gopkg.lock afterwards. It correctly includes the Godeps directories needed for that project to build:

[[projects]]
  name = "github.com/coreos/fleet"
  packages = [
    "Godeps/_workspace/src/github.com/coreos/go-semver/semver",
    "Godeps/_workspace/src/github.com/coreos/go-systemd/unit",
    "Godeps/_workspace/src/github.com/docker/libcontainer/netlink",
    "Godeps/_workspace/src/github.com/jonboulle/clockwork",
    "Godeps/_workspace/src/google.golang.org/api/googleapi",
    "Godeps/_workspace/src/google.golang.org/api/googleapi/internal/uritemplates",
    "api",
    "client",
    "etcd",
    "job",
    "log",
    "machine",
    "pkg",
    "pkg/lease",
    "registry",
    "schema",
    "unit",
    "version"
  ]
  revision = "f1d86c7bd0ec00162682024336d898d5838cc9a4"

edit: I switched my dep back to one that ignores the Godeps directory and I was able to run dep ensure just fine. However, when I tried to run dep ensure -update it failed with the same message.

sdboyer added a commit that referenced this issue Jul 4, 2018
Don't exclude Godeps folder. Fixes #1822
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