Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The invalid cwd path is not reported correctly. #51054

Open
JacksonTian opened this issue Dec 5, 2023 · 2 comments
Open

The invalid cwd path is not reported correctly. #51054

JacksonTian opened this issue Dec 5, 2023 · 2 comments

Comments

@JacksonTian
Copy link
Contributor

Version

v18.19.0

Platform

Darwin local.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

Subsystem

child_process

What steps will reproduce the bug?

const { spawn } = require('child_process');

spawn('echo hello', {
    cwd: '/invalid_path'
});

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

Report the cwd path is invalid.

What do you see instead?

$ node test.js 
node:events:495
      throw er; // Unhandled 'error' event
      ^

Error: spawn echo hello ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:284:19)
    at onErrorNT (node:internal/child_process:477:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:290:12)
    at onErrorNT (node:internal/child_process:477:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn echo hello',
  path: 'echo hello',
  spawnargs: []
}

Node.js v18.19.0

The error message make me confuse.

Additional information

No response

@richardlau
Copy link
Member

Duplicate of #45279 and may be unfixable, see #45279 (comment).

@pluris
Copy link
Contributor

pluris commented Dec 5, 2023

IMO, how about adding the typed cwd to the error message?
cwd: '/invalid_path'

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

No branches or pull requests

3 participants