Skip to content

fix(plan): set PWD to the task's working directory - #1063

Open
konaito wants to merge 2 commits into
voidzero-dev:mainfrom
konaito:fix/pwd-task-cwd-1049
Open

konaito wants to merge 2 commits into
voidzero-dev:mainfrom
konaito:fix/pwd-task-cwd-1049

Conversation

@konaito

@konaito konaito commented Dec 4, 2026

Copy link
Copy Markdown

Motivation

Fixes #1049.

vp run starts a task in the task's directory, but the spawned process inherited the caller's PWD. With vp run -r, vp run pkg#task, a task's cwd option, or a cd in the command, PWD and the real working directory disagreed. Tools that compare the two complain: workerd prints PWD environment variable doesn't match current directory once per test file under @cloudflare/vitest-plugin when the tests run through vp run -r test.

Changes

  • plan_spawn_execution replaces an inherited PWD with the spawn's cwd, as a shell cd or pnpm -r exec does. It is applied before EnvFingerprints::resolve, so a task that lists PWD in cache.env fingerprints the value it sees, and before prefix envs, so PWD=/x cmd still wins.
  • PWD is only replaced, never added, so environments that don't set it (such as most Windows shells) are unchanged. PWD is a default untracked env, so cache keys don't change.
  • When vp run is called from a symlinked path in the task's own directory, PWD is now the directory vp run resolved (the physical path) rather than the caller's symlinked spelling.
  • New pwd_follows_task_cwd plan snapshot fixture: pkg#task from the workspace root, the cwd option, cd before the command, an uncached task, a prefix assignment, and a caller without PWD.
  • CHANGELOG entry.

konaito and others added 2 commits December 4, 2026 15:04
A task that `vp run` starts in another directory (`-r`, `pkg#task`, the
`cwd` option, or a `cd` in its command) inherited the caller's `PWD`, so
`PWD` and the real working directory disagreed. Replace an inherited
`PWD` with the spawn's cwd, as a shell `cd` does.

Fixes voidzero-dev#1049

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vp run leaves PWD at the caller's directory when it runs a task in another directory

1 participant