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

[Windows] ChildProcess::LaunchError: The system cannot find the file specified. #85

Closed
jawshooah opened this issue Apr 17, 2015 · 1 comment

Comments

@jawshooah
Copy link

When attempting to run a simple echo Hello World command through ChildProcess, somehow the system can't find the echo command, but the Kernel backtick method has no problems:

C:\Users\vagrant>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require 'childprocess'
=> true
irb(main):002:0> `echo Hello World`
=> "Hello World\n"
irb(main):003:0> process = ChildProcess.build('echo', 'Hello', 'World')
=> #<ChildProcess::Windows::Process:0x00000002b761d0 @args=["echo", "Hello", "World"], @started=false, @exit_code=nil, @io=nil, @cwd=nil, @detach=false, @duplex=false, @leader=f
irb(main):004:0> process.start
ChildProcess::LaunchError: The system cannot find the file specified. (2)
        from C:/tools/ruby215/lib/ruby/gems/2.1.0/gems/childprocess-0.5.6/lib/childprocess/windows/process_builder.rb:87:in `create_process'
        from C:/tools/ruby215/lib/ruby/gems/2.1.0/gems/childprocess-0.5.6/lib/childprocess/windows/process_builder.rb:34:in `start'
        from C:/tools/ruby215/lib/ruby/gems/2.1.0/gems/childprocess-0.5.6/lib/childprocess/windows/process.rb:68:in `launch_process'
        from C:/tools/ruby215/lib/ruby/gems/2.1.0/gems/childprocess-0.5.6/lib/childprocess/abstract_process.rb:82:in `start'
        from (irb):5
        from C:/tools/ruby215/bin/irb:11:in `<main>'
@jarib
Copy link
Collaborator

jarib commented Apr 17, 2015

ChildProcess doesn't execute your command in a shell like the backtick method does. If that's what you want you should be explicit:

process = ChildProcess.build("cmd.exe", "/c", "echo 'Hello World'")

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

2 participants