Open fsateler opened 4 years ago
Hi Felipe 👋
Thanks for rasing the issue and using tty-command
.
Would you have time to investigate potential fix?
It looks like the issue is that ProcessRunner
only tries to write to stdin
once when the command is started: https://github.com/piotrmurach/tty-command/blob/da308658f0cb96db78d5b3b25985fae0434973a0/lib/tty/command/process_runner.rb#L46
I think to be able to wrap interactive commands, we would need another thread to manage stdin.
I was able to use https://github.com/stripe/subprocess to wrap an interactive command.
@ryansch - mind providing a code snippet to show how you used subprocess to solve this?
@codefriar I'd like this to be fixed in the tty-command
project. I maintain many Ruby projects and have limited time. Thus I need help and encourage any contributions that get us closer to resolving this problem. Unfortunately, your comment doesn't get us in this direction. This is not the place to seek explanations on how to use other libraries and I suggest you open an issue in the other project.
@piotrmurach My apologies. My initial read of @ryansch 's comment was that he'd gotten this to work in tty-command perhaps by utilizing the subprocess command. I was hoping to prompt him to share his fix for tty-command.
Hi all, is this possible now? When I run a shell in a subprocess with pty: true (for example kubectl to open a shell in a pod in Kubernetes), the shell starts and I can press keys etc but when I press enter nothing happens in the shell. Any suggestion? Thanks!
I just wrote https://github.com/outstand/dash/blob/cd7c740afd1dc7fa809afd630e8a50ee68e391ca/lib/state.rb#L65 to integrate Subprocess
a bit more with this gem. At least this way I get similar logging output!
@codefriar I finally did... ^
I looked at the differences between tty-command
and subprocess
and I think subprocess
works here because it gives the caller the ability to directly connect the spawned process to STDIN, STDOUT, STDERR.
@ryansch Do you have any suggestions on helping tackle this issue in tty-command
itself? I'm all for exposing streams to connect directly. This is important to solve. Any help would be really appreciated!
I had originally thought about grafting subprocess into this gem but I think exposing the streams might be all we need. I'll see if I can't work up an experiment to test it.
@codefriar , @ryansch I just read this thread and wanted to offer an alternative data point that I did interpret your posts as trying to fix or work arouind this issue rather than recommending or documenting the use of other gems. Thanks for your efforts.
Describe the problem
Shells cannot be run with TTY::Command. Keyboard input is not read by the shell.
Steps to reproduce the problem
Actual behaviour
(slightly edited to remove identifying information)
Expected behaviour
A working interactive shell.
Describe your environment