Skip to content

Commit 634e31a

Browse files
committed
fix: install script silently fails on build from source
The cargo build pipe (cargo | while read) was killed by set -euo pipefail — the while subshell exit status triggered set -e before reaching the cp command, so the binary never got installed. Fix: disable set -e around the pipe, use tee to preserve output, check PIPESTATUS[0] for cargo's actual exit code, and add an explicit binary-exists check with a clear error message.
1 parent 6d73d10 commit 634e31a

1 file changed

Lines changed: 34 additions & 17 deletions

File tree

install.sh

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,40 @@ if [ "$INSTALLED" = false ]; then
9393

9494
cd "$HACKCODE_SRC/rust"
9595

96-
# Build with live progress percentage (~200 crates expected)
97-
EST=200
98-
BUILT=0
99-
cargo build --release -p rusty-claude-cli 2>&1 | while IFS= read -r line; do
100-
case "$line" in
101-
*Compiling*)
102-
BUILT=$((BUILT + 1))
103-
PCT=$((BUILT * 100 / EST))
104-
[ "$PCT" -gt 99 ] && PCT=99
105-
CRATE=$(echo "$line" | sed 's/.*Compiling \([^ ]*\).*/\1/')
106-
printf "\r ${GREEN}[%3d%%]${NC} Compiling ${DIM}%-30s${NC}" "$PCT" "$CRATE"
107-
;;
108-
*Finished*)
109-
printf "\r ${GREEN}[100%%]${NC} Build complete %-40s\n" " "
110-
;;
111-
esac
112-
done
96+
# Build with live progress — disable set -e around the pipe so
97+
# the while-subshell exit doesn't kill the script before cp runs.
98+
BUILD_LOG=$(mktemp)
99+
echo -e " ${DIM}Compiling (~200 crates, this may take a few minutes)...${NC}"
100+
101+
set +e
102+
cargo build --release -p rusty-claude-cli 2>&1 | tee "$BUILD_LOG" | {
103+
EST=200
104+
BUILT=0
105+
while IFS= read -r line; do
106+
case "$line" in
107+
*Compiling*)
108+
BUILT=$((BUILT + 1))
109+
PCT=$((BUILT * 100 / EST))
110+
[ "$PCT" -gt 99 ] && PCT=99
111+
CRATE=$(echo "$line" | sed 's/.*Compiling \([^ ]*\).*/\1/')
112+
printf "\r ${GREEN}[%3d%%]${NC} Compiling ${DIM}%-30s${NC}" "$PCT" "$CRATE"
113+
;;
114+
*Finished*)
115+
printf "\r ${GREEN}[100%%]${NC} Build complete %-40s\n" " "
116+
;;
117+
esac
118+
done
119+
}
120+
BUILD_EXIT=${PIPESTATUS[0]:-$?}
121+
set -e
122+
rm -f "$BUILD_LOG"
123+
124+
if [ "$BUILD_EXIT" -ne 0 ] || [ ! -f "target/release/hackcode" ]; then
125+
echo ""
126+
echo -e " ${RED}Build failed (exit code $BUILD_EXIT)${NC}"
127+
echo -e " ${DIM}Check that Rust toolchain is up to date: rustup update${NC}"
128+
exit 1
129+
fi
113130

114131
mkdir -p "$INSTALL_DIR"
115132
cp "target/release/hackcode" "$INSTALL_DIR/hackcode"

0 commit comments

Comments
 (0)