Skip to content

Commit d8311dd

Browse files
author
AI Assistant
committed
fix(install): enable proper upgrade for Go and just
- install_go.sh: Add automatic download and installation of latest Go version from go.dev/VERSION - install_core.sh: Remove early return in install_just() to allow cargo reinstall for upgrades Previously: - Go: Script only printed message to install manually, no upgrade functionality - just: reconcile_one would remove apt package but install_just() returned early if binary existed Now: - Go: Downloads latest version from official Go site, removes old /usr/local/go, extracts new version - just: Always calls 'cargo install just' which reinstalls to latest version Fixes cargo-installed tools not upgrading when 'reconcile' action is used.
1 parent 1a6f985 commit d8311dd

2 files changed

Lines changed: 60 additions & 4 deletions

File tree

scripts/install_core.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,10 @@ install_glab() {
693693
}
694694

695695
install_just() {
696-
if have just; then return; fi
697-
if have brew; then brew install just; return; fi
696+
if have brew; then
697+
if have just; then brew upgrade just || brew install just; else brew install just; fi
698+
return
699+
fi
698700
if have cargo; then cargo install just; return; fi
699701
}
700702

scripts/install_go.sh

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,65 @@ have() { command -v "$1" >/dev/null 2>&1; }
55

66
TOOL="go"
77
before="$(have go && go version || true)"
8+
89
if have brew; then
9-
if have go; then brew upgrade go || true; else brew install go; fi
10+
# Use homebrew for installation/upgrade
11+
if have go; then brew upgrade go || brew install go || true; else brew install go || true; fi
1012
else
11-
echo "Please install Go from https://go.dev/dl/"
13+
# Manual installation from official Go downloads
14+
# Determine OS and architecture
15+
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
16+
ARCH="$(uname -m)"
17+
case "$ARCH" in
18+
x86_64|amd64) GOARCH="amd64" ;;
19+
aarch64|arm64) GOARCH="arm64" ;;
20+
armv6*) GOARCH="armv6l" ;;
21+
*) GOARCH="amd64" ;;
22+
esac
23+
24+
# Get latest version from Go download page
25+
TMP="$(mktemp -d)"
26+
VERSION_URL="https://go.dev/VERSION?m=text"
27+
if curl -fsSL "$VERSION_URL" -o "$TMP/version.txt" 2>/dev/null; then
28+
# VERSION file contains lines like "go1.25.2" - take first line
29+
TARGET_VERSION="$(head -n1 "$TMP/version.txt" | tr -d '\n\r')"
30+
if [ -n "$TARGET_VERSION" ]; then
31+
# Download archive
32+
ARCHIVE="${TARGET_VERSION}.${OS}-${GOARCH}.tar.gz"
33+
DOWNLOAD_URL="https://go.dev/dl/${ARCHIVE}"
34+
35+
echo "Downloading ${ARCHIVE}..."
36+
if curl -fsSL "$DOWNLOAD_URL" -o "$TMP/${ARCHIVE}"; then
37+
# Remove existing installation
38+
if [ -d "/usr/local/go" ]; then
39+
echo "Removing existing /usr/local/go..."
40+
sudo rm -rf /usr/local/go
41+
fi
42+
43+
# Extract new version
44+
echo "Extracting to /usr/local/go..."
45+
sudo tar -C /usr/local -xzf "$TMP/${ARCHIVE}"
46+
47+
# Ensure /usr/local/go/bin is in PATH
48+
if [ ! -f "/usr/local/bin/go" ]; then
49+
sudo ln -sf /usr/local/go/bin/go /usr/local/bin/go 2>/dev/null || true
50+
sudo ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt 2>/dev/null || true
51+
fi
52+
else
53+
echo "Failed to download ${DOWNLOAD_URL}"
54+
echo "Please install Go manually from https://go.dev/dl/"
55+
fi
56+
else
57+
echo "Failed to determine latest Go version"
58+
echo "Please install Go from https://go.dev/dl/"
59+
fi
60+
else
61+
echo "Failed to fetch Go version information"
62+
echo "Please install Go from https://go.dev/dl/"
63+
fi
64+
rm -rf "$TMP" 2>/dev/null || true
1265
fi
66+
1367
after="$(have go && go version || true)"
1468
path="$(command -v go 2>/dev/null || true)"
1569
printf "[%s] before: %s\n" "$TOOL" "${before:-<none>}"

0 commit comments

Comments
 (0)