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: why does go get -d -u fail when go get -u #11090

Closed
williamh opened this issue Jun 5, 2015 · 9 comments
Closed

cmd/go: why does go get -d -u fail when go get -u #11090

williamh opened this issue Jun 5, 2015 · 9 comments
Milestone

Comments

@williamh
Copy link

williamh commented Jun 5, 2015

I am running go 1.4.2 on Linux/amd64 and noticed that I get an error using go get in a situation that doesn't seem to be an error. Here are the commands to reproduce it:

$ mkdir /home/William/go
$ export GOPATH=/home/William/go
$ go get -d golang.org/x/tools && echo "download of source was successful."

In this example, the first time I run "go get -d golang.org/x/tools", I do not get the successful message. Instead, a failure error code is returned along with the message:

" golang.org/x/tools: No buildable Go source files in /home/William/go/src/golang.org/x/tools"

If "-d" is download only, is this a bug, or am I misunderstanding what "-d" means?

Thanks,

William

@williamh
Copy link
Author

williamh commented Jun 5, 2015

I get the same error message and failure exit every time if I add the -u option to the "go get" command:

$ go get -d -u golang.org/x/tools

Thanks,

William

@adg
Copy link
Contributor

adg commented Jun 5, 2015

go get is for fetching packages, not repositories. golang.org/x/tools is the root of the tools repository, so go get golang.org/x/tools will succeed in checking out the repository but then fail as it tries to build tools package (as there is no such package).

This explains why -d works, as it only tries to download the package but doesn't try to build.

I'm not sure why go get -d -u should be different to go get -d in its error state. Maybe that's a bug?

@adg adg changed the title go get -d has confusing error situation cmd/go: why does go get -d -u fail when go get -u Jun 5, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.5Maybe milestone Jun 6, 2015
@williamh
Copy link
Author

williamh commented Jun 8, 2015

My thinking was that without -d it should try to build, but with -d it should download only, so "go get -d" and "go get -d -u" should not have an error state if they download the repository. However, "go get" or "go get -u" should have the error state if they try to build.

@williamh
Copy link
Author

@adg:
I'm not sure how clear I was in my original description of this issue, so I want to show the sequence of commands I ran along side my questions:

GOROOT is /usr/lib/go

$ rm -fr /home/William/go
$ mkdir /home/William/go
$ export GOPATH=/home/William/go
$ cd /home/William/go
$ go get golang.org/x/tools # this fails because tools is not a package, that makes sense.
$ rm -fr src/golang.org
$ go get -d golang.org/x/tools # Why does this fail the same way as go get without -d?
$ go get -d golang.org/x/tools # Running this a second time in a row succeeds
$ rm -fr src/golang.org
$ go get -d -u golang.org/x/tools # Why does this fail like go get without the -d?
$ go get -d -u golang.org/x/tools # Running this a second time in a row fails the same way, why?

Does all of this make sense?

@adg
Copy link
Contributor

adg commented Jun 16, 2015

Yep, it makes sense. The fix is probably quite subtle. We might get it fixed for 1.5; let's see.

@williamh
Copy link
Author

I found a way around this that is even more subtle than I thought after experimentation with our packages in Gentoo. If you add "/..." to the end of a repository name, things work as expected, e.g.

$ go get -d -t -u -v golang.org/x/tools/...

Doing this makes "go get" not complain about non-buildable sources at the top level.

So is this just a documentation issue? I didn't see anything about it in "go help" anywhere.

@adg
Copy link
Contributor

adg commented Jun 22, 2015

The /... means that it will match the packages inside that repo, so it makes sense that it works.

I don't think it's just a documentation issue. I think there's a subtle difference in how -d is treated depending on whether -u is specified, and that is not intentional and should be fixed.

@rsc
Copy link
Contributor

rsc commented Jul 14, 2015

They should both fail.
Even with -d, the command needs to read
the package sources to find out what the dependencies are,
since -d also fetches dependencies recursively.
So errors like not having any source files still surface.
The bug is that get -d (without -u) succeeds.
Will fix.

@gopherbot
Copy link

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

@rsc rsc closed this as completed in 4325a9e Jul 15, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.5Maybe Jul 16, 2015
@golang golang locked and limited conversation to collaborators Jul 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants