Macchina-CLI/macchina

Macchina does not work without /dev/stdin on macOS

Opened this issue · 3 comments

Describe the bug
Macchina does not work without /dev/stdin on macOS.
I've also tested on Arch Linux x86_64 and Arch Linux aarch64, they both work without /dev/stdin.

To Reproduce
Steps to reproduce the behavior:

  1. macchina < /dev/null

Expected behavior
Macchina runs correctly.

Actual behavior
It hangs and cannot exit with CTRL-C.

Usage Scenario
I put macchina into my .bashrc script, and would like it to not consume /dev/stdin, so that

  • I can type ahead when .bashrc script (macchina and others) runs;
  • and shell can accept external input on startup.
    • e.g. VSCode can spawn an integrated terminal, feed command into it, and then run it. (e.g. VSCode Python virtualenv integration)
    • currently the above does not work as the initial command fed into the terminal will be consumed by macchina.

Screenshots
image

macchina --doctor output

We've collected a total of 20 readouts including 2 failed read(s) and 1 read(s) resulting in a warning.

Readout "LocalIP" failed with message: Unable to get local IPv4 address.
Readout "GPU" failed with message: This metric is not available on this platform or is not yet implemented by libmacchina.

1 of the 3 unsuccessful read(s) resulted in a warning:
 Readout "Distribution" threw a warning with message: Since you're on macOS, there is no distribution to be read from the system.

System Information

  • Operating System: macOS 15.1 Beta
  • Terminal: iTerm2
  • Macchina's version: macchina 6.2.1; libmacchina 7.3.1

I've also tested with macchina 6.1.8, it's the same issue for me.

Some more findings on this:

  • macchina < /dev/null hangs with 100% CPU usage;
  • macchina < /dev/null > file works;
  • some debugging shows it hangs at backend.get_cursor_position(), which calls crossterm::cursor::position().

Now it seems like a crossterm bug...

Related crossterm bug at crossterm-rs/crossterm#828

Workaround for macchina users on macOS:

macchina < /dev/null > >(cat)

Thanks for sharing that workaround, we'll upgrade to a non-affected version of crossterm when that issue is eventually addressed.