Andrei Botalov Andrei Botalov -4 years ago 139
Ruby Question

"The system cannot find the file specified" when starting process using ChildProcess

When I run the following code:

require 'childprocess'

process = ChildProcess.build("cucumber")
process.start


(It seem that any other gem can be instead cucumber)

I get error:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.3/lib/childprocess/windows/process_builder.rb:87:in `create_process': The system cannot
find the file specified. (2) (ChildProcess::LaunchError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.3/lib/childprocess/windows/process_builder.rb:34:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.3/lib/childprocess/windows/process.rb:63:in `launch_process'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.3/lib/childprocess/abstract_process.rb:67:in `start'
from env.rb:4:in `<main>'


When I run it in Windows cmd using e.g.
cucumber
, process starts normally.

How can I solve it? Why it occurs?

Answer Source

Have same trouble a few days ago. You can point ChildProcess to cucumber.bat file:

require 'childprocess'

process = ChildProcess.build("C:\\Ruby193\\bin\\cucumber.bat")
process.start
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download