Skip to content

Can't run docker with exec() (the input device is not a TTY) #680

@skrysm

Description

@skrysm

Node version (or tell us if you're using electron or some other framework):

7.7.1 (and also 7.5.0)

ShellJS version (the most recent version/Github branch you see the bug on):

0.7.6

Operating system:

Windows 10 x64, Ubuntu 16.04.2 x64

Description of the bug:

docker run command can't be executed with exec(). (May also affect other programs.)

I'm executing this script (via node script.js):

require('shelljs/global');
config.fatal = true;
exec('docker run --rm -ti hello-world');

Depending on the operating system and terminal used, I'm getting different errors:

Windows 10 & Cmder:

The handle is invalid.
D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\common.js:381
      if (config.fatal) throw e;
                        ^

Error: exec: internal error
    at Object.error (D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\common.js:112:27)
    at _exec (D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\exec.js:292:12)
    at D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\common.js:316:23
    at Object.<anonymous> (D:\Desktop\shelljs-exec-bug\script.js:3:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)

Windows 10 & regular cmd:

the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\common.js:381
      if (config.fatal) throw e;
                        ^

Error: exec: internal error
    at Object.error (D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\common.js:112:27)
    at _exec (D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\exec.js:292:12)
    at D:\Desktop\shelljs-exec-bug\node_modules\shelljs\src\common.js:316:23
    at Object.<anonymous> (D:\Desktop\shelljs-exec-bug\script.js:3:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)

Ubuntu:

the input device is not a TTY
/root/shelljs-ctrl-c/node_modules/shelljs/src/common.js:381
      if (config.fatal) throw e;
                        ^

Error: exec: internal error
    at Object.error (/root/shelljs-ctrl-c/node_modules/shelljs/src/common.js:112:27)
    at _exec (/root/shelljs-ctrl-c/node_modules/shelljs/src/exec.js:292:12)
    at /root/shelljs-ctrl-c/node_modules/shelljs/src/common.js:316:23
    at Object.<anonymous> (/root/shelljs-ctrl-c/test-shelljs.js:4:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)

Running the same command directly on the command line or even through child_process.spawn() works, though:

const child_process = require('child_process');
child_process.spawnSync('docker', [ 'run', '--rm', '-ti', 'hello-world' ], {
	stdio: 'inherit'
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateexecIssues specific to the shell.exec() API

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions