Skip to content

Dev runner outside a worktree forwards T3CODE_HOME=~/.t3, pointing the dev server at the live userdata #38805

Closed

Description

@Lenoridev

Problem

Outside a linked git worktree (the main checkout or any plain git clone), vp run dev forwards an ambient T3CODE_HOME to the server. The server treats any T3CODE_HOME as an explicit home and stores state in <home>/userdata instead of <home>/dev (apps/server/src/config.ts:149, apps/server/src/cli/config.ts:334-346).

The T3 Code boot service sets T3CODE_HOME to the install's home (apps/server/src/cloud/bootService.ts:116), and agent shells inherit it. So an agent that runs vp run dev in a plain clone gets T3CODE_HOME=~/.t3, and the dev server targets the live ~/.t3/userdata. The same happens with vp run dev --home-dir ~/.t3. Today the only thing stopping it is the ownership lock (apps/server/src/serverOwnership.ts), which refuses to start while the live server holds ~/.t3/userdata. If the live server is not running, the dev server opens the live database.

The selection is in scripts/dev-runner.ts:779-783 and createDevRunnerEnv. The test falls back to an ambient T3CODE_HOME outside a worktree (scripts/dev-runner.test.ts:968) pins the forwarding.

Without T3CODE_HOME, a plain clone uses ~/.t3 as an implicit home, and its state goes to ~/.t3/dev. A dry run from a fresh clone prints source=default ports ... baseDir=/home/<user>/.t3. That part is intended, but it is only documented for "the main checkout":

  • Every non-worktree checkout shares ~/.t3/dev (database, settings, secrets) and the default ports. Only one of their servers can run at a time, because the ownership lock is per state directory.
  • AGENTS.md describes only the worktree default.
  • The first-run seed only targets a worktree's own .t3 (scripts/dev-runner.ts:904). A plain clone, or a --home-dir outside the worktree, starts with an empty database. This is a sensible guard, since migrate-dev-db writes <base>/userdata. The docs do not mention it or the manual alternative, vp run migrate-dev-db --base-dir <clone>/.t3.

Expected

  • A dev home that resolves to ~/.t3 (from --home-dir or an ambient T3CODE_HOME) never reaches the server as an explicit home, so dev state lands in ~/.t3/dev.
  • The docs say what a plain clone gets and how to isolate and seed one.

Not covered: a live install with a non-default home (for example T3CODE_HOME=/data/t3 from the boot service) is still forwarded as explicit. Detecting that needs the boot service unit and is left for a follow-up if wanted.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions