asciinema / asciinema

Terminal session recorder 📹

Home Page:https://asciinema.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

asciinema cat fails with OSError: [Errno 6] No such device or address: '/dev/tty' when running from GitHub Action

vorburger opened this issue · comments

Describe the bug

In enola-dev/enola#142, I would like to run asciinema from a GitHub Action.

To Reproduce

Create a GitHub .github/workflows/asciinema.yaml with a run: of something which launches asciinema triggers:

asciinema: recording asciicast to /home/runner/work/enola/enola/docs/use/library/script.cast
asciinema: exit opened program when you're done
asciinema: recording finished
asciinema: asciicast saved to /home/runner/work/enola/enola/docs/use/library/script.cast

+ svg-term --window --width 80 --height 25 --in /home/runner/work/enola/enola/docs/use/library/script.cast --out /home/runner/work/enola/enola/docs/use/library/script.svg
+ asciinema cat /home/runner/work/enola/enola/docs/use/library/script.cast
+ col -b
+ perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g'
Traceback (most recent call last):
  File "/home/runner/work/enola/enola/.venv/bin/asciinema", line 8, in <module>
    sys.exit(main())
  File "/home/runner/work/enola/enola/.venv/lib/python3.10/site-packages/asciinema/__main__.py", line 215, in main
    code = command.execute()
  File "/home/runner/work/enola/enola/.venv/lib/python3.10/site-packages/asciinema/commands/cat.py", line 17, in execute
    with open("/dev/tty", "rt", encoding="utf-8") as stdin:
OSError: [Errno 6] No such device or address: '/dev/tty'
Error: Process completed with exit code 123.

Versions:

  • OS: Ubuntu VM from GitHub Action
  • asciinema cli: 2.2.0

Additional context

I gathered this is related to actions/runner#241, and understand that this isn't so much a "bug" of asciinema but a limitation of the Linux environment of a GitHub Action not having a /dev/tty.

But perhaps someone can provide some input or suggestions how to work around this? I've found https://github.com/tarides/meio/pull/48/files where @TheLortex patches a get_terminal_size() - but that doesn't seem to be where it fails above...

After enabling set -x in my script, I figured that this actually seems to be specific only to asciinema cat and not asciinema rec; I will update the log above with details, and the issue title, accordingly.

I can work around this by not using asciinema cat in the GitHub Action and just change my script to to run that locally. (BTW zechris/asciinema-rec_script#63 is something about doing that alltogether differently, otherwise unrelated to this.)

Keeping this issue open for others who may run into this and possible future better workaround.

Thanks. I think we can find a simple way to fix this for cat.