Proposal: go get should exit if GOPATH is not set

121 vues
Accéder directement au premier message non lu

Dave Cheney

non lue,
16 juil. 2012, 00:37:5216/07/2012
à golang-dev,Andrew Gerrand
Hello,

A frequent problem reported on IRC is the go tool not working
properly. We've gotten pretty good at debugging the issue to these
culprits.

1. GOPATH is not exported.
2. while 1 was in effect, go get downloaded the source to
$GOROOT/src/pkg and now aliases any other copy of the source.

I would like to propose that a change be made to the go tool so that
it will not fetch third party source if GOPATH is not set. While there
are cases where not having a GOPATH is valid, I think that go get is
not one of them and this will solve the first issue, and by doing so,
reduce the frequency of the second.

A sample proposal is available at http://codereview.appspot.com/6397048/

I look forward to your feedback.

Cheers

Dave

Andrew Gerrand

non lue,
16 juil. 2012, 14:53:0216/07/2012
à Dave Cheney,golang-dev
I'm with this proposal.

Even though it works, it's almost always the wrong thing to install
external packages inside GOROOT. I now feel that it was a mistake to
allow it in the first place.

Perhaps people who want to install external packages inside GOROOT can
hack their go tool to permit it. That shouldn't be a big deal as
they'd already have a writable GOROOT.

Andrew

Jan Mercl

non lue,
16 juil. 2012, 16:10:2516/07/2012
à Dave Cheney,golang-dev,Andrew Gerrand
On Mon, Jul 16, 2012 at 6:37 AM, Dave Cheney <da...@cheney.net> wrote:
I look forward to your feedback.

Personally I'm fine with this (as I don't need to install packages to $GOROOT/whatever). But I don't know if the compatibilty promise covers also scripts invoking Go 1 tools...? There might be some which will get broken by the CL, IIUC.

-j 

Andrew Gerrand

non lue,
16 juil. 2012, 16:20:2216/07/2012
à Jan Mercl,Dave Cheney,golang-dev
Nope, the compatibility promise doesn't cover the tools.

Brad Fitzpatrick

non lue,
16 juil. 2012, 16:25:4716/07/2012
à Andrew Gerrand,Jan Mercl,Dave Cheney,golang-dev
On Mon, Jul 16, 2012 at 1:20 PM, Andrew Gerrand <a...@golang.org> wrote:

Nope, the compatibility promise doesn't cover the tools.

Just because we don't have an automated check for it doesn't mean the promise isn't there.

It would suck if I did apt-get update golang-go and my Go hypothetically updated from 1.0.5 to 1.1.2 and suddenly my go-get-proxy service stops working because the command line flags or verbs changed.

Maybe this change is okay, but I wouldn't go so far as to say that the compatibility promise doesn't apply to the tools.

Patrick Mylund Nielsen

non lue,
16 juil. 2012, 16:26:0016/07/2012
à Andrew Gerrand,Dave Cheney,golang-dev
Definitely agree. GOPATH seems to be the thing that gets the most people stuck. It would be great if the tool warned about an unexported GOPATH, and possibly included instructions or linked to a page with instructions for the different platforms. (It's easy to do GOPATH=/home/foo/bar; go, in bash, but it doesn't work, and nothing tells you why.) That you can just have one directory in GOPATH for everything also isn't obvious to newcomers.

Andrew Gerrand

non lue,
16 juil. 2012, 16:27:4116/07/2012
à Brad Fitzpatrick,Jan Mercl,Dave Cheney,golang-dev

Brad Fitzpatrick

non lue,
16 juil. 2012, 16:29:2016/07/2012
à Andrew Gerrand,Jan Mercl,Dave Cheney,golang-dev
Break all the things!

Andrew Gerrand

non lue,
16 juil. 2012, 16:31:0616/07/2012
à Brad Fitzpatrick,Jan Mercl,Dave Cheney,golang-dev
goinstall had a weird heuristic: if something went wrong when remotely
installing something and you didn't have GOPATH set, it would say
"Hey, this didn't work, try setting GOPATH".

It was correct sometimes, but it was also wrong sometimes. And it was
particularly confounding to people who had non-GOPATH-related issues.

That's why I'm in favor of this, at least tentatively. If it's just a
case of "No, do this first," then that's an instruction/diagnostic we
can give reliably.

Curious to hear more people's thoughts.

Kyle Lemons

non lue,
16 juil. 2012, 17:49:3216/07/2012
à Andrew Gerrand,Brad Fitzpatrick,Jan Mercl,Dave Cheney,golang-dev
I'm with you, but I originally assumed that I'm biased toward making things easier on me as a helper on the mailing list and IRC (since it would remove a huge class of common questions) and that this thread would light up with people in support of packages in GOROOT; since it hasn't, I'm less sure that I'm in the minority on this one :).  I was an early adopter of GOPATH, so I find it somewhat difficult to gauge community opinion on it.

Patrick Mylund Nielsen

non lue,
16 juil. 2012, 17:58:3016/07/2012
à Kyle Lemons,Andrew Gerrand,Brad Fitzpatrick,Jan Mercl,Dave Cheney,golang-dev
Most people I've seen have done this by putting GOROOT in GOPATH. I think the argument for "no-conf" in non-default locations is pretty slim since you'd have to set GOROOT anyway.

> I originally assumed that I'm biased toward making things easier on me as a helper on the mailing list and IRC (since it would remove a huge class of common questions) 

Or, put another way: this would Go a lot easier to use for a lot of people. It's definitely a top 3 question. As long as the error message isn't ambiguous, why not?

Dave Cheney

non lue,
16 juil. 2012, 19:28:2016/07/2012
à Patrick Mylund Nielsen,Kyle Lemons,Andrew Gerrand,Brad Fitzpatrick,Jan Mercl,golang-dev
Thank you all for your considered comments. I'll hg mail this proposal
for wider review.

Andrew Gerrand

non lue,
16 juil. 2012, 22:20:3716/07/2012
à Dave Cheney,Patrick Mylund Nielsen,Kyle Lemons,Brad Fitzpatrick,Jan Mercl,golang-dev
On 16 July 2012 16:28, Dave Cheney <da...@cheney.net> wrote:
> Thank you all for your considered comments. I'll hg mail this proposal
> for wider review.

I'd prefer to decide exactly what we should do before doing the code part.

In particular I'd like to hear from Russ, as he designed the thing in
the first place. He's just returning from holidays so it'll probably
take him a bit to catch up.

Andrew

Russ Cox

non lue,
29 juil. 2012, 19:00:3129/07/2012
à Andrew Gerrand,Dave Cheney,Patrick Mylund Nielsen,Kyle Lemons,Brad Fitzpatrick,Jan Mercl,golang-dev
I am not comfortable with this proposal. If I want to put all my code
in $GOROOT, I should not have some tool telling me I can't. Especially
since there might already be people working this way.

I don't understand the problems being reported on IRC. If the code
gets downloaded once into $GOROOT, don't future go get's update that
copy of the code? What's the problem, other than the location being
unexpected?

It also seems like go list -f '{{.Dir}}' pkg/path would be a trivial
way to diagnose this.

Russ

Patrick Mylund Nielsen

non lue,
29 juil. 2012, 23:24:2629/07/2012
à Russ Cox,Andrew Gerrand,Dave Cheney,Kyle Lemons,Brad Fitzpatrick,Jan Mercl,golang-dev
IMO the biggest problem is not being able to tell, e.g. via go env, or having the Go tool tell you when you there's an error and GOPATH isn't in go's environ, e.g. "Is GOPATH set correctly? See 'go doc gopath'". A common problem is GOPATH=/home/foo/go; go build -> "why doesn't it work?"

Russ Cox

non lue,
29 juil. 2012, 23:48:3329/07/2012
à Patrick Mylund Nielsen,Andrew Gerrand,Dave Cheney,Kyle Lemons,Brad Fitzpatrick,Jan Mercl,golang-dev
On Sun, Jul 29, 2012 at 11:24 PM, Patrick Mylund Nielsen
<pat...@patrickmylund.com> wrote:
> IMO the biggest problem is not being able to tell, e.g. via go env, or
> having the Go tool tell you when you there's an error and GOPATH isn't in
> go's environ, e.g. "Is GOPATH set correctly? See 'go doc gopath'". A common
> problem is GOPATH=/home/foo/go; go build -> "why doesn't it work?"

The biggest problem is not being able to tell what?

Patrick Mylund Nielsen

non lue,
29 juil. 2012, 23:52:0829/07/2012
à Russ Cox,Andrew Gerrand,Dave Cheney,Kyle Lemons,Brad Fitzpatrick,Jan Mercl,golang-dev
Sorry -- 'go env' doesn't show GOPATH (unless that changed recently) so you can't easily tell if GOPATH is "visible" to go or not, i.e. if it is actually exported, so many end up spending a lot of time wondering what they have to do with those folders when in reality they set GOPATH instead of exporting it in bash.

Russ Cox

non lue,
30 juil. 2012, 00:05:0330/07/2012
à Patrick Mylund Nielsen,Andrew Gerrand,Dave Cheney,Kyle Lemons,Brad Fitzpatrick,Jan Mercl,golang-dev
On Sun, Jul 29, 2012 at 11:52 PM, Patrick Mylund Nielsen
<pat...@patrickmylund.com> wrote:
> Sorry -- 'go env' doesn't show GOPATH (unless that changed recently) so you
> can't easily tell if GOPATH is "visible" to go or not, i.e. if it is
> actually exported, so many end up spending a lot of time wondering what they
> have to do with those folders when in reality they set GOPATH instead of
> exporting it in bash.

CL 6446064.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message