Skip to content

Check cwd before spawning child process #11520

Description

@jhnns
  • Version: v7.6.0
  • Platform: Darwin Pecorino.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

When a cwd is passed to child_process.spawn() that does not exist, node just reports ENOENT:

constspawn=require("child_process").spawnspawn(process.execPath,{cwd: "/does/not/exist"});
> Error: spawn /usr/local/bin/node ENOENT
at exports._errnoException (util.js:1028:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

This error message is very confusing because it reads like /usr/local/bin/node does not exist. It took me several hours to debug this issue, including serious doubts in my sanity 😁.

Do you think it is feasible to check the cwd before spawning the process, or is there a use-case/is it possible to spawn a process with a non-existent cwd? If it's not feasible, would it be an option to include the cwd in the error message to give a slight hint in the right direction?

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.feature requestIssues that request new features to be added to Node.js.libuvIssues and PRs related to the libuv dependency or the uv binding.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions