You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Default shells seem to be limited. For example, the following step:
- run: |
ps
echo "$(tty)"
produces:
PID TTY TIME CMD
2587 ? 00:00:02 Runner.Listener
2611 ? 00:00:02 Runner.Worker
2763 ? 00:00:00 bash
2777 ? 00:00:00 ps
not a tty
As a result, multiple tools that can provide pretty coloured logs do not work as expected. This is the case of e.g. colorama or pytest in the Python ecosystem.
A possible workaround is to use docker run --rm -t .... However, this involves installing in the container multiple resources/tools that are already available on the host. Furthermore, I don't know if windows containers are supported on windows-latest jobs.
I tried setting shell: bash -i -l {0}, but I get:
bash: cannot set terminal process group (1291): Inappropriate ioctl for device
bash: no job control in this shell
I tried python -c 'import pty; pty.spawn("/bin/sh")' too, but the job wil run for more than 10min with no output.
Which is the appropriate syntax to get a TTY?
Reacted by Marika Marszalkowski, Petr Ruzicka, Shivam Mathur, Danny Ben Shitrit, Kirill Groshkov, Daniel Lockyer, Patrick Connolly, Kartikey Tanna, Adrien Becchis, rob and 96 more
So maybe it can work? Why does it get permission denied when trying to run that script? Presumably it's {0} being substituted, but it's not executable??
The execution might continue after those warning, although not providing a tty. Anyway, I have not been able to achieve using both shell and run. See actions/starter-workflows#95.
No. TBH, I was quite surprised about how this issue was handled. Alternatives so far are to manually force each tool (if options are provided) or to use docker containers (thus, making GitHub environments and actions irrelevant).
What are you trying to do with this? Is it just color codes? (Im sure there are other implications of being a tty) As far as Im aware, the web console will render ANSI color codes correctly, however there is of course the issue of: how is a tool, in general, supposed to know that? I dont really know enough to say for sure, but it seems like allocating a tty is not 100% correct- does that assume it is a 2 way input/output? Obviously you cant type into the web console, so I dont know how close we can get to saying the web console is a true tty, and thus implying we support the features of a tty (input, maybe more?) I hesitate to say we should force downstream tools (anything the runner runs during job execution, ie your workflow) to think they have a tty. I recall this impacting things like installers which may throw a prompt up and wait for input, and similar issues.
I do know: We set $TERM=dumb so that tools ran here dont try to do anything fancy. After all, all we are doing is buffering the stdout of the programs you run, and streaming them line by line to the web browser. That being said, I did mention the web console will render ansi colors. How can we configure the environment to indicate that to downstream processes? Ive played around with setting TERM differently, read about terminfo, etc, but honestly havent fully wrapped my head around it yet
I guess in general, my stance is that the web console is not a terminal and shouldnt pretend to be, although we do in a sense, because we render ansi colors. And my question to that is, is there a granular way we can surface that capability (ansi colors, only) to downstream tools? Via environment or other?
@dakale An example use case of TTY environment variable is gpg-agent, which is used to sign files on GitHub Actions. If TTY is broken, GPG2, installed by default, can't communicate with gpg-agent well.
Signing files with GPG is required for uploading artifacts to the Maven central repository. Hopefully, we can use gpg2 (installed by default) in GH action without such a complex setup.
Reacted by Samuel Williams, Pamela Delgado, T. Nein, StephenWithPH, Aleksander Machniak, Christian, Thom'H, Caroline Hickey, Bartek Pacia, matt and 3 more
Hi @dakale! Thanks a lot for giving this a thought!
What are you trying to do with this? Is it just color codes? (Im sure there are other implications of being a tty) As far as Im aware, the web console will render ANSI color codes correctly, however there is of course the issue of: how is a tool, in general, supposed to know that?
Yes, the main issue I found is a difference between executing "test runners" locally or on GHA. Some of these tools are pytest, tox, colorama, yarn, grunt, (rich)go... The point it that each of those uses a different mechanism to force colors when a tty is not available. Therefore, although possible, it is a maintenance nightmare. I'm afraid that there is no resource to tell all of them at once, except providing a good enough tty.
I dont really know enough to say for sure, but it seems like allocating a tty is not 100% correct- does that assume it is a 2 way input/output? Obviously you cant type into the web console, so I dont know how close we can get to saying the web console is a true tty, and thus implying we support the features of a tty (input, maybe more?) I hesitate to say we should force downstream tools (anything the runner runs during job execution, ie your workflow) to think they have a tty.
IMHO, you are mixing concepts here. On the one hand, TTY stands for TeleTYpewriter, which in modern days, is interpreted as a text-only terminal, as opposed to a GUI. On the other hand, a terminal, be it text-only or a GUI, can be input-only, output-only, or both of them. The normal approach is for it to be input/output locally and output-only on CI environments.
I don't think it is harmful at all to let downstream tools know/think that they are using a tty for output only, because a proper terminal is used almost always (all suggested cmd, powershell and bash terminals are proper tty tools). Furthermore, most of the jobs that are executed on CI should be in "batch mode", even if an input terminal was shown. This is true for local execution too.
I recall this impacting things like installers which may throw a prompt up and wait for input, and similar issues.
Most installers allow to run them in batch mode. If they don't, and they need the environment to be forced, that's an issue to be solved by the maintainers of the installers.
Please, note that any limitation you might think about with this regard is applicable almost directly to docker containers. I mean that this has already being addressed and solved. Precisely, if the same tasks are executed in containers running on GHA, a proper tty (output-only) is provided. This is to say that any user can potentially replace run: ... with run: docker run --rm -tv $(pwd):/src -w /src ubuntu:19.04 ...., which is a tty with no stdin. It is also possible to execute a container with stdin but without a tty: https://stackoverflow.com/questions/35459652/when-would-i-use-interactive-without-tty-in-a-docker-container.
I do know: We set $TERM=dumb so that tools ran here dont try to do anything fancy. (...) How can we configure the environment to indicate that to downstream processes? Ive played around with setting TERM differently, read about terminfo, etc, but honestly havent fully wrapped my head around it yet
I think that any solution which makes it optional, such as providing a (limited) tty and using TERM to tell that it is not a regular "xterm", is better than forcing a solution. If a tty is provided, users can disable it. However, now it is not available, so it's not possible to enable it.
EDIT
@xerial, precisely, this issue is related to actions/starter-workflows#96, because GPG seems to be required for using a docker credential helper.
Reacted by Samuel Williams, Claude Léveillé, Michael Diamond, Makyen, Hugo van Kemenade and Ahsan David Pérez Bermúdez
Unfortunately even PTYs seem to hang in runners. I've been working on conda/rattler#1746 which has a rust-based PTY implementation and it just hangs when run in a runner when you perform anything but very basic operations in the PTY.
Activity
andymckay commentedon Oct 7, 2019
Thank you @1138-4eb, but we'd like to keep issues related to code in this repository.
eine commentedon Oct 7, 2019
@andymckay, this issue is related to almost, if not all, the code in this repository. For example:
ioquatix commentedon Nov 12, 2019
I too am interested in this.
ioquatix commentedon Nov 12, 2019
So, I tried using the
shell:option, as in:But got the following:
eine commentedon Nov 12, 2019
@ioquatix, note that the messages in lines 4 and 5 are warnings. I don't know if those are related to the error in line 6. See for example https://github.com/ghdl/ghdl/runs/298621638#step:5:14
ioquatix commentedon Nov 12, 2019
Ahh, interesting.
So maybe it can work? Why does it get permission denied when trying to run that script? Presumably it's
{0}being substituted, but it's not executable??eine commentedon Nov 12, 2019
The execution might continue after those warning, although not providing a tty. Anyway, I have not been able to achieve using both
shellandrun. See actions/starter-workflows#95.ioquatix commentedon Nov 12, 2019
Yeah, I've come to the same conclusion, no matter what I do I can't figure out how to get it to allocate a TTY/PTY that actually works.
ioquatix commentedon Nov 12, 2019
@1138-4eb did you find any solution at all?
eine commentedon Nov 12, 2019
No. TBH, I was quite surprised about how this issue was handled. Alternatives so far are to manually force each tool (if options are provided) or to use docker containers (thus, making GitHub environments and actions irrelevant).
ioquatix commentedon Nov 12, 2019
I've emailed github support.. but that's a black hole... let's see if anything comes of it.
dakale commentedon Nov 20, 2019
What are you trying to do with this? Is it just color codes? (Im sure there are other implications of being a tty) As far as Im aware, the web console will render ANSI color codes correctly, however there is of course the issue of: how is a tool, in general, supposed to know that? I dont really know enough to say for sure, but it seems like allocating a tty is not 100% correct- does that assume it is a 2 way input/output? Obviously you cant type into the web console, so I dont know how close we can get to saying the web console is a true tty, and thus implying we support the features of a tty (input, maybe more?) I hesitate to say we should force downstream tools (anything the runner runs during job execution, ie your workflow) to think they have a tty. I recall this impacting things like installers which may throw a prompt up and wait for input, and similar issues.
I do know: We set $TERM=dumb so that tools ran here dont try to do anything fancy. After all, all we are doing is buffering the stdout of the programs you run, and streaming them line by line to the web browser. That being said, I did mention the web console will render ansi colors. How can we configure the environment to indicate that to downstream processes? Ive played around with setting TERM differently, read about terminfo, etc, but honestly havent fully wrapped my head around it yet
I guess in general, my stance is that the web console is not a terminal and shouldnt pretend to be, although we do in a sense, because we render ansi colors. And my question to that is, is there a granular way we can surface that capability (ansi colors, only) to downstream tools? Via environment or other?
@ioquatix To answer something you brought up, in the
shell:option,{0}is the filename (not contents) of the temp file that therun:string was written to, per https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#custom-shellxerial commentedon Nov 21, 2019
@dakale An example use case of TTY environment variable is gpg-agent, which is used to sign files on GitHub Actions. If TTY is broken, GPG2, installed by default, can't communicate with gpg-agent well.
To resolve this, we needed to force using GPG1, which doesn't depend on TTY by default. @olafurpg created a GitHub action task to do so:
https://github.com/olafurpg/setup-gpg
Signing files with GPG is required for uploading artifacts to the Maven central repository. Hopefully, we can use gpg2 (installed by default) in GH action without such a complex setup.
eine commentedon Nov 21, 2019
Hi @dakale! Thanks a lot for giving this a thought!
Yes, the main issue I found is a difference between executing "test runners" locally or on GHA. Some of these tools are pytest, tox, colorama, yarn, grunt, (rich)go... The point it that each of those uses a different mechanism to force colors when a tty is not available. Therefore, although possible, it is a maintenance nightmare. I'm afraid that there is no resource to tell all of them at once, except providing a good enough tty.
IMHO, you are mixing concepts here. On the one hand, TTY stands for TeleTYpewriter, which in modern days, is interpreted as a text-only terminal, as opposed to a GUI. On the other hand, a terminal, be it text-only or a GUI, can be input-only, output-only, or both of them. The normal approach is for it to be input/output locally and output-only on CI environments.
I don't think it is harmful at all to let downstream tools know/think that they are using a tty for output only, because a proper terminal is used almost always (all suggested cmd, powershell and bash terminals are proper tty tools). Furthermore, most of the jobs that are executed on CI should be in "batch mode", even if an input terminal was shown. This is true for local execution too.
Most installers allow to run them in batch mode. If they don't, and they need the environment to be forced, that's an issue to be solved by the maintainers of the installers.
Please, note that any limitation you might think about with this regard is applicable almost directly to docker containers. I mean that this has already being addressed and solved. Precisely, if the same tasks are executed in containers running on GHA, a proper tty (output-only) is provided. This is to say that any user can potentially replace
run: ...withrun: docker run --rm -tv $(pwd):/src -w /src ubuntu:19.04 ...., which is a tty with no stdin. It is also possible to execute a container with stdin but without a tty: https://stackoverflow.com/questions/35459652/when-would-i-use-interactive-without-tty-in-a-docker-container.I think that any solution which makes it optional, such as providing a (limited) tty and using TERM to tell that it is not a regular "xterm", is better than forcing a solution. If a tty is provided, users can disable it. However, now it is not available, so it's not possible to enable it.
EDIT
@xerial, precisely, this issue is related to actions/starter-workflows#96, because GPG seems to be required for using a docker credential helper.
150 remaining items
integration tests: add --force-color & set in CI
kirankumar-badiger commentedon Jun 1, 2025
Unable to run expect command based script in Non TTY Terminal in github action runner
benoit-pierre commentedon Jun 1, 2025
Here's a small Python based workaround:
Example:
kirankumar-badiger commentedon Jun 1, 2025
Thanks, I am trying to run this python script with expect command: https://github.com/oracle-devrel/cd3-automation-toolkit/blob/main/cd3_automation_toolkit/setUpOCI.py
feat(test): New UI implementation for `ie test` & refactor various pa…
iamthebot commentedon Oct 15, 2025
Unfortunately even PTYs seem to hang in runners. I've been working on conda/rattler#1746 which has a rust-based PTY implementation and it just hangs when run in a runner when you perform anything but very basic operations in the PTY.
fix(main): use pseudoterminal to fork main.sh
fix(main): use pseudoterminal to fork main.sh
Run CI on host runner and invoke docker ourselves
integration tests: add --force-color & set in CI
fix(ci): disable TTY features (escape sequences)
workflow: force color support to be enabled
integration tests: add --force-color & set in CI