-
Notifications
You must be signed in to change notification settings - Fork 18k
x/build/cmd/relui: macOS installer should add GOBIN to PATH #39531
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
Comments
I think this is a good idea as it will lead to a noticeable improvement to the user experience for new users, and we should do this, unless we are able to discover a reason why doing so could be harmful or dangerous. Given the installers already own the decision of where to place the Go installation and make it available (via an added entry to PATH or a platform-equivalent), and by not setting a GOPATH, they are implicitly relying on the default GOPATH value that I'll think more about it, but I can't think of concerns with doing so. I'll tentatively mark this for consideration for 1.15, since it seems like a minor and safe change to me (and the change doesn't need to be done in the main Go tree). It's an opportunity to use an upcoming beta release to try it out and get user feedback. That said, we are in the release freeze for 1.15, so if people think this decision needs more time or input, we can move this for 1.16 cycle. /cc @golang/osp-team |
This issue is currently labeled as early-in-cycle for Go 1.16. |
@jayconrod Friendly ping on this. Does it sound good to you to move this issue to NeedsFix for 1.16 milestone? I'll also /cc @stevetraut who's been working on improving the installation experience, I think this change can be beneficial. |
Sure, it sounds like we're in agreement this is a good idea. Does anyone on the release team have bandwidth to fix this for 1.16? I'm not familiar with the installers, and I'm not sure if I'll have bandwidth to look at this before the freeze. |
Yes, I can take this. |
I've made progress on the side of the macOS installer, but ran into some usability questions around edge cases that we'll need to agree on answers to. I'll provide more detail and follow up on this during the 1.17 cycle. |
I spent some time investigating this and found some additional constraints and challenges. It seems we can't make a simple change here without potentially needing larger UI and behavior changes, and corresponding updates to the installation/uninstallation instructions. There are the following relevant factors:
Ownership of GOPATHThere's agreement it's clear what to do when an installer runs on a clean system, where neither The Windows installer differs from macOS installer in that Windows sets GOPATH to "%USERPROFILE%\go", while macOS one doesn't set it (and rely on cmd/go's default "$HOME/go" one). The Windows uninstaller has a mechanism to remove the environment variables it sets:
The macOS uninstall instructions are to remove In the original issue, @jayconrod suggested:
I explored that path: # Take existing $GOBIN and/or $GOPATH
# into account, then add $GOBIN to $PATH.
if _, ok := os.LookupEnv("GOBIN"); ok {
echo "$GOBIN" >> /etc/path.d/go
} else {
GOPATH=$(go env GOPATH)
if $GOPATH == "" {
// This should never happen. Bail out gracefully if it does.
return
}
$GOBIN := filepath.Join(filepath.SplitList($GOPATH)[0], "bin")
echo "$GOBIN" >> /etc/path.d/go
} But came to the conclusion that this might actually be counter-productive:
So the macOS installer doesn't currently set the GOPATH environment variable, it uses the default one, or the one the user has specified. This is how it behaved for a long time, so suddenly overwriting a potential custom GOPATH without prompting the user would be too disruptive. Starting to prompt the user would add cognitive overhead, so it's a bigger change to consider. Access to environment configurationDiscussion above assumes it's possible for the installer to know what Consider that the user may have those environment variables conditionally configured in a ConclusionBased on these findings, it seems making this change in the macOS installer may be a bigger undertaking than we anticipated, and needs a more holistic approach. I considered one possible best-effort solution of appending While talking about this briefly with @toothrot, he suggested a possible idea for the I don't plan to keep working on this for now, so moving out the Go 1.17 milestone. |
This that this 2020 issue is stalled on determining the right solution, I think it would be highly valuable and appreciated if Suggest that any such user facing message include a link to https://go.dev/doc/install where a more detailed explanation can be always be kept up to date. — If such a fix is going to still take some time, can we update the docs:
|
This is a good idea to avoid having to set up the environment variables manually. Ref: https://discussions.apple.com/thread/250911992?sortBy=best |
We currently provide installers for Go for Windows (an .msi file) and macOS (a .pkg file).
Both installers add
$GOROOT/bin
toPATH
. This lets users run commands likego build
without having to editPATH
themselves.However, users still need to edit
PATH
in order to run binaries installed withgo install
orgo get
. This introduces unnecessary confusion for new developers. To avoid this, both installers should add$GOBIN
toPATH
as well.(Note that neither
GOBIN
norGOPATH
are likely to be set when an installer runs. If they are set, we should respect them; the goal is just to ensure that the directory wherego install
writes binaries is added toPATH
).The text was updated successfully, but these errors were encountered: