Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

- **Fixed** A task that `vp run` starts in another directory, as with `vp run -r`, `vp run pkg#task`, a task's `cwd` option, or a `cd` in its command, now sees `PWD` set to that directory instead of the one `vp run` was called from, so tools that check `PWD` against the working directory, such as workerd, no longer warn ([#1049](https://github.com/voidzero-dev/vite-task/issues/1049), [#1063](https://github.com/voidzero-dev/vite-task/pull/1063)).
- **Changed** When automatic file-access tracking cannot record everything a task did, the "Not cached" summary line now includes the specific reason (for example, that the tracking channel ran out of capacity or that installing the seccomp filter failed for a given executable) ([#1054](https://github.com/voidzero-dev/vite-task/pull/1054), [#1056](https://github.com/voidzero-dev/vite-task/pull/1056)).
- **Changed** Invalid remote cache endpoint URLs in `cache.remote.url` or `VP_REMOTE_CACHE_URL` (such as missing schemes, non-`http`/`https` schemes, or missing hosts) now fail upfront during configuration and planning instead of warning per task during execution, and `vp run --help` now documents `VP_REMOTE_CACHE`, `VP_REMOTE_CACHE_URL`, and `VP_REMOTE_CACHE_HEADER_<NAME>` ([#1048](https://github.com/voidzero-dev/vite-task/pull/1048)).
- **Changed** Removed `NEXT_*`, `VERCEL`, `VERCEL_*`, `USE_OUTPUT_FOR_EDGE_FUNCTIONS`, `NOW_BUILDER`, `VC_MICROFRONTENDS_CONFIG_FILE_NAME`, `GITHUB_*`, `ACTIONS_ID_TOKEN_REQUEST_URL`, `DOCKER_*`, `BUILDKIT_*`, `COMPOSE_*`, and `*_TOKEN` from the default untracked environment variables passed to cached tasks. Tasks that need any of these variables should declare them explicitly in `cache.env` or `cache.untrackedEnv` ([#1044](https://github.com/voidzero-dev/vite-task/pull/1044)).
Expand Down
12 changes: 12 additions & 0 deletions crates/vt_plan/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,18 @@ fn plan_spawn_execution(
let mut spawn_envs = (**envs).clone();
let cwd = Arc::clone(&resolved_task_options.cwd);

// Keep `PWD` in line with the directory the task runs in, as a shell
// `cd` would. Otherwise a task run from another directory (`-r`,
// `pkg#task`, the `cwd` option, or a `cd` in its command) inherits the
// caller's `PWD`, and tools that check it against the real working
// directory complain. Only an inherited `PWD` is replaced, so none is
// added where the caller had none. Set before `EnvFingerprints::resolve`
// so a task that lists `PWD` in `env` fingerprints the value it sees. A
// prefix assignment (`PWD=… command`) still wins: those are applied last.
if let Some(pwd) = spawn_envs.get_mut(EnvName::from_ref(OsStr::new("PWD"))) {
*pwd = Arc::from(cwd.as_path().as_os_str());
}

let mut resolved_cache_metadata = None;
if let Some(cache_config) = &resolved_task_options.cache_config {
// Resolve envs according cache configs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "pwd-follows-task-cwd",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "a"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"tasks": {
"where": {
"command": "vtt print-env PWD"
},
"where-sub": {
"command": "vtt print-env PWD",
"cwd": "sub"
},
"where-cd": {
"command": "cd sub && vtt print-env PWD"
},
"where-uncached": {
"command": "vtt print-env PWD",
"cache": false
},
"where-prefix": {
"command": "PWD=/custom vtt print-env PWD"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- packages/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Tests that a spawned task sees `PWD` set to the directory it runs in, not
# the directory `vt run` was called from (as after a shell `cd`).

[fields]
key = true

[fields.spawn_command]
cwd = true

[fields.spawn_command.spawn_envs]
PWD = true

[[plan]]
name = "package_task_from_workspace_root"
args = ["run", "a#where"]
env = { PWD = "/caller" }

[[plan]]
name = "task_cwd_option"
args = ["run", "where-sub"]
cwd = "packages/a"
env = { PWD = "/caller" }

[[plan]]
name = "cd_before_command"
args = ["run", "a#where-cd"]
env = { PWD = "/caller" }

[[plan]]
name = "uncached_task"
args = ["run", "a#where-uncached"]
env = { PWD = "/caller" }

[[plan]]
name = "prefix_assignment_wins"
args = ["run", "a#where-prefix"]
env = { PWD = "/caller" }

[[plan]]
name = "pwd_not_added_when_caller_has_none"
args = ["run", "a#where"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// run a#where-cd
{
"graph": [
{
"key": [
"<workspace>/packages/a",
"where-cd"
],
"node": {
"items": [
{
"kind": {
"Leaf": {
"Spawn": {
"spawn_command": {
"spawn_envs": {
"PWD": "<workspace>/packages/a/sub"
},
"cwd": "<workspace>/packages/a/sub"
}
}
}
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// run a#where
{
"graph": [
{
"key": [
"<workspace>/packages/a",
"where"
],
"node": {
"items": [
{
"kind": {
"Leaf": {
"Spawn": {
"spawn_command": {
"spawn_envs": {
"PWD": "<workspace>/packages/a"
},
"cwd": "<workspace>/packages/a"
}
}
}
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// run a#where-prefix
{
"graph": [
{
"key": [
"<workspace>/packages/a",
"where-prefix"
],
"node": {
"items": [
{
"kind": {
"Leaf": {
"Spawn": {
"spawn_command": {
"spawn_envs": {
"PWD": "/custom"
},
"cwd": "<workspace>/packages/a"
}
}
}
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// run a#where
{
"graph": [
{
"key": [
"<workspace>/packages/a",
"where"
],
"node": {
"items": [
{
"kind": {
"Leaf": {
"Spawn": {
"spawn_command": {
"spawn_envs": {},
"cwd": "<workspace>/packages/a"
}
}
}
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// run where-sub
{
"graph": [
{
"key": [
"<workspace>/packages/a",
"where-sub"
],
"node": {
"items": [
{
"kind": {
"Leaf": {
"Spawn": {
"spawn_command": {
"spawn_envs": {
"PWD": "<workspace>/packages/a/sub"
},
"cwd": "<workspace>/packages/a/sub"
}
}
}
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// run a#where-uncached
{
"graph": [
{
"key": [
"<workspace>/packages/a",
"where-uncached"
],
"node": {
"items": [
{
"kind": {
"Leaf": {
"Spawn": {
"spawn_command": {
"spawn_envs": {
"PWD": "<workspace>/packages/a"
},
"cwd": "<workspace>/packages/a"
}
}
}
}
}
]
}
}
]
}
Loading