Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when tput not found [Document ncurses dependency] #273

Closed
dhampik opened this issue Jul 15, 2020 · 2 comments
Closed

Exception when tput not found [Document ncurses dependency] #273

dhampik opened this issue Jul 15, 2020 · 2 comments
Assignees

Comments

@dhampik
Copy link

dhampik commented Jul 15, 2020

php:7.4.8-fpm-alpine3.12 docker image does not have ncurses (and thus tput command) installed by default. That causes the following error when running phive:

phive install
PHP Fatal error:  Uncaught PharIo\Phive\EnvironmentException: Command tput not found in phar:///usr/local/bin/phive/src/shared/environment/Environment.php:30
Stack trace:
#0 phar:///usr/local/bin/phive/src/shared/environment/UnixoidEnvironment.php(51): PharIo\Phive\Environment->getPathToCommand('tput')
#1 phar:///usr/local/bin/phive/src/shared/cli/output/OutputLocator.php(16): PharIo\Phive\UnixoidEnvironment->supportsColoredOutput()
#2 phar:///usr/local/bin/phive/src/Factory.php(199): PharIo\Phive\Cli\OutputLocator->getOutput(Object(PharIo\Phive\UnixoidEnvironment), true)
#3 phar:///usr/local/bin/phive/src/Factory.php(32): PharIo\Phive\Factory->getOutput()
#4 /usr/local/bin/phive(349): PharIo\Phive\Factory->getRunner()
#5 {main}
  thrown in phar:///usr/local/bin/phive/src/shared/environment/Environment.php on line 30

Fatal error: Uncaught PharIo\Phive\EnvironmentException: Command tput not found in phar:///usr/local/bin/phive/src/shared/environment/Environment.php on line 30

PharIo\Phive\EnvironmentException: Command tput not found in phar:///usr/local/bin/phive/src/shared/environment/Environment.php on line 30

Call Stack:
    0.0017     457912   1. {main}() /usr/local/bin/phive:0
    0.0112     770048   2. PharIo\Phive\Factory->getRunner() /usr/local/bin/phive:349
    0.0127     823488   3. PharIo\Phive\Factory->getOutput() phar:///usr/local/bin/phive/src/Factory.php:32
    0.0143     868528   4. PharIo\Phive\Cli\OutputLocator->getOutput() phar:///usr/local/bin/phive/src/Factory.php:199
    0.0143     868528   5. PharIo\Phive\UnixoidEnvironment->supportsColoredOutput() phar:///usr/local/bin/phive/src/shared/cli/output/OutputLocator.php:16
    0.0143     868904   6. PharIo\Phive\UnixoidEnvironment->getPathToCommand() phar:///usr/local/bin/phive/src/shared/environment/UnixoidEnvironment.php:51

I actually didn't know about tput command in linux and thought that it's actually a typo and it should be "output" instead, so I had to look into source files to understand what's going on.

There is also dependency on gnupg, but there is a clear output for it:

phive install
Phive 0.14.4 - Copyright (C) 2015-2020 by Arne Blankerts, Sebastian Heuer and Contributors
[ERROR]    No executable gpg binary found.  
[ERROR]     Either install gpg or enable the gnupg extension in PHP. 

Maybe it would be good to document it somewhere (readme?).

@theseer
Copy link
Member

theseer commented Jul 15, 2020

We might also provide an alternative / backup implementation, in case tput is not available.

@theseer theseer added the bug label Jul 15, 2020
@theseer theseer self-assigned this Jul 15, 2020
@theseer
Copy link
Member

theseer commented Jul 15, 2020

Yes, looking at the code in question the exception certainly should not bubble up like this to begin with. But indeed there should also be alternative means to detect color capabilities.

@theseer theseer changed the title Document ncurses dependency Exception when tput not found [Document ncurses dependency] Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants