Composer installation error - output is not a tty, input is not a tty

It can be a PATH or an encoding issue:

  • issue 25 mentions:

it seems that git ls-remote origin, run from a freshly-built and installed MinGW Git fails to be able to output anything, and git ls-remote origin | cat (a trick learned from working with old MSys'/MinGW's quirks) only says: output is not a tty (the exit code is 127, suggesting that some executable was not found, but it is very difficult to say which one because not even debug print statements to stderr are shown; It seems that in case of a crash or of a die(), stderr is not flushed)

  • issue 519 even suggests to unalias winpty

      unalias $(alias | grep winpty | cut -d"=" -f1 | cut -d" " -f2)
    

But:

No, we cannot simply abandon winpty. PHP can be run interactively, i.e. it requires a proper Win32 Console. Running PHP without winpty in MinTTY would not provide that Console instance, leaving you with a seemingly unresponsive terminal.

See git-for-windows/build-extra@44ed99b, #399 and #400 to understand what havoc you would wreak by simply removing those aliases.

So right now, the bash console is not compatible with executing php through pipe (as the second | php might not benefit from winpty, which seems needed when a program requires a Win32 Console for interactive usage).

Peh points out in the comments:

If you use C:`Program Files\Git\bin\bash.exeinstead ofC:\Program Files\Git\git-bash.exe`, then the command works fine.
I'm using it in combination with ConsoleZ without any problems

That probably is because bash.exe does not use winpty, contrary to git-bash.exe.


VonC's answer is correct, and to help others in the future I want to provide a more visual solution.

  • Navigate to C:\Program Files\Git\bin
  • Double-click on bash.exe

enter image description here

  • You should now see a command prompt.

  • Navigate to your PHP project directory and install Composer.

    $ cd C:\path\to\your\project

    $ curl -sS https://getcomposer.org/installer | php

    $ ls

  • The file composer.phar is now visible in project root.

  • Install a package with composer.

    $ php composer.phar require some-package-you-want-to-install