# Travis output not a TTY on Windows builders

**URL:** <https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956>\
**Category:** Windows\
**Tags:** build-env, windows\
**Created:** [September 1, 2019, 4:52pm UTC](https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956 "2019-09-01T16:52:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xswordsx](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/xswordsx/32/2634_2.png) [@xswordsx](https://travis-ci.community/u/xswordsx)\
**Post date:** [September 1, 2019, 4:52pm UTC](https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956/1 "2019-09-01T16:52:03Z")

</div>

Hello,

I am trying to run some tests on a command-line tool which decides whether to show color or not based on the environment it’s running in (when the output is being piped or is generally not a TTY - colors are omitted).

**What did you expect?**  
Running commands under `cmd` / `ps` they be recognized as TTYs

**What happened?**  
The tests detect `stdout` as a non-TTY stream.

**Additional information**

- [Build logs](https://travis-ci.org/xswordsx/ff/builds/579382667)
- [Source code](https://github.com/xswordsx/ff/tree/561dea203900725d3629bb82fa85f87b291f692d)
- Tested locally under
  - `cmd` (Windows 10)
  - `ps` (Windows 10)

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [September 1, 2019, 5:26pm UTC](https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956/2 "2019-09-01T17:26:36Z")

</div>

Checking this locally in Git Bash gives the same result:

```auto
MINGW64 ~
$ python -c 'import sys,os; print os.isatty(sys.stdout.fileno())'
False

```

So this is Git Bash’s (or rather, the underlying MinGW64’s) problem.

[https://stackoverflow.com/questions/40912072/git-for-windows-mintty-sys-stdout-isatty-returns-false](https://stackoverflow.com/questions/40912072/git-for-windows-mintty-sys-stdout-isatty-returns-false) suggests that this can be worked around by running the command via `winpty`:

```auto
MINGW64 ~
$ winpty python -c 'import sys,os; print os.isatty(sys.stdout.fileno())'
True

```

---

<div class="post-metadata">

**Author:** ![xswordsx](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/xswordsx/32/2634_2.png) [@xswordsx](https://travis-ci.community/u/xswordsx)\
**Post date:** [September 6, 2019, 9:27am UTC](https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956/3 "2019-09-06T09:27:18Z")

</div>

I tried a bunch of different stuff ([see CI file](https://travis-ci.org/xswordsx/ff/jobs/581573620/config)) but I could not get `winpty` to work on the CI server _(works fine locally)_.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [October 23, 2019, 9:10am UTC](https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956/4 "2019-10-23T09:10:52Z")

</div>

[This is an issue with `winpty`.](https://github.com/rprichard/winpty/issues/93) It requires `stdin` to be a terminal. There’s no fix as of this writing.

[There’s a pull request](https://github.com/rprichard/winpty/pull/78) that claims to add a “pipe mode”. Maybe it could be used.

---

<div class="post-metadata">

**Author:** ![veganaiZe](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/veganaize/32/3258_2.png) [@veganaiZe](https://travis-ci.community/u/veganaiZe)\
**Post date:** [January 16, 2020, 8:13pm UTC](https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956/5 "2020-01-16T20:13:43Z")

</div>

💡 $ `winpty -Xallow-non-tty -Xplain <command-line>`

Outputs properly; just don’t trust its return code.

> [@\[Work-around\] Console output mangled](https://travis-ci.community/t/work-around-console-output-mangled/3541):
>
> Hi there! We had problems with the unit tests that the output to the console was mangled, lines would miss and the order of the output was not kept properly. We found that the problem is related to using Python and git-bash in combination. Some users in Stackoverflow also indicate problems with php and git-bash. The solution (workaround) is to use winpty, but with some special undocumented flags, because git-bash is not a windows console. We describe the problem/solution as this: I leave h…

---

<div class="post-metadata">

**Author:** ![xswordsx](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/xswordsx/32/2634_2.png) [@xswordsx](https://travis-ci.community/u/xswordsx)\
**Post date:** [January 18, 2020, 10:09am UTC](https://travis-ci.community/t/travis-output-not-a-tty-on-windows-builders/4956/6 "2020-01-18T10:09:59Z")

</div>

Thank you very much, @veganaiZe!

The flags enable a proper TTY (as seen in the [tests](https://travis-ci.com/xswordsx/ff/jobs/277189414) and the [CI](https://github.com/xswordsx/ff/blob/f09b1794ec6dab2d60d72692c18f7457ca6ecaae/.travis.yml#L29)).

Marking the thread as **RESOLVED**.
