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

cmd/go: get -u can fail once and then succeed #14450

Closed
ianlancetaylor opened this issue Feb 21, 2016 · 6 comments
Closed

cmd/go: get -u can fail once and then succeed #14450

ianlancetaylor opened this issue Feb 21, 2016 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ianlancetaylor
Copy link
Contributor

Noticed by accident. After running go get for an invalid directory, the first go get -u fails, and the second succeeds. The internal error lines at the end are #14444. This issue is about the fact that the two runs of go get -u .../ fail in different ways.

I haven't looked into it.

> mkdir /tmp/gopath2
> GOPATH=/tmp/gopath2 go get golang.org/x/tools/cmd/imports   # does not exist
package golang.org/x/tools/cmd/imports: cannot find package "golang.org/x/tools/cmd/imports" in any of:
    /home/iant/go/src/golang.org/x/tools/cmd/imports (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/tools/cmd/imports (from $GOPATH)
> GOPATH=/tmp/gopath2 go get -u .../
/tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:20:2: cannot find package "golang.org/x/text/encoding" in any of:
    /home/iant/go/src/golang.org/x/text/encoding (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/encoding (from $GOPATH)
    /tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:21:2: cannot find package "golang.org/x/text/encoding/charmap" in any of:
    /home/iant/go/src/golang.org/x/text/encoding/charmap (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/encoding/charmap (from $GOPATH)
/tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:22:2: cannot find package "golang.org/x/text/encoding/htmlindex" in any of:
    /home/iant/go/src/golang.org/x/text/encoding/htmlindex (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/encoding/htmlindex (from $GOPATH)
/tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:23:2: cannot find package "golang.org/x/text/transform" in any of:
    /home/iant/go/src/golang.org/x/text/transform (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/transform (from $GOPATH)
/tmp/gopath2/src/golang.org/x/net/http2/h2i/h2i.go:38:2: cannot find package "golang.org/x/crypto/ssh/terminal" in any of:
    /home/iant/go/src/golang.org/x/crypto/ssh/terminal (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/crypto/ssh/terminal (from $GOPATH)
> GOPATH=/tmp/gopath2 go get -u .../
internal error: duplicate loads of unsafe
internal error: duplicate loads of runtime/internal/sys
internal error: duplicate loads of runtime/internal/atomic
many other internal errors
@ianlancetaylor ianlancetaylor added this to the Go1.6.1 milestone Feb 21, 2016
@ianlancetaylor
Copy link
Contributor Author

Thanks, if this fails with 1.5, adjusting milestone to 1.7.

@ianlancetaylor ianlancetaylor modified the milestones: Go1.7, Go1.6.1 Feb 24, 2016
@mahendrakariya
Copy link

Looks like my earlier comment got accidently deleted. So adding it again.

I was able to reproduce this issue in Go 1.5 on darwin/amd64.

@tmwh
Copy link
Contributor

tmwh commented Feb 25, 2016

This issue is repeatable with existing package too:

> mkdir /tmp/gopath2
> GOPATH=/tmp/gopath2 go get golang.org/x/tools/cmd/bundle
> GOPATH=/tmp/gopath2 go get -u .../

/tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:20:2: cannot find package "golang.org/x/text/encoding" in any of:
    /home/tmwh/go/src/golang.org/x/text/encoding (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/encoding (from $GOPATH)
/tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:21:2: cannot find package "golang.org/x/text/encoding/charmap" in any of:
    /home/tmwh/go/src/golang.org/x/text/encoding/charmap (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/encoding/charmap (from $GOPATH)
/tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:22:2: cannot find package "golang.org/x/text/encoding/htmlindex" in any of:
    /home/tmwh/go/src/golang.org/x/text/encoding/htmlindex (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/encoding/htmlindex (from $GOPATH)
/tmp/gopath2/src/golang.org/x/net/html/charset/charset.go:23:2: cannot find package "golang.org/x/text/transform" in any of:
    /home/tmwh/go/src/golang.org/x/text/transform (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/text/transform (from $GOPATH)
/tmp/gopath2/src/golang.org/x/net/http2/h2i/h2i.go:38:2: cannot find package "golang.org/x/crypto/ssh/terminal" in any of:
    /home/tmwh/go/src/golang.org/x/crypto/ssh/terminal (from $GOROOT)
    /tmp/gopath2/src/golang.org/x/crypto/ssh/terminal (from $GOPATH)

It happens because golang.org/x/tools/cmd/html2article depends on golang.org/x/net/html and after golang.org/x/net/html is successfully downloaded we are trying to import all packages (.../) from its repository. It contains golang.org/x/net/html/charset which is not imported in any other packages. That's why its imports (golang.org/x/text/encoding, golang.org/x/text/encoding/charmap, golang.org/x/text/encoding/htmlindex...) were not downloaded.

I've created the minimal packages structure for reproducing this:
https://github.com/tmwh/go-get-issue-14450
https://github.com/tmwh/go-get-issue-14450-b-dependency
https://github.com/tmwh/go-get-issue-14450-d-dependency

I've come up with 2 possible solutions for this problem

  • Don't try to import packages that were not downloaded
  • Download all packages that are matching the passed path even if they were downloaded as part of the other packages' repository.

The first one was smaller, so I've decided to submit it https://go-review.googlesource.com/19892 I can submit the second solution too, if it is the way you would like to handle that.

@gopherbot
Copy link

CL https://golang.org/cl/19892 mentions this issue.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label May 26, 2016
@quentinmit
Copy link
Contributor

Ping @rsc. I'm not sure if there's discussion elsewhere that I'm not seeing, but it seems like there's a straightforward fix for this waiting for your review in CL 19892. I'll refrain from punting to Go1.8 for now until I hear back from you.

@rsc
Copy link
Contributor

rsc commented May 27, 2016

Not going to get to this for Go 1.7, sorry.

@rsc rsc modified the milestones: Go1.8, Go1.7 May 27, 2016
@golang golang locked and limited conversation to collaborators Oct 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants