Skip to content

fix(go): preserve ~/go across version upgrades#1057

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-go-installer-global-tools-issue
Draft

fix(go): preserve ~/go across version upgrades#1057
Copilot wants to merge 4 commits intomainfrom
copilot/fix-go-installer-global-tools-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 12, 2026

  • Update go/install.sh pkg_link() to keep ~/go stable across version upgrades
  • Mirror same changes to golang/install.sh
  • Use test instead of [ ... ] per codebase convention
  • Refactor pkg_link() to use early returns instead of nested elif
Original prompt

This section details on the original issue you should resolve

<issue_title>Go installer removes all globally installed tools when upgrading</issue_title>
<issue_description>I just upgraded to go v1.26.1 with webinstall.dev and in the process it has removed all global/binary tools I've installed with "go install ...". Why? Does the script need to remove everything to upgrade version? The official installer just dumps new files into the /usr/local/go folder without touching anything else...</issue_description>

<agent_instructions>Update the Go installer such that if there is not a ~/go/, it will create it (not as a symlink), but if there is one that's versioned in ~/.local/opt, it will rename it without the version continue to use the same one rather than swap symlinks.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@coolaj86 It doesn't actually _remove_ any of the globally installed tools, it creates a new symlink.

It you look in ~/.local/opt/ you'll see that everything is still there.

The reason for this was simply that most tools have huge breaking changes between even minor versions (node, ruby, python, etc) and Webi is conflict-free by design - everything is guaranteed to work and not break even when switching between versions.

However, Go has proven to not have that problem, so I think it's worth having it not follow that safety measure and keep the original ~/go/ rather than updating the symlink.</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Previously, each `go install` upgrade would create a new versioned
`go-bin-vX.Y.Z` directory and symlink `~/go` to it, effectively
hiding all globally-installed Go tools on every upgrade.

New behavior in pkg_link():
- New install: create ~/go as a real directory (not a symlink)
- Existing versioned symlink: rename go-bin-vX.Y.Z to the stable
  unversioned path ~/.local/opt/go-bin, preserving all installed tools
- Already migrated (symlink to go-bin) or real dir: leave untouched
- Broken symlink: recreate ~/go as a real directory

Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Go installer to preserve globally installed tools fix(go): preserve ~/go across version upgrades Mar 12, 2026
Comment thread go/install.sh Outdated
# all Go versions, so ~/go is kept stable rather than being swapped to a
# versioned directory on each upgrade.
b_gobin_stable="${HOME}/.local/opt/go-bin"
if [ ! -e "$GOBIN" ] && [ ! -L "$GOBIN" ]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use test instead of [ ... ]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in cd7948c — replaced all [ ... ] with test in both go/install.sh and golang/install.sh.

Comment thread go/install.sh Outdated
if [ ! -e "$GOBIN" ] && [ ! -L "$GOBIN" ]; then
# New install: create ~/go as a real directory (not a symlink)
mkdir -p "$GOBIN/bin"
elif [ -L "$GOBIN" ]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot It looks like an early return would be well-suited here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3cb1dc6pkg_link() is now flat with early returns for each case (not exists, real dir, already stable symlink, versioned symlink migration, broken symlink).

Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go installer unlinks globally installed tools when upgrading

2 participants