Skip to content

Bare npx vitest run writes test fixtures into the real ~/.codeman #640

Closed

Description

@opticon454

Bug

A bare npx vitest run writes test fixtures into the developer's real ~/.codeman.

On a machine that runs Codeman this left a clis.json with a test entry, a fixture users.json, webhook.json, intents.json, .env, settings.json values and a .secret-fixture file. The running instance loads them on its next restart, which looks exactly like "my settings were reset".

Steps to reproduce

  1. On a machine with a real ~/.codeman, run npx vitest run from the repo root (instead of npm test).
  2. Inspect ~/.codeman: fixture files and values have been written there.

Cause

There is no root vitest config: the configs live in config/ and npm test passes --config. A bare invocation has no setupFiles, so test/setup.ts never runs and HOME is not redirected.

Related: on a machine with a real agent CLI installed, the temp-HOME teardown can fail a passing file with ENOTEMPTY (about 1 run in 3 for session-routes-claude-model), because claude keeps flushing ~/.claude.json and ~/.claude/backups/ into the temp HOME after the test ends.

Status

Fixed, with tests, on branch fix/test-home-isolation in my fork. Not submitted as a PR yet: I'm at the open-PR limit and the fix is queued behind my current open PRs (#567, #592, #616, #617, #618). I'll open the PR as soon as a slot frees, or sooner if you'd like to lift the limit or take it directly from the branch.

Activity

  1. Ark0N commented on Oct 18, 2026

    @Ark0N
    Owner

    Thanks @opticon454, this is a real bug and a nasty one, since it looks exactly like "my settings were reset". npm test passes --config config/vitest.ci.config.ts, so its setupFiles redirect HOME, but a bare npx vitest run finds no config at all and runs against the real ~/.codeman. CLAUDE.md warns about it, which does not help anyone who has not read that line.

    I had a look at fix/test-home-isolation and the shape is right, so yes, please open it as a PR. Two things the review will look at, so you can get ahead of them:

    • The root vitest.config.ts. The repo root is kept short on purpose (CLAUDE.md, the note at the top) and config lives in config/, but the rule allows files a tool only looks for at the root, and a bare vitest only looks there, so I think it qualifies. Please add it to that list of root-only files in CLAUDE.md in the same PR, with the reason, so nobody "tidies" it back into config/.
    • The temp-HOME teardown retry. The ENOTEMPTY from a real claude flushing into the temp HOME after a test ends is a good catch. The retry has to stay bounded, and it must never retry or delete outside the temp HOME; safeRmHomeTree() is the guard the tests use for that, and test/test-env-isolation.test.ts pins the setup side.

    About the open-PR limit: drafts do not count toward it, so you can open this as a draft now and mark it ready once a slot frees. Several of your open PRs are reviewed and should go in with the next release, which frees slots too.

  2. Ark0N commented on Oct 18, 2026

    @Ark0N
    Owner

    @opticon454 quick follow-up: I added you to the repository's exemption from the open-PR limit, so you can open #640's and #641's fixes as normal PRs now, no draft needed. It exempts you from the cap only. Thanks for queueing them so patiently.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions