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: goinstall -installsuffix={..} {package} attempts to install to $GOROOT/pkg/goos_goarch_{..} #10998

Closed
james-lawrence opened this issue May 30, 2015 · 5 comments
Milestone

Comments

@james-lawrence
Copy link
Contributor

it looks like its trying to reinstall the runtime package with my suffix?

[jatone]$ $PWD
bash: /home/james-lawrence/development/gilo: Is a directory
[jatone]$ ls -lha bin/
total 8.0K
drwxr-xr-x 2 jatone jatone 4.0K May 30 07:11 .
drwxr-xr-x 5 jatone jatone 4.0K May 30 06:43 ..

[jatone]$ go env
GOARCH="amd64"
GOBIN="/home/james-lawrence/development/gilo/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/james-lawrence/development/gilo"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

[jatone]$ go install --installsuffix="abc" bitbucket.org/jatone/gilo/commands/...
go install runtime: mkdir /usr/lib/go/pkg/linux_amd64_abc/: permission denied

[jatone]$ ls -lha bin/
total 8.0K
drwxr-xr-x 2 jatone jatone 4.0K May 30 07:11 .
drwxr-xr-x 5 jatone jatone 4.0K May 30 06:43 ..

[jatone]$ go install bitbucket.org/jatone/gilo/commands/...
[jatone]$ ls -lha bin/
total 15M
drwxr-xr-x 2 jatone jatone 4.0K May 30 07:13 .
drwxr-xr-x 5 jatone jatone 4.0K May 30 06:43 ..
-rwxr-xr-x 1 jatone jatone 4.5M May 30 07:13 gilo
-rwxr-xr-x 1 jatone jatone 6.7M May 30 07:13 gilod
-rwxr-xr-x 1 jatone jatone 3.1M May 30 07:13 gilo-shim

go help build says:
-installsuffix suffix
a suffix to use in the name of the package installation directory,
in order to keep output separate from default builds.
If using the -race flag, the install suffix is automatically set to race
or, if set explicitly, has _race appended to it.

unclear from that documentation that it'll recompile packages in GOROOT, I was only expecting stuff from the GOPATH environment variable to be impacted.

@ianlancetaylor
Copy link
Contributor

Which version of go?

@ianlancetaylor ianlancetaylor changed the title goinstall -installsuffix={..} {package} attempts to install to $GOROOT/bin cmd/go: goinstall -installsuffix={..} {package} attempts to install to $GOROOT/bin May 30, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.5 milestone May 30, 2015
@minux
Copy link
Member

minux commented May 30, 2015

I don't see a problem here.

  1. go install --installsuffix="abc" bitbucket.org/jatone/gilo/commands/...
    will also try to (re)installed the standard libraries (because there is
    no installation of standard library with installsuffix abc). And that's
    why it tries to write to $GOROOT/pkg/linux_amd64_abc.
  2. go env showed that you have set $GOBIN, which will the location
    all installed commands go.

@minux
Copy link
Member

minux commented May 30, 2015 via email

@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

See also #10210

@rsc
Copy link
Contributor

rsc commented Jul 14, 2015

Yes, this is how it's supposed to work. -installsuffix applies to all code, not just GOPATH.

@rsc rsc changed the title cmd/go: goinstall -installsuffix={..} {package} attempts to install to $GOROOT/bin cmd/go: goinstall -installsuffix={..} {package} attempts to install to $GOROOT/pkg/goos_goarch_{..} Jul 14, 2015
@rsc rsc closed this as completed Jul 14, 2015
@golang golang locked and limited conversation to collaborators Jul 13, 2016
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>
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

5 participants