Tuesday, April 5, 2011

How to run Ruby CGI scripts in Windows 7 with XAMPP

I use Ubuntu to develop my apps, but sometimes I need to run scripts in windows.

In a computer with Windows 7, I've installed Ruby and XAMPP. It runs PHP script very well, but when I tried to run a Ruby CGI script, I got the error:

Couldn't create child process: 720002

It's due to the "shebang" first line of the script:

#!/usr/bin/ruby

In my local installation, ruby is in:

C:\ruby\bin\ruby.exe

That's not much different from the linux path. I solved the problem by creating a symbolic link usr pointing to ruby at root directory. To do that, run cmd as Administrator and type:

c:
cd \
mklink /D usr ruby

That was enough to run my scripts. :)

2 comments:

  1. Thanks, hoped it would work! Alas, didn't. (even after rebooting, usually the universal medicine for windoz)

    I got things to work by using this shebang
    #!"C:\Ruby192\bin\ruby.exe"

    for noobs that drop by, this means having to change the shebang line when uploading code to *nix servers

    ReplyDelete
  2. Thanks! I'm starting on ruby now, and was searching a solution for this. Actually, what worked for me was the solution given by Mr. Ploskonka, but your post explained what was causing the problem =)

    ReplyDelete