Skip to content

Commit f70fdf7

Browse files
committed
fix(install): capture tar extraction diagnostic output on darwin-arm64 (PILOT-221)
macOS bsdtar can silently produce no output when extracting GitHub gzip archives on arm64 (darwin-arm64). The existing code suppressed stderr via 2>/dev/null, leaving users with a generic "failed to extract" error and no diagnostic path to debug or report the failure. This change: - Captures stderr from tar and gunzip into a temp file instead of /dev/null, so diagnostic output is available when extraction fails. - Uses an explicit EXTRACT_OK flag for cleaner fallback control flow. - Shows diagnostic output (tool stderr) when both extraction methods fail, making it possible to identify the root cause. - Cleans up the temp file on success. The gunzip|tar fallback is preserved as the second attempt path. Closes PILOT-221
1 parent eb18f4a commit f70fdf7

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

install.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,35 @@ if [ -n "$TAG" ]; then
302302
if tar --version 2>/dev/null | grep -q 'GNU tar'; then
303303
TAR_SAFE="--no-same-owner --no-same-permissions"
304304
fi
305-
# macOS bsdtar can fail silently on GitHub gzip archives.
306-
# Try tar -xzf first; fall back to gunzip|tar on failure.
307-
if ! tar -xzf "$TMPDIR/$ARCHIVE" -C "$TMPDIR" $TAR_SAFE 2>/dev/null || [ ! -f "$TMPDIR/pilotctl" ]; then
305+
# macOS bsdtar can fail silently on GitHub gzip archives
306+
# (e.g. darwin-arm64 — bsdtar reads the gzip format header
307+
# differently and may produce no output without reporting
308+
# an error). Try tar -xzf first; fall back to gunzip|tar on
309+
# failure. Both stderr paths are preserved in TAR_ERR so the
310+
# final error message includes diagnostic output.
311+
TAR_ERR=$(mktemp "${TMPDIR}/tar_err.XXXXXX")
312+
EXTRACT_OK=false
313+
if tar -xzf "$TMPDIR/$ARCHIVE" -C "$TMPDIR" $TAR_SAFE 2>"$TAR_ERR" && [ -f "$TMPDIR/pilotctl" ]; then
314+
EXTRACT_OK=true
315+
else
308316
echo " tar -xzf failed or produced no output; trying gunzip fallback..."
309-
gunzip -c "$TMPDIR/$ARCHIVE" | tar -x $TAR_SAFE -C "$TMPDIR"
317+
if gunzip -c "$TMPDIR/$ARCHIVE" 2>"$TAR_ERR" | tar -x $TAR_SAFE -C "$TMPDIR" 2>>"$TAR_ERR"; then
318+
if [ -f "$TMPDIR/pilotctl" ]; then
319+
EXTRACT_OK=true
320+
fi
321+
fi
310322
fi
311-
if [ ! -f "$TMPDIR/pilotctl" ]; then
323+
if [ "$EXTRACT_OK" != true ]; then
312324
echo "Error: failed to extract binaries from ${ARCHIVE}"
325+
if [ -s "$TAR_ERR" ]; then
326+
echo " Diagnostic output from extract tool:"
327+
sed 's/^/ /' "$TAR_ERR"
328+
fi
313329
echo "Try downloading manually from:"
314330
echo " ${URL}"
315331
exit 1
316332
fi
333+
rm -f "$TAR_ERR"
317334
else
318335
TAG=""
319336
fi

0 commit comments

Comments
 (0)