Skip to content

POSIX installer overrides an explicit Git target with the caller checkout #127361

Closed

Description

@steipete

Summary

When the full POSIX installer runs from inside any OpenClaw checkout, its Git path unconditionally replaces the configured GIT_DIR with the checkout detected from $PWD. This overrides both explicit --git-dir and OPENCLAW_GIT_DIR, so the installer mutates/builds the caller's current checkout instead of the requested target.

A no-network source harness at frozen a434545620127a3105699513d662395a43b43eb1 set a distinct requested directory, ran main() from an OpenClaw checkout, and observed:

selected=/home/user/workspace/repo

Current main was rechecked and still unconditionally assigns repo_dir="$detected_checkout" after initializing repo_dir="$GIT_DIR".

Deterministic sequence

cd /srv/openclaw-a
./scripts/install.sh --git --git-dir /srv/openclaw-b

Equivalent environment form:

cd /srv/openclaw-a
OPENCLAW_GIT_DIR=/srv/openclaw-b ./scripts/install.sh --git

In both cases, checkout A is selected/mutated/built and checkout B is ignored.

Owner / contract

  • scripts/install.sh initializes GIT_DIR from OPENCLAW_GIT_DIR or the default.
  • Argument parsing assigns --git-dir into the same variable.
  • main() detects an OpenClaw checkout from $PWD.
  • Git installation starts with repo_dir="$GIT_DIR" but then unconditionally replaces it when a checkout was detected.
  • Installer docs advertise both selectors as explicit checkout-directory controls; environment docs say explicit path overrides retain precedence.
  • The dedicated-prefix POSIX installer and Windows path do not perform this substitution.

Current tests cover lower-level Git installation and CLI/env paths, but not main() with an unrelated valid OpenClaw $PWD.

Targeted live issue/PR searches found no exact existing root.

Suggested repair

Track whether the Git target was explicitly supplied by nonempty OPENCLAW_GIT_DIR or --git-dir. Reuse detected_checkout only when no explicit target exists. CLI should retain precedence over environment if both are supplied according to existing option policy.

Regression

At the main() boundary, run from checkout A while requesting checkout B through:

  1. --git-dir;
  2. OPENCLAW_GIT_DIR;
  3. no explicit target (where detected A may remain the intended convenience).

Stub mutation/build callees and assert only the intended directory is selected.

Risk

Review required, medium installer-precedence impact. The current behavior can update/build the wrong checkout while reporting success and leaving the explicitly requested owner untouched.

Activity

  1. added
    bug
    maintainer
    on Aug 21, 2026
  2. added
    clawsweeper:needs-maintainer-review
    clawsweeper:no-new-fix-pr
    clawsweeper:source-repro
    impact:other
    issue-rating: 🦞 diamond lobster
    maturity:stable
    P2
    on Aug 21, 2026
  3. clawsweeper commented on Aug 21, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 25, 2026, 6:34 AM ET / 10:34 UTC.

    Summary
    Keep open: current main still replaces the explicit Git target with the detected caller checkout, and the protected issue has a focused open repair PR that formally owns the fix.

    Reproducibility: yes. Current main sets an explicit target and then unconditionally replaces it when checkout detection succeeds; this owner-boundary defect is directly traceable from source.

    Next step
    The formally linked open repair already owns this focused fix, and the maintainer label requires human review rather than a duplicate automation job.

    Review details

    Best possible solution:

    Land the linked repair with regression coverage for CLI, environment, and no-explicit-target cases, retaining checkout detection only as the convenience fallback.

    Do we have a high-confidence way to reproduce the issue?

    Yes. Current main sets an explicit target and then unconditionally replaces it when checkout detection succeeds; this owner-boundary defect is directly traceable from source.

    Is this the best way to solve the issue?

    Yes. Using the detected checkout only when no nonempty explicit target was supplied restores the contract without removing the convenience fallback.

    AGENTS.md: found and applied where relevant.

    Codex review notes: model internal, reasoning high; reviewed against 837b89a0e75c.

    Label changes

    Label justifications:

    • P2: The defect can update and build the wrong checkout, but is bounded to the Git installer path.
    • impact:other: An explicit installer destination can be silently replaced by the caller checkout.
    • maturity:stable: The documented installer contract is primarily owned by the M4 Stable CLI Setup surface.
    Evidence reviewed

    What I checked:

    • Current source defect: Current main initializes the target from OPENCLAW_GIT_DIR and allows --git-dir to replace it, but then replaces that target whenever checkout detection succeeds. (scripts/install.sh:3777, 837b89a0e75c)
    • Documented target contract: The installer reference describes both --git-dir and OPENCLAW_GIT_DIR as checkout-directory selectors, and environment docs state explicit path variables retain precedence. Public docs: docs/install/installer.md. (docs/install/installer.md:156, 837b89a0e75c)
    • Coverage gap: Current main-flow installer tests stub checkout detection as absent, so they do not cover an explicit target while another checkout is detected. (test/scripts/install-sh.test.ts:1637, 837b89a0e75c)
    • History provenance: Blame attributes the current target-replacement block to the commit that introduced the present scripts/install.sh path. (scripts/install.sh:3777, 6f4b9a28cf2e)
    • Open canonical repair: The supplied GitHub timeline links an open same-repository PR that formally closes this issue and includes after-fix target-selection proof; it has not merged. (a39513c31b47)
    • Stable owner classification: The maturity helper identifies CLI Setup as an M4 Stable surface, matching this documented installer contract. (qa/maturity-scores.yaml, 837b89a0e75c)

    Likely related people:

    • zengLingbiao: Current-path history attributes the installer block to this commit. (role: current-path introducer; confidence: high; commits: 6f4b9a28cf2e; files: scripts/install.sh)
    • steipete: Reported the precise precedence failure and is a co-author on the commit introducing the current script path. (role: reporter and current-path co-author; confidence: medium; commits: 6f4b9a28cf2e; files: scripts/install.sh)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  4. added
    issue-rating: 🦀 challenger crab
    clawsweeper:current-main-repro
    clawsweeper:source-repro
    issue-rating: 🦞 diamond lobster
    clawsweeper:linked-pr-open
    clawsweeper:no-new-fix-pr
    and removed
    clawsweeper:source-repro
    issue-rating: 🦞 diamond lobster
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    clawsweeper:current-main-repro
    issue-rating: 🦀 challenger crab
    on Aug 23, 2026
  5. steipete commented on Aug 25, 2026

    @steipete
    ContributorAuthor

    Fixed in #128407 (6831959): the standalone installer now honors explicit --git-dir/--dir and OPENCLAW_GIT_DIR, selecting the requested checkout B instead of mutating detected checkout A. Real before-and-after installer runs confirm both CLI and environment-variable selection leave A untouched and correctly build/report B; all 218 installer tests pass.

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

    P2bugclawsweeper:linked-pr-openclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:otherissue-rating: 🦞 diamond lobstermaintainermaturity:stable

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions