darklang / dark

Darklang main repo, including language, backend, and infra
https://darklang.com
Other
1.68k stars 91 forks source link

Allocate a pty #1

Closed pbiggar closed 7 years ago

pbiggar commented 7 years ago

I'm abandoning this for now, after spending too long on it.

I had to revert 77afc9140186f3e35a05aa4ac9b7a2116a49b9ed.

I originally added this to make docker allocate a tty, which means we can skip the delicate buffering behaviour in python, and also gets better output (the ocaml compiler shows progress when run under a tty, for example).

Unfortunately, the patch as is prevents stdin, which means fswatch isn't doing anything. The solution is to add the -p flag to unbuffer, but this causes docker to echo stdin (from fswatch) back to us. I tried a ton of things to fix this, including all the alternatives to unbuffer on SO, but it looks like the problem isn't unbuffer but docker. I validated this with a script below

#!/bin/bash

# fswatch -a . | unbuffer -p sed -e "s/./b/g"
fswatch -a . | unbuffer -p docker run -it dark sed -e "s/./b/g"

You would think you could just add a grep at the end of the pipe, but then that also needs to be unbuffered, and this starts to add a ton of newlines to the output, making the whole thing pointless (I believe this is a function of ttys, which use crlf, though I haven't figured out how specifically it would cause this).

Maybe we can use stty to fix this, but I've spent too long on this already.

pbiggar commented 7 years ago

Figured out we only need to trick the elm compiler into thinking there is a tty, so we add unbuffer in the docker image and call it directly on Elm.