tags:

views:

111

answers:

2

Hi,

I am a developer on the horn OSS project that sets out to ease the pain of building other OSS projects. We are attempting to make horn a ruby gems like experience. One of the many challenges of horn is having to deal with all the various build engines like Nant, powershell, msbuild and rake which is the point of this post.

Horn has 2 manifestations, it runs as a cmd line tool and it also runs as a windows service where it builds all the various packages which can be downloaded from this website.

Certain OSS projects use rake to build their source code which has eventually brought me to the point of this post.

I cannot get the rake process to run from the windows service while the exact same code can start the rake process without any issues when running from the command line. The reason that rake does run from the cmd line tool could be because it is associated with a window although I cannot rightly say. No exception is thrown but the process just does not start.

The funny thing is that every other .exe works fine and it is only rake that is causing the problem.

Here is the code to start that creates the process:

public IProcess GetProcess(string pathToBuildTool, string cmdLineArguments, string workingDirectoryPath)
{
    var psi = new ProcessStartInfo(pathToBuildTool, cmdLineArguments)
                  {
                      UseShellExecute = false,
                      RedirectStandardOutput = true,
                      WorkingDirectory = workingDirectoryPath,
                      Arguments = cmdLineArguments
                  };

    return new DiagnosticsProcess(Process.Start(psi));
}

Does anyone have any suggestions as to what the problem is?

Cheers

Paul

A: 

Apparently, Rake on Windows should be invoked through the supplied batch file (typically c:\ruby\bin\rake.bat), instead of running the .EXE directly. See Instant Badger: Rake gotcha on Windows for details.

If switching to using the supplied batch file doesn't fix the problem, please let me know & I'll d/l the horn source and take a closer look.

Duncan Bayne
No cigar buddy but thanks for the answer.If you are looking at the source, it is in the horn.services.sln and the install_package_service.bat will install it. I have the debugger set to fire open at the appropriate place when it is started.
dagda1
+2  A: 

I compiled and investigated a bit myself.

On my machine, the Horn service actually starts a Ruby process to run Rake, but the process exits immediately with an error. I used Process Monitor to monitor process creation while filtering for the path containing "ruby". The end result is that Horn was not able to build with the Rakefile.

After some more investigation I was playing a bit with how Horn creates build processes. I found that the build actually runs on my machine when I do not only redirect StandardOutput but also StandardError.

public IProcess GetProcess(string pathToBuildTool, string cmdLineArguments, string workingDirectoryPath)
{
    var psi = new ProcessStartInfo(pathToBuildTool, cmdLineArguments)
                  {
                      UseShellExecute = false,
                      RedirectStandardOutput = true,
                      RedirectStandardError = true,
                      WorkingDirectory = workingDirectoryPath,
                      Arguments = cmdLineArguments
                  };

    return new DiagnosticsProcess(Process.Start(psi));
}

I also changed DiagnosticProcess to output both messages from StandardOutput and StandardError:

public string GetLineOrOutput()
{
    return process.StandardOutput.ReadLine() ?? process.StandardError.ReadLine();
}

The net result is the following line being the last message in the Horn service log:

HORN HAS FINISHED INSTALLING mspec.
Alexander Groß