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: documentation cmd/go get claims "installs" but "go install" has a different effect #15825

Closed
bernhardreiter opened this issue May 24, 2016 · 12 comments

Comments

@bernhardreiter
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

go1.6.2 linux/amd64
go1.6.2 linux/386

  1. What operating system and processor architecture are you using (go env)?
    GOHOSTARCH="386"
    GOHOSTOS="linux"
    GOOS="linux"

GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

Trying to build a software from source with dependencies
and then continue developing this software in the cycle:
change code, recompile, run.

The dependencies shall not be recompiled each time.
Using
go get -u -v github.com/mattn/go-sqlite3
and then trying to recompile with "go build"
with lead to recompiling go-sqlite3 each time, though it did not change.
After an
go install github.com/mattn/go-sqlite3
It works without recompiling.

The documentation to "go get" says:
https://golang.org/cmd/go/
"""Download and install packages and dependencies

Get downloads and installs the packages named by the import paths, along with their dependencies. """

and "go install" says:
"""Compile and install packages and dependencies

Install compiles and installs the packages named by the import paths, along with their dependencies. """

There are two inconsistencies:
a) go get seems to also compile, otherwise I could not use it and there wouldn't be the reference
to the build flags. But compilation is not mentioned.
b) go install seems to do something else than just "install", but it is not documented.
Reason: there is a different behaviour for recompilation, but both commands list "install"
and "go install" does not describe a different additional action.

  1. What did you expect to see?

Both inconsistencies solved, so my mental model about what is happening can
be more easily constructed.
Possily: An explanation when recompilation checks will be happen and how to avoid them.

  1. What did you see instead?

The inconsistencies above.

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented May 25, 2016

I can't recreate this problem. Can you show the output of go get -x PKG followed by go build -x PKG, or whatever command incorrectly rebuilds the package?

@ianlancetaylor ianlancetaylor changed the title documentation cmd/go get claims "installs" but "go install" has a different effect cmd/go: documentation cmd/go get claims "installs" but "go install" has a different effect May 25, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.7Maybe milestone May 25, 2016
@bernhardreiter
Copy link
Author

bernhardreiter commented May 25, 2016

@ianlancetaylor thanks for trying to reproduce my problem.
I have one setup here where I do get a rebuild after having done a "go get" on a dependency
when doing a "go build" on my main file. (This is the second time I see this problem, the first time I did not inquire and a few wild "go get"s and "go install"s later it was gone.) I've tried to freshly recreate the situation of my problem-showing-setup this morning, but I found that there must be another factor.
I'll keep trying a bit, if you have a hint how to diagnose this further, it would be helpful.

Nevertheless the missing "compile" in the "go get" section already is an inconsistency in the documentation. And given that I have a situation where I get an unexpected rebuild, some hints
would be useful in which state rebuilds occur and when not.

@bernhardreiter
Copy link
Author

In my problem-showing-setup I think the go version was switched a few times:
1.4.2 -> 1.5.1 -> 1.6 -> 1.6.1 -> 1.6.2
and it may have to do with the depencencies having changed over time.
The following dependencies are used in this software project:
golang.org/x/crypto/bcrypt
github.com/lib/pq
github.com/mattn/go-sqlite3
github.com/urfave/negroni
github.com/gorilla/mux

the rebuild happens with github.com/mattn/go-sqlite3 all the time and I've noticed it
after I have updated from github.com/codegangsta/negroni to github.com/urfave/negroni
My command history shows
cd github.com
rm -rf codegangsta/
go get -u -v github.com/urfave/negroni
no changes regarding sqlite3.

Given the documentation this should probably not have happened.
(Either that sqlite3 is not in "rebuild each time mode" or me not understanding what the issue is.)
Any ideas how to diagnose this further?

@ianlancetaylor
Copy link
Contributor

I don't have any suggestions, other than running go get -x to see what is actually happening.

I don't think we can fix this without a way to reproduce the problem, or at least a trace showing what is happening.

@ianlancetaylor ianlancetaylor modified the milestones: Unplanned, Go1.7Maybe Jun 9, 2016
@bernhardreiter
Copy link
Author

bernhardreiter commented Jun 9, 2016

@ianlancetaylor thanks for your response.
I believe the documentation inconsistency in wording can be fixed.

The technical part (which initially matched the documentation inconsistency) needs to be investigated
further. My current hypothesis is, that there is something wrong in the way go handles it,
but I can observe is only with github.com/mattn/go-sqlite3. @s-l-teichmann observes a similliar
issue with go-sqlite3. Maybe we should separate the go-sqlite3 rebuilding issue from the documentation
inconsistency.

@gopherbot
Copy link
Contributor

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

gopherbot pushed a commit that referenced this issue Jun 10, 2016
Make the documentation for `go get` match the documentation for `go
install`, since `go get` essentially invokes `go install`.

Update #15825.

Change-Id: I374d80efd301814b6d98b86b7a4a68dd09704c92
Reviewed-on: https://go-review.googlesource.com/23925
Reviewed-by: Andrew Gerrand <adg@golang.org>
@s-l-teichmann
Copy link

https://groups.google.com/forum/#!topic/golang-nuts/7t9PFp3zYPo seems to be related to this case.

You go get the sqlite-lib and have to go install it separately to prevent the re-compilation every time.

@davecheney
Copy link
Contributor

If sqlite3 is present on disk it will not be fetched and therefore not
installed. If the go installation is updated then the previous version of
sqlite3 will be considered stale and not updated.

As you saw in that thread I recommend using go install -v always. This will
make your go experience a lot more enjoyable. Please trust me on this.

On Thu, 16 Jun 2016, 15:59 Sascha L. Teichmann notifications@github.com
wrote:

https://groups.google.com/forum/#!topic/golang-nuts/7t9PFp3zYPo seems to
be related to this case.

You go get the sqlite-lib and have to go install it separately to prevent
the re-compilation every time.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#15825 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAAcA9Rer3euw3tCbvljw2NV0bh8oljYks5qMOYzgaJpZM4Il3wm
.

@bernhardreiter
Copy link
Author

bernhardreiter commented Jun 17, 2016

@davecheney but what is your reason to recommend "go install" over "go get" when "go get"
does also do "install" (according to documentation. I believe there is a difference under some circumstances, which would be a defect)?

@bernhardreiter
Copy link
Author

@davecheney Oh, are you saying that "go get" will not compile and install, if it already finds a version on disc? In my test case that would mean I got the "download" and "compile" steps done, but not the "install" step? How could I create this situation? (I probably only used "go get" maybe some "go installs" and later go build on my local source code. The local source finds the go-sqlite3 pacages and uses it, so it must be compiled at the right place I think.)

@adg
Copy link
Contributor

adg commented Jun 19, 2016

I think @davecheney is recommending the -v flag specifically, not go get over go install.

To be clear: go get has the exact same semantics as go install PLUS it fetches remote dependencies.

@seankhliao
Copy link
Member

Closing as I don't see anything else to do here

@golang golang locked and limited conversation to collaborators Jun 8, 2023
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

7 participants