Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to install composer through php, as described in their wesite.

php -r "readfile('https://getcomposer.org/installer');" | php

But it is displaying the following error:

$ php -r "readfile('https://getcomposer.org/installer');" | php
output is not a tty
input is not a tty

I am in windows 7 and using git bash to execute this command. At windows command prompt, it is working fine. This problem is only occur when I run this command from git bash 2.6.2-64bit.

BTW, I have installed composer for windows, and that is working fine. But I can not download composer.phar in this way. How can I fix this issue?

like image 846
Tahmina Khatoon Avatar asked Nov 10 '15 02:11

Tahmina Khatoon


2 Answers

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.

like image 162
VonC Avatar answered Oct 18 '22 12:10

VonC


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

like image 41
nu everest Avatar answered Oct 18 '22 11:10

nu everest