Skip to content

[Bug]: plugin temp-dir tests fail on any host where /tmp/openclaw is preferable (env-coupled os.tmpdir assertions) #101876

Description

@steipete

What happened?

Three plugin test cases fail on any POSIX machine where /tmp/openclaw exists or can be created with safe ownership (developer laptops after any OpenClaw run, warm CI boxes, remote test hosts):

  • src/plugins/git-install.test.ts > installPluginFromGitSpec > falls back to OS temp when target workspace creation fails
  • src/plugins/manifest-model-id-normalization.test.ts > manifest model id normalization > reuses manifest metadata while file fingerprints are unchanged
  • src/plugins/tools.optional.test.ts > resolvePluginTools optional tools > reloads when gateway binding would otherwise reuse a default-mode active registry

Example failure:

AssertionError: expected '/tmp/openclaw' to be '/tmp' // Object.is equality
  at src/plugins/git-install.test.ts:571 — expect(path.dirname(fallbackPrefix)).toBe(await fs.realpath(os.tmpdir()))

Mechanism

withTempDir (src/infra/install-source-utils.ts) defaults its root to resolvePreferredOpenClawTmpDir() (src/infra/tmp-openclaw-dir.ts), which on POSIX prefers — and creates on demand — POSIX_OPENCLAW_TMP_DIR = "/tmp/openclaw" whenever ownership/permissions are safe, falling back to os.tmpdir() only when that is unsafe. The tests assert the fallback lands under os.tmpdir(), which only holds in environments where /tmp/openclaw resolves unsafe (e.g. CI uid mismatch). The assertions encode the environment, not the contract.

Reproduction

node scripts/run-vitest.mjs src/plugins/git-install.test.ts on macOS or Linux as a user that can own /tmp/openclaw → 3 failures. Verified 2026-07-07 on macOS (worktree of 6683a86) and a clean Linux box (both with /tmp/openclaw absent-then-created and pre-existing): 3 failed / 95 passed each time. All three test files and their prod modules are byte-identical to origin/main (last touched by #99896).

Expected

Tests should pin the temp-root resolution (inject resolvePreferredOpenClawTmpDirOptions / the resolver dep, or assert against resolvePreferredOpenClawTmpDir() instead of os.tmpdir()) so they pass regardless of host /tmp/openclaw state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PR

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions