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'

Activity

  1. Haleclipse commented on Jun 7, 2026

    @Haleclipse
    Contributor
  2. giturass commented on Jun 7, 2026

    @giturass
    Author

    哈雷大佬 我发现这样安装的claude code会报429 rejected 用的any 用其他proot glibc-runner方法安装的就可以正常使用 不知道问题出在哪里 感谢

  3. Haleclipse commented on Jun 8, 2026

    @Haleclipse
    Contributor

    配置问题 跟程序没关系

  4. pinned this issue on Jun 8, 2026
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