spago icon indicating copy to clipboard operation
spago copied to clipboard

Unlike spago-legacy, PureScript version creates child-process which is non-TTY

Open shamansir opened this issue 5 months ago • 1 comments

I am working on purescript-blessed wrapper and with current spago, at least when I run it from spago run, the process is not a TTY anymore.

Spago version: 0.93.42 Spago-legacy version: 0.21.0.

I have some FFI code with calls to chjj/blessed (or kenan238/reblessed to be precise, which is the fixed modern version) and the terminal launched is just 1x1 char in size. Through debugging, I discovered that process.stdout.isTTY is not true anymore (while with spago-legacy it was), and both process.stdout.columns and process.stdout.rows are undefined.

For now, I have a forced workaround to this:

function ensureTTY() {
    if (!process.stdout.isTTY) {
        const {columns, rows} = terminalSize();
        process.stdout.isTTY = true;
        process.stdout.columns = columns;
        process.stdout.rows = rows;
    }
}

I run my code with spago run --quiet --censor-stats to avoid all the output.

Fair to say, blessed provides the API to spawn program with the custom configured terminal/tput, but this functionality is not yet wrapped.

Side-note: Since blessed and reblessed are still all CommonJS, I am failing to bundle it to ES modules easily.

If needed, I can manage to create some lib-independent demo for the issue.

shamansir avatar May 31 '25 11:05 shamansir

I see. We are using execa for spawning processes, and I suspect that the TTY behaviour was lost in the translation from Haskell.

All in all this sounds like a bug? I guess spawning processes with 1x1 terminal is not really optimal. Happy to have this fixed (unless that would cause disruptions to other usecases, which I am not sure about?) if you want to have a go at it.

f-f avatar Jun 05 '25 10:06 f-f