diff --git a/node_modules/vfs-child/parent.js b/node_modules/vfs-child/parent.js index 733570c6..e47c0838 100644 --- a/node_modules/vfs-child/parent.js +++ b/node_modules/vfs-child/parent.js @@ -17,17 +17,32 @@ function Parent(fsOptions) { } options.stdio = options.customFds = [-1, -1, 2]; var args = [require.resolve('./child.js'), JSON.stringify(fsOptions)]; - var executablePath = process.execPath; + var nodeBin = fsOptions.nodeBin || [process.execPath]; var child; // Override Consumer's connect since the transport logic is internal to this module this.connect = connect.bind(this); function connect(callback) { - child = spawn(executablePath, args, options); + child = spawn(nodeBin[0], args, options); child.stdin.readable = true; - Consumer.prototype.connect.call(this, [child.stdout, child.stdin], callback); - child.stdin.resume(); + Consumer.prototype.connect.call(this, [child.stdout, child.stdin], tryNext); child.on("exit", disconnect); + child.on("error", tryNext); + child.stdin.resume(); + var _self = this; + // try all possible locations of node before giving up + function tryNext(err, vfs) { + if (!child) return; + child.removeListener("error", tryNext); + if (err && err.code == "ENOENT" && nodeBin.length > 1) { + child = null; + nodeBin.shift(); + _self.emit("error", err); + _self.connect(callback); + } else { + callback(err, vfs); + } + } } // Override Consumer's disconnect to kill the child process afterwards diff --git a/node_modules/vfs-local/localfs.js b/node_modules/vfs-local/localfs.js index 6e106dad..ed83b41e 100644 --- a/node_modules/vfs-local/localfs.js +++ b/node_modules/vfs-local/localfs.js @@ -60,34 +60,28 @@ function logToFile(message){ }); } - +console.error(process.env.PATH) //////////////////////////////////////////////////////////////////////////////// module.exports = function setup(fsOptions) { var pty; if (!fsOptions.nopty) { - var e1; - try { - pty = require('pty.js'); - } catch(e) { - e1 = e; - + [fsOptions.homeDir + "/.c9/node_modules/pty.js", "pty.js", "pty.nw.js"].some(function(p) { try { - if (os.platform() == "darwin" && os.release() == "11.4.2") - throw new Error("Unsupported Platform " + os.platform() + " " + os.release()); - - pty = require('pty.nw.js'); - } catch(e2) { - console.warn("unable to initialize pty.js:"); - console.warn(e1, e2); - pty = function(){}; + pty = require(p); + return true; + } catch(e) { + console.warn(e, p); } - } + }); + if (!pty) + console.warn("unable to initialize pty.js:"); } - else { - pty = function(){ + if (!pty) { + pty = function(command, options, callback) { console.log("PTY is not supported."); }; + pty.spawn = pty; } var TMUX = fsOptions.tmuxBin || "tmux"; diff --git a/plugins/c9.vfs.extend/collab-server.js b/plugins/c9.vfs.extend/collab-server.js index 89ac7283..96da46a1 100644 --- a/plugins/c9.vfs.extend/collab-server.js +++ b/plugins/c9.vfs.extend/collab-server.js @@ -22,6 +22,8 @@ var dbFilePath; var cachedWS; var cachedUsers; +var Sequelize; + var debug = false; function getHomeDir() { @@ -39,18 +41,23 @@ function getProjectWD() { * npm: sqlite3 & sequelize */ function installServer(callback) { - function checkInstalled() { + function checkInstalled(root) { try { - require("sqlite3"); - require("sequelize"); + require(root + "sqlite3"); + Sequelize = require(root + "sequelize"); return true; } catch (err) { + console.error(err); return false; } } - if (!checkInstalled()) { - var err = new Error("[vfs-collab] Missing dependencies - NODE_PATH: " + process.env.NODE_PATH + "; node " + process.version); + if (!checkInstalled(getHomeDir() + "/.c9/node_modules/") && !checkInstalled("")) { + var err = new Error("[vfs-collab] Couldn't load node modules sqlite3 and sequelize " + + "from " + getHomeDir() + "/.c9/node_modules/; " + + "node version: " + process.version + "; " + + "node execPath " + process.execPath + ); err.code = "EFATAL"; return callback(err); } @@ -80,7 +87,6 @@ function wrapSeq(fun, next) { * @param {Function} callback */ function initDB(readonly, callback) { - var Sequelize = require("sequelize"); var MAX_LOG_LINE_LENGTH = 151; dbFilePath = dbFilePath || Path.join(getProjectWD(), "collab.db"); diff --git a/settings/standalone.js b/settings/standalone.js index eb413831..c6f00ca9 100644 --- a/settings/standalone.js +++ b/settings/standalone.js @@ -16,8 +16,8 @@ module.exports = function(manifest, installPath) { if (win32 && process.env.HOME === undefined) { process.env.HOME = process.env.HOMEDRIVE + process.env.HOMEPATH; - if (!/msys\/bin|Git\/bin/.test(process.PATH)) - process.PATH = path.join(process.env.HOME, ".c9", "msys/bin") + ";" + process.PATH; + if (!/msys\/bin|Git\/bin/.test(process.env.PATH)) + process.env.PATH = path.join(process.env.HOME, ".c9", "msys/bin") + ";" + process.env.PATH; } var home = process.env.HOME;