cwd option in child_process.spawn

467 views
Skip to first unread message

Rajasekhar Chinnam

unread,
Nov 19, 2014, 3:01:07 PM11/19/14
to nod...@googlegroups.com
hello

I am running node on Windows. The 'cwd' option of the child_process.spawn method is ignored after upgrading to node to '0.10.29'.

Any pointers to resolve this will be appreciated. 


Code:
var process_name = "test.bat";
var working_dir = "D:\\tmp\\tmp";
var arguments = ""'

var launcher = child_process.spawn(process_name, arguments, { cwd: working_dir, env: process.env });

thank you
Raja

Rajasekhar Chinnam

unread,
Nov 19, 2014, 6:13:46 PM11/19/14
to nod...@googlegroups.com
Found the issue:

Now 'arguments' should be array not string. 
Node should have given a better error message rather than just ignoring the cwd parameter.


Sam Roberts

unread,
Nov 20, 2014, 7:28:05 AM11/20/14
to nod...@googlegroups.com
On Wed, Nov 19, 2014 at 12:01 PM, Rajasekhar Chinnam
<rajasekha...@gmail.com> wrote:
> I am running node on Windows. The 'cwd' option of the child_process.spawn
> method is ignored after upgrading to node to '0.10.29'.

Do you have a complete reproduction?

Because I don't think you can spawn test.bat on windows (you can
exec() it, but that's because with exec test.bat is passed to the
cmd.exe shell, which knows how to run bat files).

Sam Roberts

unread,
Nov 20, 2014, 1:21:36 PM11/20/14
to nod...@googlegroups.com
On Wed, Nov 19, 2014 at 3:13 PM, Rajasekhar Chinnam
<rajasekha...@gmail.com> wrote:
> Found the issue:
>
> Now 'arguments' should be array not string.

1. arguments hasn't been a string EVER in 0.10, can't speak to before
2. if arguments is NOT an array in position args[1], it was assumed
you had not passed the optional arguments array (because... you did
not pass an arguments arrary), so it was assuming the string was the
options object
3. you would have got an error thrown if you were on an up to date
node version, 0.10 or 0.11

Why did you update to .29, not the latest stable?
Reply all
Reply to author
Forward
0 new messages