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 clean -i all" removes go binary #10710

Closed
divan opened this issue May 5, 2015 · 20 comments
Closed

cmd/go: "go clean -i all" removes go binary #10710

divan opened this issue May 5, 2015 · 20 comments

Comments

@divan
Copy link

divan commented May 5, 2015

go clean -i all command deletes go binary itself, and this behavior is undocumented.

$ go version
go version go1.4.2 darwin/amd64

$ go clean -i -n all | grep -A 2 "cmd/go$"
cd /usr/local/go/src/cmd/go
rm -f go go.exe go.test go.test.exe bootstrap bootstrap.exe build build.exe clean clean.exe context context.exe discovery discovery.exe doc doc.exe env env.exe fix fix.exe fmt fmt.exe generate generate.exe generate_test generate_test.exe get get.exe go11 go11.exe go_windows_test go_windows_test.exe help help.exe http http.exe list list.exe main main.exe match_test match_test.exe pkg pkg.exe pkg_test pkg_test.exe run run.exe signal signal.exe signal_notunix signal_notunix.exe signal_unix signal_unix.exe tag_test tag_test.exe test test.exe testflag testflag.exe testgo testgo.exe tool tool.exe vcs vcs.exe vcs_test vcs_test.exe version version.exe vet vet.exe zdefaultcc zdefaultcc.exe
@minux
Copy link
Member

minux commented May 5, 2015 via email

@minux minux closed this as completed May 5, 2015
@AlekSi
Copy link
Contributor

AlekSi commented May 5, 2015

@minux
Copy link
Member

minux commented May 5, 2015 via email

@davecheney
Copy link
Contributor

The OP was unlucky enough to have installed go from source. If they were
using the binary distro they would have seen permission errors and may have
reached for the sudo hammer, making things even worse.

I don't think go clean should touch the std lib under any circumstance.

On Wed, 6 May 2015 09:30 Minux Ma notifications@github.com wrote:

I think this is consistent with the docs, introducing a special case
for the go command is going to break the consistency.

we obviously can't remove cmd/go from "all", and then the question
is why shouldn't go clean -i remove the installed binary of a package
or command included in the selected packages?

should go clean -i cmd/go be a no-op too? I doubt so.


Reply to this email directly or view it on GitHub
#10710 (comment).

@minux
Copy link
Member

minux commented May 5, 2015 via email

@davecheney
Copy link
Contributor

On 6 May 2015 9:49 am, "Minux Ma" notifications@github.com wrote:

are you suggesting that go clean -i std cmd should be a no-op?
why are things in $GOROOT that different?

Because in the general case, users of the language, not you and me that
compile trunk from source, they don't have permission to change $GOROOT.

If we want to fix this, let's fix it in the correct way. Introduce
negative selectors so that one can use go clean -i all -std -cmd
to clean only GOPATHs.

I disagree, this is an issue involving data loss; adding more flags and
expecting people to use them to not loose data is not an acceptable
solution to me.


Reply to this email directly or view it on GitHub.

@minux
Copy link
Member

minux commented May 5, 2015 via email

@AlekSi
Copy link
Contributor

AlekSi commented May 5, 2015

Because in the general case, users of the language, not you and me that
compile trunk from source, they don't have permission to change $GOROOT.

Well, OP used homebrew on OS X, it's quite typical.

@davecheney
Copy link
Contributor

Off topic, I have no idea why go clean is even necessary.

On Wed, 6 May 2015 09:56 Minux Ma notifications@github.com wrote:

go clean -i is a command that inherently involves data losses.

adding the GOROOT restriction it's like adding a safety measure to 'rm -rf
/*'.


Reply to this email directly or view it on GitHub
#10710 (comment).

@minux
Copy link
Member

minux commented May 6, 2015 via email

@ianlancetaylor
Copy link
Contributor

Just as "go build -a" does not rebuild the standard library in a release, I don't think that "go clean -i" should remove cmd/go in a release. There's just no way that anybody would expect that to happen.

I'm also OK with dropping the -i option to go clean, I don't know who would use that.

@ianlancetaylor ianlancetaylor reopened this May 6, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.5Maybe milestone May 6, 2015
@AlekSi
Copy link
Contributor

AlekSi commented May 6, 2015

I'm also OK with dropping the -i option to go clean, I don't know who would use that.

In this case (I'm original victim) I wanted to remove installed binaries from $GOPATH/bin.

@davecheney
Copy link
Contributor

Why not just do rm $GOPATH/bin/* ? To me it seems wrong for the go tool to
wrap an operation that can potentially loose data, I prefer that these
things are explicit.

On Wed, May 6, 2015 at 10:33 AM, Alexey Palazhchenko <
notifications@github.com> wrote:

I'm also OK with dropping the -i option to go clean, I don't know who
would use that.

In this case (I'm original victim) I wanted to remove installed binaries
from $GOPATH/bin.


Reply to this email directly or view it on GitHub
#10710 (comment).

@minux
Copy link
Member

minux commented May 6, 2015

I'm OK with dropping the -i option.

I don't like more special case for GOROOT (I still believe the go install -a
special case is a mistake (my alternative solution would be to ignore the
permission error if the new file is the same as the old one already there)).

I agree with Dave that removing $GOPATH/bin/* is better to be explicit
and go clean -i does much more than that.

@AlekSi
Copy link
Contributor

AlekSi commented May 6, 2015

Two reasons:

  1. Same command will work on both Windows and Unix.
  2. I wanted to remove only binaries corresponding to Go packages in $GOPATH – there is other stuff in bin.

@minux
Copy link
Member

minux commented May 6, 2015 via email

@AlekSi
Copy link
Contributor

AlekSi commented May 6, 2015

go to the GOPATH and run go clean -i ./... there.

The only downside is that command should be run at $GOPATH, not some $GOPATH subdirectory.

@minux
Copy link
Member

minux commented May 6, 2015 via email

@gopherbot
Copy link

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

@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

I tend to agree with Minux. The command says delete everything. It did. CL 9780 may end up with something useful, but it's not going to change what go clean -i all does.

@rsc rsc closed this as completed Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 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

7 participants