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

panic: shouldn't be possible unable to deduce repository and source type for: "golang.org/x/sys/unix" #581

Closed
bsed opened this issue May 15, 2017 · 10 comments · Fixed by #697

Comments

@bsed
Copy link

bsed commented May 15, 2017

 $ dep ensure -update
panic: shouldn't be possible unable to deduce repository and source type for: "golang.org/x/sys/unix"

goroutine 1 [running]:
github.com/golang/dep/internal/gps.(*solver).selectRoot(0xc0421a4000, 0xc0420f5500, 0x1b)
        E:/gocode/src/github.com/golang/dep/internal/gps/solver.go:502 +0xb18
github.com/golang/dep/internal/gps.(*solver).Solve(0xc0421a4000, 0x12, 0xa71d00, 0xabf608, 0xc0420fbf6e)
        E:/gocode/src/github.com/golang/dep/internal/gps/solver.go:348 +0x8e
main.(*ensureCommand).Run(0xc0421484a0, 0xc04210bb40, 0xc04204e3b0, 0x0, 0x0, 0x0, 0x0)
        E:/gocode/src/github.com/golang/dep/cmd/dep/ensure.go:148 +0x389
main.(*Config).Run(0xc04200b320, 0xc04200b320)
        E:/gocode/src/github.com/golang/dep/cmd/dep/main.go:159 +0x8ba
main.main()
        E:/gocode/src/github.com/golang/dep/cmd/dep/main.go:44 +0x25a

@bsed
Copy link
Author

bsed commented May 15, 2017

sm.DeduceProjectRoot: unable to deduce repository and source type for: "golang.org/x/crypto/acme/autocert"

@sdboyer sdboyer added the bug label May 15, 2017
@sdboyer
Copy link
Member

sdboyer commented May 15, 2017

The ultimate reason for the error is detailed in #292, but it's not great that there's a panic case that can be triggered by this. Let's treat this issue as being about covering that panic.

@ibrasho
Copy link
Collaborator

ibrasho commented May 15, 2017

Any specific error message instead of the panic?

@sdboyer
Copy link
Member

sdboyer commented May 16, 2017

Looking at the source line, I see it's preceded by a note from me:

// TODO(sdboyer) this could well happen; handle it with a more graceful error

So yeah 😄 Problem is, at that specific point, there are a number of things that could cause the error. Still, for now, the best thing to do is probably just return the error out directly.

@ibrasho
Copy link
Collaborator

ibrasho commented May 16, 2017

Should it be handled somewhere else? Otherwise, dep will be print this error anyway:

ensure Solve(): unable to deduce repository and source type for: "golang.org/x/sys/unix"

@ibrasho
Copy link
Collaborator

ibrasho commented May 16, 2017

#561 Seems like an improvement to the errors that are returned:

panic: shouldn't be possible unable to deduce repository and source type for "golang.org/x/sys/unix": unable to determine remote metadata protocol: failed to access url "http://golang.org/x/sys/unix?go-get=1"

@sdboyer
Copy link
Member

sdboyer commented May 16, 2017

Yes, #561 would improve the message - but it absolutely does have to return out the error, as it's not possible to continue solving if this occurs.

It could be handled earlier, e.g. in Prepare(). We'd have to iterate through each of the imports in the project, attempt deduction, and collect a slice of failures. That work should be parallelized. Kind of akin to what we do in init, but with a waitgroup and using DeduceProjectRoot() instead of SyncSourceFor().

@ibrasho
Copy link
Collaborator

ibrasho commented May 16, 2017

Prepare() doesn't have access to the logger ctx.Loggers.Err unless verbose mode is toggled. Any pointers on what could be done in that case?

BTW, I noticed that Prepare() is called twice in Run() (in init.go). I'm not sure if this intentional or not.

@sdboyer
Copy link
Member

sdboyer commented May 17, 2017

Right, we never print anything directly from within gps. There's only one single solitary exception to that rule, and it needs to be gotten rid of, too 😄 apart from the fs funcs you're working on in the other PR, gps should be considered self-contained, and import only things at or below its level in the project.

Instead, follow the pattern that's in that function - return a badOptsFailure with an appropriate message. It's not great, but it's consistent, and good enough for now.

BTW, I noticed that Prepare() is called twice in Run() (in init.go). I'm not sure if this intentional or not.

It is - the comments say a bit about it. It's run the second time in order to get the modified input hash for the Gopkg.lock memo field.

ibrasho added a commit to ibrasho-forks/dep that referenced this issue Jun 6, 2017
solver.selectRoot() panics when solver.intersectConstraintsWithImports()
returns an error.

This commit returns the error instead if that error is due to inability
to deduce a project repository.

Solves golang#292 and golang#581

Signed-off-by: Ibrahim AshShohail <ibra.sho@gmail.com>
@ibrasho
Copy link
Collaborator

ibrasho commented Jun 7, 2017

@sdboyer Somehow this issue is not reproducible using dep v0.1.0-88-gce194b4fb9f3.

I'm getting the following error instead of a panic: ensure Solve(): unable to deduce repository and source type for "golang.org/x/sys": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://golang.org/x/sys?go-get=1": Get http://golang.org/x/sys?go-get=1: dial tcp 127.0.0.1:80: getsockopt: connection refused

@bsed Could you update dep and check now?

@bsed bsed closed this as completed Jun 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants