node-pty icon indicating copy to clipboard operation
node-pty copied to clipboard

Platform Difference when launching non-existing Commands

Open tsmaeder opened this issue 1 year ago • 2 comments
trafficstars

Environment details

  • OS: Linux/Window
  • OS version: Ubuntu 22, Windows 11
  • node-pty version: 1.0.0

Issue description

The following program behaves very differently on Windows vs. Linux:

const pty = require('node-pty');


const process = pty.spawn('gurkensalat', [], {});

console.log(`process pid = ${process.pid}`);

On Windows, this program throws an Error

C:\Users\thomas\code\EclipseSource\theia\node_modules\node-pty\lib\windowsPtyAgent.js:80
            term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor);
                                   ^

Error: File not found:
    at new WindowsPtyAgent (C:\Users\thomas\code\EclipseSource\theia\node_modules\node-pty\lib\windowsPtyAgent.js:80:36)
    at new WindowsTerminal (C:\Users\thomas\code\EclipseSource\theia\node_modules\node-pty\lib\windowsTerminal.js:51:24)
    at Object.spawn (C:\Users\thomas\code\EclipseSource\theia\node_modules\node-pty\lib\index.js:29:12)
    at Object.<anonymous> (C:\Users\thomas\code\EclipseSource\theia\packages\process\foo.js:4:21)

whereas on Linux it prints a pid.

I think I remember that in previous versions, the spawn call would fail for Linux also. Is there a way to still detect those failures on Linux reliably?

tsmaeder avatar Jun 23 '24 12:06 tsmaeder