Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
skrysmanski opened this issue Mar 4, 2017 · 5 comments
Closed

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

skrysmanski opened this issue Mar 4, 2017 · 5 comments
Labels
duplicate exec Issues specific to the shell.exec() API

Comments

@skrysmanski
Copy link

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'
});
@nfischer
Copy link
Member

nfischer commented Mar 4, 2017

This should be fixed by #524

@nfischer nfischer added the exec Issues specific to the shell.exec() API label Mar 8, 2017
@wclr
Copy link

wclr commented Mar 25, 2017

I believe the same problem with docker compose exec docker-compose exec [service] bash

#695

@wclr
Copy link

wclr commented Mar 25, 2017

standard exec from child_process works, so it should be no problem to fix it in shelljs.

@nfischer
Copy link
Member

Duplicate of #424

@nfischer nfischer marked this as a duplicate of #424 Oct 18, 2017
@nfischer
Copy link
Member

nfischer commented Oct 18, 2017

Workaround is in the FAQs: https://github.com/shelljs/shelljs/wiki/FAQ#running-interactive-programs-with-exec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate exec Issues specific to the shell.exec() API
Projects
None yet
Development

No branches or pull requests

3 participants