Projects not finding Git

Anyone had success using Projects in node-red run on Azure App Service? I'm getting the error below despite being able to run both "git" and "ssh-keygen" from the command line.

"Projects disabled : git command not found"

Node-red v0.19.5
Node.js v8.11.1

Is git available in the Azure App Service?

Yep. It's mainly used for managing application code but uses a standard git command line tool.

Maybe it isn't on the path when you have started Node-RED? How are you starting it?

It runs on Express so maybe that is the problem.

server.js:

var express = require("express");
var RED = require('node-red');
var app = express();
var http = require('http');

var PORT=process.env.PORT;

var server=http.createServer(app);
var settings=require("./settings.js");

RED.init(server,settings);

app.use(settings.httpAdminRoot,RED.httpAdmin);
app.use(settings.httpNodeRoot,RED.httpNode);
 
server.listen(settings.uiPort);
console.log(`listening port:${settings.uiPort}`);
RED.start();

I don't believe so. That is just running Node-RED in embedded mode. I believe it will be how the app is started. It will have been started without a PATH and therefore inside the context of Node.JS, ExpressJS and Node-RED, git cannot be found.

Thanks for the pointer Julian. Turns out that there appears to be a bug in Azure in that the PATH variable used by the IIS Application Pool is pointing to a 32 bit directory for Git when in fact the 64 bit version is installed.

I have worked around this by manually adding the required directory to the path in the server.js file:

var express = require('express'),
    RED = require('node-red'),
    http = require('http'),
    settings = require('./settings.js');

var app = express(),
    server = http.createServer(app);

process.env.Path =  'D:\\Program Files\\Git\\cmd;D:\\Program Files\\Git\\usr\\bin;' + process.env.Path;

RED.init(server,settings);

app.use(settings.httpAdminRoot,RED.httpAdmin);
app.use(settings.httpNodeRoot,RED.httpNode);
 
server.listen(settings.uiPort);
console.log(`listening port:${settings.uiPort}`);
RED.start();
1 Like

Great, glad that got sorted.

By the way, you can avoid all those backslashes and errors by using path.join which always gives valid paths for the target OS. It tends to be a lot safer than using manual path strings.

1 Like