Docker Push / Push CUDA image to Docker (push) Canceled after 0s
* fix: probe github ssh auth directly in install.sh The previous `has_ssh_access` probe ran `git ls-remote` against the public prime-rl repo, which can return success under SSH connection multiplexing, cached creds, or other states without the local key actually being registered with a GitHub user. When that happens, the HTTPS `insteadOf` rewrite is never applied and private-submodule clones fail with "Permission denied (publickey)". Use `ssh -T git@github.com` and grep for the canonical "successfully authenticated" string instead. This is a direct check of the precondition (your key is registered with a GitHub user) and matches the pattern git itself recommends. * fix: capture ssh output to var so pipefail doesn't mask success `ssh -T git@github.com` always exits 1 (GitHub denies shell access after authenticating), and install.sh has `set -o pipefail` at the top, so the previous pipeline made has_ssh_access return failure even for developers with valid keys. Capture stdout/stderr into a variable first, then grep — keeps pipefail intact for the rest of the script. * fix: use universal ssh options in github auth probe `StrictHostKeyChecking=accept-new` requires OpenSSH 7.6+ (Sep 2017). On older systems ssh errors with 'Bad configuration option' and the probe wrongly reports no SSH auth, forcing HTTPS even when SSH would have worked. Use `StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null` instead, which works on all OpenSSH versions. Safe for a probe-only flow: no key material is exchanged, and a hostile MITM at worst makes the probe wrongly report 'no SSH', causing HTTPS fallback for public repos. * fix: rely on ensure_known_hosts and default ssh host key checking Previous commit disabled `StrictHostKeyChecking` and `UserKnownHostsFile` to side-step OpenSSH version requirements, but that made the auth probe trust any host that returns the "successfully authenticated" string — a MITM could steer the script into using their SSH for submodule clones. `ensure_known_hosts` already runs (line 116) before any `has_ssh_access` call and populates github.com via ssh-keyscan, so default host key checking is both safe and sufficient. Drop the options entirely; keep `BatchMode=yes` to suppress prompts. * fix: propagate insteadOf to submodule clones via GIT_CONFIG_* env `git submodule--helper clone` spawns fresh `git clone` processes that read only ~/.gitconfig and env vars — not the parent repo's local .git/config. So setting `url..insteadOf` locally never reached the submodule clones, and they kept attempting SSH despite the probe correctly reporting no auth. Use `GIT_CONFIG_COUNT`/`GIT_CONFIG_KEY_0`/`GIT_CONFIG_VALUE_0` which propagate the rewrite to every child git process for the duration of this script, with no persistent state in ~/.gitconfig.
166 lines
4.8 KiB
Bash
Executable File
166 lines
4.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
|
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
|
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
|
|
|
REPO_ID="prime-rl"
|
|
|
|
# Flag defaults (can be overridden via env)
|
|
SKIP_CLONE=${SKIP_CLONE:-0}
|
|
|
|
assert_supported_platform() {
|
|
local os arch
|
|
os="$(uname -s)"
|
|
arch="$(uname -m)"
|
|
|
|
if [ "$os" != "Linux" ]; then
|
|
log_error "Unsupported platform: ${os}/${arch}."
|
|
log_error "prime-rl currently supports Linux on x86_64 or aarch64 only."
|
|
exit 1
|
|
fi
|
|
|
|
case "$arch" in
|
|
x86_64 | aarch64) ;;
|
|
*)
|
|
log_error "Unsupported architecture: ${arch}."
|
|
log_error "prime-rl currently supports Linux on x86_64 or aarch64 only."
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if ! command -v apt &>/dev/null; then
|
|
log_error "Unsupported Linux distribution: apt is required by this installer."
|
|
log_error "Use a Debian/Ubuntu-based Linux machine on x86_64 or aarch64, or install manually."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
has_ssh_access() {
|
|
# Probe GitHub SSH auth directly. `ssh -T git@github.com` returns
|
|
# "successfully authenticated" only when the local key is registered
|
|
# with a GitHub user, which is the precondition for cloning private
|
|
# submodules over SSH. The previous `git ls-remote` probe could
|
|
# spuriously succeed (cached creds, public-repo edge cases) and
|
|
# leave submodule clones to fail later.
|
|
#
|
|
# Note: ssh -T git@github.com always exits 1 (GitHub denies shell
|
|
# access after authenticating), so we capture stdout/stderr to a var
|
|
# first and grep the var. Piping directly would trigger pipefail.
|
|
set +e
|
|
out=$(timeout 5s ssh -o BatchMode=yes -T git@github.com 2>&1)
|
|
echo "$out" | grep -q "successfully authenticated"
|
|
rc=$?
|
|
set -e
|
|
return $rc
|
|
}
|
|
|
|
ensure_known_hosts() {
|
|
# Make sure ~/.ssh exists with the right perms, then add GitHub host key.
|
|
mkdir -p "${HOME}/.ssh"
|
|
chmod 700 "${HOME}/.ssh"
|
|
# Use -H to hash hostnames; merge uniquely to avoid dupes.
|
|
if command -v ssh-keyscan >/dev/null 2>&1; then
|
|
ssh-keyscan -H github.com 2>/dev/null | sort -u |
|
|
tee -a "${HOME}/.ssh/known_hosts" >/dev/null
|
|
chmod 600 "${HOME}/.ssh/known_hosts"
|
|
fi
|
|
}
|
|
|
|
# Initialize each submodule independently so that a missing private repo
|
|
# (e.g. configs/private when the user lacks access) does not abort the install.
|
|
init_submodules() {
|
|
if [ ! -f .gitmodules ]; then
|
|
return 0
|
|
fi
|
|
local paths failures
|
|
paths=$(git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | awk '{print $2}')
|
|
failures=()
|
|
for path in $paths; do
|
|
log_info "Initializing submodule: ${path}"
|
|
if git submodule update --init --recursive -- "$path"; then
|
|
:
|
|
else
|
|
log_warn "Could not initialize submodule '${path}' (likely no access). Continuing without it."
|
|
failures+=("$path")
|
|
fi
|
|
done
|
|
if [ "${#failures[@]}" -gt 0 ]; then
|
|
log_warn "Skipped submodules: ${failures[*]}"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
assert_supported_platform
|
|
|
|
# Ensure sudo exists
|
|
if ! command -v sudo &>/dev/null; then
|
|
apt update
|
|
apt install -y sudo
|
|
fi
|
|
|
|
log_info "Installing base packages..."
|
|
sudo apt update
|
|
sudo apt install -y build-essential openssh-client curl git tmux htop nvtop
|
|
|
|
log_info "Configuring SSH known_hosts for GitHub..."
|
|
ensure_known_hosts
|
|
|
|
if [ "$SKIP_CLONE" -eq 1 ]; then
|
|
log_info "Skipping clone; assuming we are already inside the repo."
|
|
else
|
|
log_info "Determining best way to clone (SSH vs HTTPS)..."
|
|
if has_ssh_access; then
|
|
log_info "SSH access to GitHub works. Cloning via SSH."
|
|
git clone git@github.com:PrimeIntellect-ai/${REPO_ID}.git
|
|
else
|
|
log_warn "SSH auth to GitHub not available. Cloning via HTTPS."
|
|
git clone https://github.com/PrimeIntellect-ai/${REPO_ID}.git
|
|
fi
|
|
|
|
log_info "Entering project directory..."
|
|
cd ${REPO_ID}
|
|
fi
|
|
|
|
if ! has_ssh_access; then
|
|
# Propagate the rewrite via env vars so it reaches `git submodule--helper clone`,
|
|
# which spawns fresh `git clone` processes that do not read the parent repo's
|
|
# local `.git/config`. Local `git config url..insteadOf` is invisible to them.
|
|
log_info "Routing git@github.com: SSH URLs to HTTPS for this run."
|
|
export GIT_CONFIG_COUNT=1
|
|
export GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf"
|
|
export GIT_CONFIG_VALUE_0="git@github.com:"
|
|
fi
|
|
|
|
log_info "Initializing submodules..."
|
|
init_submodules
|
|
|
|
log_info "Installing uv..."
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
log_info "Sourcing uv environment..."
|
|
if ! command -v uv &>/dev/null; then
|
|
source $HOME/.local/bin/env
|
|
fi
|
|
|
|
log_info "Installing prime..."
|
|
uv tool install prime
|
|
|
|
log_info "Syncing virtual environment..."
|
|
uv sync --all-extras
|
|
|
|
log_info "Installing pre-commit hooks..."
|
|
uv run pre-commit install
|
|
|
|
log_info "Installation completed!"
|
|
}
|
|
|
|
main
|