Skip to content

Commit fcd9b2d

Browse files
committed
Improve install script robustness with WSL binary filtering, pnpm fallbacks, and error logging
- installing in wsl fails
1 parent 9eba5b8 commit fcd9b2d

1 file changed

Lines changed: 44 additions & 7 deletions

File tree

‎install.sh‎

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,20 @@ if ! command -v git &> /dev/null; then
357357
exit 1
358358
fi
359359

360+
is_wsl_windows_bin() {
361+
case "$1" in
362+
/mnt/[a-zA-Z]/*) return 0 ;;
363+
*) return 1 ;;
364+
esac
365+
}
366+
360367
check_node_version() {
361-
if ! command -v node &> /dev/null; then return 1; fi
368+
local node_bin npm_bin
369+
node_bin=$(command -v node 2>/dev/null) || return 1
370+
npm_bin=$(command -v npm 2>/dev/null) || return 1
371+
if is_wsl_windows_bin "$node_bin" || is_wsl_windows_bin "$npm_bin"; then
372+
return 1
373+
fi
362374
local version
363375
version=$(node -v | sed 's/^v//' | cut -d. -f1)
364376
[ "$version" -ge 20 ]
@@ -486,12 +498,18 @@ stop_spinner() {
486498
fi
487499
}
488500

501+
CWC_DIR="$HOME/.cwc"
502+
mkdir -p -m 700 "$CWC_DIR"
503+
chmod 700 "$CWC_DIR" 2>/dev/null || true
504+
505+
STEP_LOG="$CWC_DIR/install.log"
506+
489507
run_step() {
490508
local msg="$1"; shift
491509
printf " %s..." "$msg"
492510
start_spinner &
493511
SPINNER_PID=$!
494-
if "$@" > /dev/null 2>&1 < /dev/null; then
512+
if "$@" > "$STEP_LOG" 2>&1 < /dev/null; then
495513
stop_spinner 0
496514
else
497515
stop_spinner 1
@@ -501,14 +519,30 @@ run_step() {
501519

502520
echo ""
503521

504-
if ! command -v pnpm >/dev/null 2>&1; then
522+
has_valid_pnpm() {
523+
local pnpm_bin
524+
pnpm_bin=$(command -v pnpm 2>/dev/null) || return 1
525+
! is_wsl_windows_bin "$pnpm_bin"
526+
}
527+
528+
if ! has_valid_pnpm; then
505529
npm install -g pnpm >/dev/null 2>&1 || true
530+
npm_prefix=$(npm prefix -g 2>/dev/null || true)
531+
if [ -n "$npm_prefix" ] && [ -d "$npm_prefix/bin" ]; then
532+
export PATH="$npm_prefix/bin:$PATH"
533+
fi
506534
fi
507535

508-
CWC_DIR="$HOME/.cwc"
536+
if ! has_valid_pnpm; then
537+
mkdir -p "$CWC_DIR/.tools"
538+
npm install --prefix "$CWC_DIR/.tools" pnpm >/dev/null 2>&1 || true
539+
export PATH="$CWC_DIR/.tools/node_modules/.bin:$PATH"
540+
fi
509541

510-
mkdir -p -m 700 "$CWC_DIR"
511-
chmod 700 "$CWC_DIR" 2>/dev/null || true
542+
if ! has_valid_pnpm; then
543+
echo "$msg_error Failed to install pnpm."
544+
exit 1
545+
fi
512546

513547
update_repo() {
514548
if [ -n "$TAG_NAME" ]; then
@@ -558,7 +592,10 @@ if ! run_step "$msg_step_deps" pnpm --filter gemini-coder --filter browser insta
558592
pnpm store prune > /dev/null 2>&1 || true
559593
run_step "$msg_step_cloning" clone_repo
560594
cd "$REPO_DIR"
561-
run_step "$msg_step_deps" pnpm --filter gemini-coder --filter browser install
595+
if ! run_step "$msg_step_deps" pnpm --filter gemini-coder --filter browser install; then
596+
tail -n 20 "$STEP_LOG" >&2 || true
597+
exit 1
598+
fi
562599
fi
563600

564601
rm -f ./apps/editor/*.vsix

0 commit comments

Comments
 (0)