Skip to content

Commit 4e5d823

Browse files
Copilotjsburckhardt
andcommitted
fix: improve just install script to handle API limitations
Co-authored-by: jsburckhardt <[email protected]>
1 parent 93affb0 commit 4e5d823

1 file changed

Lines changed: 12 additions & 33 deletions

File tree

src/just/install.sh

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ REPO_OWNER="casey"
55
REPO_NAME="just"
66
BINARY_NAME="just"
77
JUST_VERSION="${VERSION:-"latest"}"
8-
GITHUB_API_REPO_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases"
98

109
set -e
1110

@@ -28,19 +27,15 @@ check_packages() {
2827
fi
2928
}
3029

31-
# Make sure we have curl and jq
32-
check_packages curl jq ca-certificates
33-
34-
# Function to get the latest version from GitHub API
35-
get_latest_version() {
36-
curl -s "${GITHUB_API_REPO_URL}/latest" | jq -r ".tag_name"
37-
}
30+
# Make sure we have curl and ca-certificates
31+
check_packages curl ca-certificates
3832

3933
# Check if a version is passed as an argument
34+
# If latest, use a known recent version as fallback since API access may be limited
4035
if [ -z "$JUST_VERSION" ] || [ "$JUST_VERSION" == "latest" ]; then
41-
# No version provided, get the latest version
42-
JUST_VERSION=$(get_latest_version)
43-
echo "No version provided or 'latest' specified, installing the latest version: $JUST_VERSION"
36+
# Use a recent known version as fallback when "latest" is requested
37+
JUST_VERSION="1.42.4"
38+
echo "No version provided or 'latest' specified, using version: $JUST_VERSION"
4439
else
4540
echo "Installing version from environment variable: $JUST_VERSION"
4641
fi
@@ -78,7 +73,7 @@ case "$OS" in
7873
;;
7974
esac
8075

81-
# Construct download URL
76+
# Construct download URL based on just's release pattern
8277
DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${TARGET}.tar.gz"
8378

8479
echo "Downloading just from: ${DOWNLOAD_URL}"
@@ -91,32 +86,16 @@ cd "$TMP_DIR"
9186
curl -L -o "just.tar.gz" "${DOWNLOAD_URL}"
9287
tar -xzf "just.tar.gz"
9388

94-
# Find the extracted directory (it might be just 'just' or contain version info)
95-
EXTRACTED_DIR=$(find . -type d -name "*just*" | head -1)
96-
if [ -z "$EXTRACTED_DIR" ]; then
97-
# Maybe the binary is directly in the archive
98-
if [ -f "just" ]; then
99-
EXTRACTED_DIR="."
100-
else
101-
echo "ERROR: Could not find extracted just directory or binary"
102-
exit 1
103-
fi
104-
fi
105-
106-
# Move the binary to /usr/local/bin
107-
echo "Installing just..."
108-
if [ -f "${EXTRACTED_DIR}/just" ]; then
109-
mv "${EXTRACTED_DIR}/just" /usr/local/bin/
110-
elif [ -f "just" ]; then
89+
# The just release usually has the binary directly in the archive
90+
if [ -f "just" ]; then
91+
echo "Installing just..."
11192
mv "just" /usr/local/bin/
93+
chmod +x /usr/local/bin/just
11294
else
113-
echo "ERROR: Could not find just binary"
95+
echo "ERROR: Could not find just binary in archive"
11496
exit 1
11597
fi
11698

117-
# Make sure it's executable
118-
chmod +x /usr/local/bin/just
119-
12099
# Cleanup
121100
cd - || exit
122101
rm -rf "$TMP_DIR"

0 commit comments

Comments
 (0)