mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-29 18:40:38 +00:00
Consolidates two reports that overlap in scope: - #476 (@senki): install.sh hardcoded `--python 3.11` but pyproject.toml declares `requires-python = ">=3.10,<3.14"`. The installer should track the project's allowed range, not pin a conservative-three-years-ago version. - #484 (@sanjayravit): install.sh crashed on hosts with no python3/python on PATH because `mark_done`, `beacon`, and `get_anon_id` all called $PY_CMD via inline Python heredocs. This PR closes both gaps with five surgical edits to install.sh (all behavior-preserving for the existing happy path; the bats tests prove it): 1. get_anon_id — replace `python3 -c uuid` with POSIX `/dev/urandom + od` + bash substring expansion. Same UUID v4 shape; works on Python-less hosts. 2. beacon — replace the 40-line Python heredoc with curl + a shell-built JSON payload. All inputs are from controlled sources (event ∈ fixed vocabulary, stage from stage_label(), numeric ids/codes from validated arithmetic, anon_id from a fresh UUID) so no general-purpose JSON escaping is needed. `|| true` is load-bearing — PostHog 5xx must never abort an install via the ERR trap. 3. mark_done — replace `python3 -c json.load+update+dump` with awk that regenerates the file from scratch. Idempotent: if the key is already marked, return early. Robust against prior format drift. wsl key is always rewritten last so a later FORCE_WSL=1 re-run correctly updates it. 4. parse_requires_python — new helper. Greps the project's requires-python field, handles inclusive (`<=3.13`) and exclusive (`<3.14`) upper bounds correctly, falls back to 3.11 if pyproject can't be parsed (the previous hardcoded value — safe under the existing 3.10-3.13 range). 5. create_venv — call parse_requires_python instead of hardcoding 3.11. The existing uv-managed-Python fallback (from #444) still kicks in if the host doesn't have the target version installed. Adversarial review caught two real bugs before commit: - HIGH: parse_requires_python's exclusive-bound regex would also match the digits after `<=` (inclusive bound) and then incorrectly subtract 1 — producing 3.12 from `<=3.13`. Fixed by checking the inclusive form first. - MEDIUM: the new "no Python on PATH" bats test silently skips symlinking `pgrep` on hosts where it isn't at /usr/bin or /bin (some minimal BusyBox configurations). Added an explicit "no matching process" fallback so start_ollama's check works. New bats coverage: - `install succeeds with no system Python on PATH (#484)` — builds a PATH that excludes python3/python and exercises the full install. Asserts state file is written and contains greppable step keys. - `mark_done is idempotent — second mark of same key doesn't duplicate` — re-runs the install and verifies install_uv appears exactly once in install-state.json. - `create_venv picks newest in requires-python range, not hardcoded 3.11 (#476)` — asserts uv was called with `--python 3.13` (the upper minor of `>=3.10,<3.14`). The git stub now includes `requires-python = ">=3.10,<3.14"` in its fake pyproject.toml so create_venv has something realistic to parse. @sanjayravit — your PR #484 motivated this consolidation; closing that one as superseded with credit. Co-authored-by: krypticmouse <herumbshandilya123@gmail.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
60 lines
2.0 KiB
Bash
Executable File
60 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Stub for git — supports clone and pull, returns success.
|
|
# For clone: creates a minimal fake repo tree at the target with the install scripts.
|
|
# Log the full command before any shifts.
|
|
echo "$@" >> "${GIT_STUB_LOG:-/dev/null}"
|
|
case "$1" in
|
|
clone)
|
|
# Args after `clone`: optional flags, then [url] [target]. Find the last two non-flag args.
|
|
target=""
|
|
url=""
|
|
shift # past 'clone'
|
|
while [[ $# -gt 0 ]]; do
|
|
if [[ "$1" == --* ]] || [[ "$1" == -* ]]; then
|
|
shift # skip flag and its possible value
|
|
if [[ $# -gt 0 ]] && [[ "$1" != --* ]] && [[ "$1" != -* ]] && [[ "$1" =~ ^[0-9]+$ ]]; then
|
|
shift # depth=N etc.
|
|
fi
|
|
continue
|
|
fi
|
|
if [[ -z "$url" ]]; then
|
|
url="$1"
|
|
else
|
|
target="$1"
|
|
fi
|
|
shift
|
|
done
|
|
if [[ -z "$target" ]]; then
|
|
target="${url##*/}"
|
|
target="${target%.git}"
|
|
fi
|
|
mkdir -p "$target/scripts/install"
|
|
# Provide minimal expected files so install.sh can copy them.
|
|
for s in install-rust.sh build-extension.sh pull-model.sh bg-orchestrator.sh \
|
|
jarvis-wrapper.sh jarvis-uninstall.sh; do
|
|
cat > "$target/scripts/install/$s" <<EOF2
|
|
#!/usr/bin/env bash
|
|
exit 0
|
|
EOF2
|
|
chmod +x "$target/scripts/install/$s"
|
|
done
|
|
# Make it look like a git repo so subsequent .git checks pass.
|
|
mkdir -p "$target/.git"
|
|
# Also create a pyproject.toml so editable install would work in real life.
|
|
# Includes requires-python so parse_requires_python in create_venv
|
|
# has something to match against — install.sh tracks the project's
|
|
# allowed range (#476).
|
|
cat > "$target/pyproject.toml" <<EOF2
|
|
[project]
|
|
name = "OpenJarvis"
|
|
version = "0.1.1"
|
|
requires-python = ">=3.10,<3.14"
|
|
EOF2
|
|
;;
|
|
pull)
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
exit "${GIT_STUB_EXIT:-0}"
|