1

当我运行以下代码时:

require 'childprocess'

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

(似乎任何其他宝石都可以代替黄瓜)

我得到错误:

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>'

当我在 Windows cmd 中使用 eg 运行它时cucumber,进程正常启动。

我该如何解决?为什么会发生?

4

1 回答 1

1

前几天也有同样的烦恼。您可以将 ChildProcess 指向 cucumber.bat 文件:

require 'childprocess'

process = ChildProcess.build("C:\\Ruby193\\bin\\cucumber.bat")
process.start
于 2012-08-08T12:27:25.767 回答