tomas/dialog

Error: spawn zenity ENOENT

Closed this issue · 2 comments

I ran npm i dialog, then I used this code:

const dialog = require('dialog')

dialog.info('Ground control to major Tom.', 'My app', function(exitCode) {
    if (exitCode == 0) console.log('User clicked OK');
})

Result:

david@CHE-T14S:~/z/Temp/tmp1/tmp2 $ node index.js
node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: spawn zenity ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn zenity',
  path: 'zenity',
  spawnargs: [
    '--info',
    '--text',
    'Ground control to major Tom.',
    '--title',
    'My app'
  ]
}

WSL (Ubuntu 20.04). DISPLAY variable is set.

tomas commented

Looks that you don't have the zenity program installed.

That may be the case but why would users of my software have to install some additional tool to see a message displayed? VBScript is installed by default on Windows. I didn't know what zenity even was until now. If zenity isn't by default available on popular Linux distributions then maybe it shouldn't be the (only) tool used by this library for Linux...

It seems other solutions with wider compatibility exist, such as script-dialog, apparently a shell script that will use not only zenity but also other options as available and fall back to a text-mode dialog if no viable option was found, providing the same level of reliability as your VBScript solution provides for Windows. It would be great if dialog could use that script-dialog.sh script (or some custom but similarly reliable solution) on Linux. If that's not possible for some reason, it would be nice to at least see some warning in the readme file that on Linux it will work only for some users, and for others an ENOENT exception may be thrown and should be handled in some meaningful way. (Although I'm not sure what way that would be, to be honest. It makes me feel like using this on Linux is just not an option if you want to have others use your software afterwards... which is a bit unexpected.)