mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
Starting `pi` from a directory that has been deleted crashed with an uncaught Node `ENOENT ... uv_cwd` stack trace. This also happened for `--version` and `--help`. The cause is the unguarded `process.cwd()` call in `main()` (`packages/coding-agent/src/main.ts`). `main()` now catches `ENOENT` from that call, prints one line telling the user to change to an existing directory, and exits with code 1. Other errors are rethrown unchanged. Argument handling is otherwise unchanged: `--version` still needs a valid cwd, but it now gets the readable error instead of a crash. **Testing** - Added `test/deleted-cwd.test.ts`. It stubs `process.cwd()` to throw ENOENT and checks that `main()` prints the message and exits with code 1. It also checks that a non-ENOENT error is rethrown. The first test fails without the change and passes with it. - `npm run check` passes. - Manual check with the built CLI. Before, all three commands below printed the `uv_cwd` stack trace. After, each prints `Error: The current working directory no longer exists. Change to an existing directory and try again.` and exits 1: ```sh d=$(mktemp -d); cd "$d"; rmdir "$d" pi -ne --version; pi -ne --help; pi -ne ``` Fixes #11509 Requested by @badlogic Co-authored-by: triagent <triagent@localhost> |
||
|---|---|---|
| .. | ||
| bun | ||
| cli | ||
| core | ||
| experimental | ||
| extensions | ||
| modes | ||
| utils | ||
| cli.ts | ||
| config.ts | ||
| index.ts | ||
| main.ts | ||
| migrations.ts | ||
| package-manager-cli.ts | ||
| rpc-entry.ts | ||