PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 19, 2022

[FIXED] Composer installation error - output is not a tty, input is not a tty

 February 19, 2022     composer-php, git-bash, php, windows     No comments   

Issue

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?


Solution

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.



Answered By - VonC
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing