Skip to content

Android Termux 安装修复 #7

Description

@giturass

#!/usr/bin/env sh
set -eu

PACKAGE_NAME="${1:-@cometix/claude-code}"
GYP_DIR="${HOME}/.gyp"
GYP_FILE="${GYP_DIR}/include.gypi"

log() {
printf '\n==> %s\n' "$*"
}

fail() {
printf '\nERROR: %s\n' "$*" >&2
exit 1
}

require_cmd() {
command -v "$1" >/dev/null 2>&1 || fail "Command not found: $1"
}

log "Checking Termux tools"
require_cmd pkg
require_cmd npm

log "Installing build dependencies"
pkg update -y
pkg install -y nodejs python make clang pkg-config

log "Writing node-gyp android_ndk_path workaround"
mkdir -p "$GYP_DIR"

if [ -f "$GYP_FILE" ]; then
BACKUP_FILE="${GYP_FILE}.bak.$(date +%Y%m%d-%H%M%S)"
cp "$GYP_FILE" "$BACKUP_FILE"
printf 'Backed up existing %s to %s\n' "$GYP_FILE" "$BACKUP_FILE"
fi

cat > "$GYP_FILE" <<'EOF'
{
'variables': {
'android_ndk_path': ''
}
}
EOF

log "Using Python for node-gyp"
PYTHON_BIN="$(command -v python3 || command -v python)"
printf 'Python: %s\n' "$PYTHON_BIN"

log "Installing ${PACKAGE_NAME}"
PYTHON="$PYTHON_BIN" npm install -g "$PACKAGE_NAME"

log "Done"
printf 'If npm still fails, the package probably needs Linux/proot because node-pty is not fully supported on native Android.\n'

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions