Skip to content

Conversation

@poetryofcode
Copy link

fix: throw clear error when cwd directory does not exist

Summary

  • Adds early validation for the cwd option before executing commands
  • Throws a clear Fail error if the directory doesn't exist or isn't a
    directory
  • Improves DX by providing actionable error messages instead of cryptic
    spawn errors

Before: Users got cryptic errors like "Top-level await promise never
resolved"
After: Users get clear messages like The cwd directory does not exist: /path/to/dir

Test plan

  • Added test for non-existent cwd directory
  • Added test for cwd pointing to a file instead of directory
  • Verified existing functionality still works
  • Updated size limits to accommodate the ~320 byte increase

Fixes #1386

When using a non-existent cwd directory, zx now throws a descriptive
error message instead of failing with a cryptic spawn error. This makes
debugging easier by immediately telling users what's wrong.

Fixes google#1386

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@google-cla
Copy link

google-cla bot commented Jan 28, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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