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: go install -a mypkg reinstalls standard packages #6424

Closed
btracey opened this issue Sep 19, 2013 · 19 comments
Closed

cmd/go: go install -a mypkg reinstalls standard packages #6424

btracey opened this issue Sep 19, 2013 · 19 comments
Milestone

Comments

@btracey
Copy link
Contributor

btracey commented Sep 19, 2013

Before filing a bug, please check whether it has been fixed since the
latest release. Search the issue tracker and check that you're running the
latest version of Go:

Run "go version" and compare against
http://golang.org/doc/devel/release.html  If a newer version of Go exists,
install it and retry what you did to reproduce the problem.

Thanks.

What steps will reproduce the problem?
I installed Go using the installer, which by default installs go to /usr/local/go . If I
try to use the -a build flag for go install, I get a permission denied error (because I
as a user don't have permission to write to /usr/local). I'm not sure what the right
solution to this is, but it would be nice to have some kind of workaround where I can
re-install all non std lib packages (or where I could re-install the standard library). 

What is the expected output?
brendan:~/Documents/mygo/bin$ go install -a github.com/gonum/floats
should work fine (or maybe with a different flag)

What do you see instead?
brendan:~/Documents/mygo/bin$ go install -a github.com/gonum/floats
go install runtime: open /usr/local/go/pkg/darwin_amd64/runtime.a: permission denied

Which compiler are you using (5g, 6g, 8g, gccgo)?
gc

Which operating system are you using?
darwin

Which version are you using?  (run 'go version')
go version go1.1.2 darwin/amd64

Please provide any additional information below.
https://groups.google.com/forum/#!searchin/golang-nuts/runtime$20permission$20denied/golang-nuts/yniBC9gM9I0/6sqirDNIF08J


At the moment I can get around it by cleaning the contents of the package install
folder, but it would be nice to not have to do so.
@minux
Copy link
Member

minux commented Sep 19, 2013

Comment 1:

perhaps you can use the "go clean -i" feature.
btw, why you want to rebuild anything but the std. lib? the Go command is meant to help
you
maintaining the dependencies.

@davecheney
Copy link
Contributor

Comment 2:

go install -a $SOMEPACKAGE should be an error, -a (all) and $SOMEPACKAGE are at best a
duplication of effort. The go command should reject this invocation.

@rsc
Copy link
Contributor

rsc commented Sep 20, 2013

Comment 3:

dave, i think you misunderstood the flag. consider these two commands:
go install foo
go install -a foo
they both consider installing foo and all of foo's dependencies
(recursively).
the first only builds and installs the ones that are out of date.
the second builds and installs all of them, even if they look up-to-date.
the problem here is that go install -a my/pkg is trying to reinstall, say,
math, but math cannot be written.

@davecheney
Copy link
Contributor

Comment 4:

Thanks for your reply Russ. I didn't do a very good job of explaining why I thought -a
and a $PKG was incorrect. 
As an alternative explanation, please consider the way git handles this
% git commit -a rpi.go
fatal: Paths with -a does not make sense.
^ I think this is a good model for the behaviour of the -a flag with go install, and
makes the explanation for why it doens't work simpler; -a will reinstall everything,
including the standard library, it will fail if you do not have permission to write to
your go installation, most probably if it was installed via your operating systems'
distribution mechanism.

@adg
Copy link
Contributor

adg commented Sep 20, 2013

Comment 5:

I think you're conflating "go install all" and "go install -a". They're not the same and
serve different purposes.

@minux
Copy link
Member

minux commented Sep 22, 2013

Comment 6:

Issue #6442 has been merged into this issue.

@rsc
Copy link
Contributor

rsc commented Sep 23, 2013

Comment 7:

Dave, it doesn't matter if the git commit -a behavior would make more sense to git
users. It's simply not what go install -a means, and it is too late to change the
meaning.
For what it's worth, the go install -a behavior matches 'mk -a', or GNU make's make
--always-make.
Perhaps -a should stop at GOPATH boundaries, just like ordinary builds do.

Labels changed: added priority-soon, go1.2, removed priority-triage.

Status changed to Thinking.

@rsc
Copy link
Contributor

rsc commented Oct 2, 2013

Comment 8:

I'm not going to touch this for Go 1.2. It's too close to the release. Let's fix it for
Go 1.3.

Labels changed: added go1.3, removed go1.2.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 9:

Labels changed: added release-go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 10:

Labels changed: removed go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 11:

Labels changed: added repo-main.

@rsc
Copy link
Contributor

rsc commented Apr 3, 2014

Comment 12:

The only possible fix here is to make -a stop at GOPATH boundaries.
I think people probably depend on the current behavior.
Certainly I've been depending on it recently in testing some other things.
I think we should leave things alone.

Status changed to WorkingAsIntended.

@gopherbot
Copy link

Comment 13 by beatgammit:

I have a few build scripts that `rm -r $GOPATH/pkg` because I run builds with different
tags. If I rebuild without rm-ing $GOPATH/pkg, I get the .a files from the previous
build.
I had hoped that I could use `go install -a` to recompile only those packages that that
I depend on in my GOPATH, but my GOROOT is owned by root, not my current user, so I
can't rebuild standard library packages for each build (not that I'd want to).
I can see how the current behavior could be desirable for someone working on the runtime
and standard library, but I don't think it's generally useful, especially if go is
installed via a package manager and owned by root.

@gopherbot
Copy link

Comment 14 by admin@802tsn.org:

-a may do what it's documented to do, but as noted, it does not solve the problem that I
get every time I update the compiler package and there is a mismatch with the libraries
on GOPATH. I'd love a flag that means something like "rebuild everything *except* that
in GOROOT" ...

@gopherbot
Copy link

Comment 15 by daviddengcn:

This problem appears on my Mac OS: go version go1.3 darwin/amd64

@btracey
Copy link
Contributor Author

btracey commented Sep 26, 2014

Comment 16:

This was fixed by revision 6364b071649c. It wasn't marked as such in the CL.

@robwithhair
Copy link

robwithhair commented Jun 23, 2016

I'm still getting the following error on go1.6.2 on mac installed from .pkg

$ go install -a
go install runtime/internal/sys: open /usr/local/go/pkg/darwin_amd64/runtime/internal/sys.a: permission denied
$ echo $GOPATH
/Users/robwithhair/Swoop/go workspace

Oddly go build -a succeeds and doesn't error at all

BTW I'm running this command from inside the desired package folder

@ianlancetaylor
Copy link
Contributor

@robwithhair This issue was closed years ago. If you have a new problem, please open a new issue.

Running go install -a means to install all the packages, including the standard library. It's usually not what you want to run.

If you have questions, please use a forum: https://golang.org/wiki/Questions .

Thanks.

@golang golang locked and limited conversation to collaborators Jun 23, 2016
@gopherbot
Copy link

Change https://golang.org/cl/75850 mentions this issue: cmd/go: do not install dependencies during "go install"

gopherbot pushed a commit that referenced this issue Dec 6, 2017
This CL makes "go install" behave the way many users expect:
install only the things named on the command line.
Future builds still run as fast, thanks to the new build cache (CL 75473).
To install dependencies as well (the old behavior), use "go install -i".

Actual definitions aside, what most users know and expect of "go install"
is that (1) it installs what you asked, and (2) it's fast, unlike "go build".
It was fast because it installed dependencies, but installing dependencies
confused users repeatedly (see for example #5065, #6424, #10998, #12329,
"go build" and "go test" so that they could be "fast" too, but that only
created new opportunities for confusion. We also had to add -installsuffix
and then -pkgdir, to allow "fast" even when dependencies could not be
installed in the usual place.

The recent introduction of precise content-based staleness logic means that
the go command detects the need for rebuilding packages more often than it
used to, with the consequence that "go install" rebuilds and reinstalls
dependencies more than it used to. This will create more new opportunities
for confusion and will certainly lead to more issues filed like the ones
listed above.

CL 75743 introduced a build cache, separate from the install locations.
That cache makes all operations equally incremental and fast, whether or
not the operation is "install" or "build", and whether or not "-i" is used.

Installing dependencies is no longer necessary for speed, it has confused
users in the past, and the more accurate rebuilds mean that it will confuse
users even more often in the future. This CL aims to end all that confusion
by not installing dependencies by default.

By analogy with "go build -i" and "go test -i", which still install
dependencies, this CL introduces "go install -i", which installs
dependencies in addition to the things named on the command line.

Fixes #5065.
Fixes #6424.
Fixes #10998.
Fixes #12329.
Fixes #18981.
Fixes #22469.

Another step toward #4719.

Change-Id: I3d7bc145c3a680e2f26416e182fa0dcf1e2a15e5
Reviewed-on: https://go-review.googlesource.com/75850
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This issue was closed.
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

8 participants