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

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

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

But it displays the following error:

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

I am on Windows 7 and am using git bash to execute this command. On the Windows command line, it works fine. This problem only occurs when executing this command from git bash 2.6.2-64bit.

By the way, I installed composer for windows, and it works fine. But I can not load the .phar composer this way. How can I fix this problem?

+8
source share
3 answers

This could be a PATH or encoding problem:

it seems that git ls-remote origin , starting from the newly created and installed MinGW Git, will not be able to output anything, and git ls-remote origin | cat git ls-remote origin | cat (the trick from working with old MSys / MinGW bouts) only says: output is not a tty (the exit code is 127, which indicates that no executable was found, but it’s very difficult to tell which they are shown because even print debug statements for stderr are not displayed. It seems that in the event of a crash or die (), stderr is not reset)

  • issue 519 even suggests unalias winpty

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

But:

No, we cannot just refuse winpty. PHP can be run interactively, i.e. This requires a suitable Win32 console. Running PHP without winpty in MinTTY would not provide this console instance, leaving you a seemingly unresponsive terminal.

See git -for-windows / build-extra @ 44ed99b , # 399 and # 400 for an explanation of the chaos you would have caused by simply removing these aliases.

So, the bash console is incompatible with php execution through the channel (since the second | php may not use winpty , which seems necessary when the program requires a Win32 console for interactive use).

Peh points out in the comments :

If you use C: `Program Files \ Git \ bin \ bash.exe instead of C: \ Program Files \ Git \ git- bash.exe`, then the command works fine.
I use it in conjunction with ConsoleZ without any problems

This is probably because bash.exe does not use winpty , unlike git-bash.exe .

+8
source

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

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

enter image description here

  • You should now see the command line.

  • Go to the PHP project directory and install Composer.

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

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

    $ ls

  • The composer.phar file is now displayed in the root of the project.

  • Install the composer package.

    $ php composer.phar requires some package-you-want-install

+2
source

Can be output using bash: C: \ Program Files \ Git \ bin \ bash.exe

-1
source

All Articles