Issue 1167: Gerrit CGI wont execute on windows
Status:  Accepted
Owner: ----
Reported by lhud...@cdp.com, Nov 4, 2011
Affected Version: 2.2.1

What steps will reproduce the problem?
1. Setup Gerrit on windows
2. Configure Gitweb
3. Try to view a project in gitweb

What is the expected output? What do you see instead?
Should see the gitweb project view.

Instead I get Error 500
Problem accessing /gitweb. Reason:

    Cannot run program "d:\Gitweb\gitweb.pl" (in directory "D:\Gerrit\git\Test.git"): CreateProcess error=193, %1 is not a valid Win32 application

Please provide any additional information below.

From what I can tell the perl script is being called by Runtime.getRuntime().exec(new String[] {gitwebCgi.getAbsolutePath()},
            makeEnv(req, project), repo.getDirectory());

at https://code.google.com/p/gerrit/source/browse/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitWebServlet.java#421

From my research this is incompatible with running scripts on windows. It can only be used to run exe's on windows. (someone correct me if I'm wrong)

I have activestate perl 5.10 installed and I can run the perl script from the command line. I also have changed the shebang line to point to perl.

I believe the only solution is to detect windows in gerrit and append the perl command to the beginning. Or allow an administrator to do that with the conf. You can't right now cause its a datatype file. It would have to be a string and the admin would need to specify the full command.


Nov 4, 2011
#1 sop@google.com
Ah Windows. :-)

Is it possible to work around this by making a bat script that runs perl gitweb.pl and pointing the configuration to the bat script? A *.bat is executable on Windows. Its not a perfect solution, but it may be a reasonable workaround until the Gerrit server code can be modified as you suggest to detect Windows and invoke Perl instead of gitweb.pl.
Status: Accepted
Nov 4, 2011
#2 lhud...@cdp.com
The bat file works. Separate problem, gitweb.cgi wont run on windows without modifications. 
List form of pipe open not implemented

So, (very) low priority on this.
Nov 4, 2011
#3 lhud...@cdp.com
For those interested this is my batch file

@c:\Perl\bin\perl.exe D:\Gitweb\gitweb.pl
Nov 4, 2011
#4 lhud...@cdp.com
Ok, after lots of pain it is possible to do it with msysgit's perl. You have to manually install CGI.pm.

I got CGI.pm from https://github.com/msysgit/msysgit/tree/msys/lib/perl5/5.8.8

and my updated batch script is

@"C:\Program files\git\bin\perl.exe" D:\Gitweb\gitweb.cgi
May 20, 2012
#5 larry.ca...@gmail.com
this should be report to msysgit "Git for windows" package to have CGI perl module and gitweb.bat for it as well