Skip to content

fix: provide clear error when cwd directory does not exist#1407

Open
apoorvdarshan wants to merge 2 commits intogoogle:mainfrom
apoorvdarshan:fix/cwd-validation-error
Open

fix: provide clear error when cwd directory does not exist#1407
apoorvdarshan wants to merge 2 commits intogoogle:mainfrom
apoorvdarshan:fix/cwd-validation-error

Conversation

@apoorvdarshan
Copy link

Summary

  • Adds an explicit fs.existsSync(cwd) check in ProcessPromise.run() before spawning the child process
  • When a nonexistent directory is passed as cwd, it now throws a clear error: The working directory '/path' does not exist. instead of a confusing ENOENT or a hanging promise (on Deno)
  • Adds a dedicated test for the new error message

Fixes #1386

Test plan

  • Existing test updated to match the new error message
  • New test added: provides clear error when cwd does not exist
  • All 133 core tests pass
  • Size limits updated to accommodate the added validation

When a nonexistent directory is passed as cwd option, the spawn call
would fail with a confusing ENOENT error (or worse, a hanging promise
on Deno). This adds an explicit check before spawning to validate the
cwd exists and provides a clear, actionable error message.

Fixes google#1386
@apoorvdarshan apoorvdarshan force-pushed the fix/cwd-validation-error branch from fc8078c to 8493fe3 Compare February 16, 2026 08:25
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.

[Bug]: Confusing error when cwd directory doesn't exist

1 participant