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

rtrim() expects parameter 1 to be string, bool given #218

Closed
burzum opened this issue Dec 5, 2019 · 18 comments
Closed

rtrim() expects parameter 1 to be string, bool given #218

burzum opened this issue Dec 5, 2019 · 18 comments
Labels

Comments

@burzum
Copy link

burzum commented Dec 5, 2019

When running phive on Windows 10, using Powershell, I'm getting the error:

rtrim() expects parameter 1 to be string, bool given

Here is the full output:

λ php .\phive.phar install phpunit@8.0
Phive 0.13.2 - Copyright (C) 2015-2019 by Arne Blankerts, Sebastian Heuer and Contributors
Fetching repository list
Downloading https://phar.io/data/repositories.xml
Downloading https://phar.phpunit.de/phive.xml
Downloading https://phar.phpunit.de/phpunit-8.0.6.phar
Downloading https://phar.phpunit.de/phpunit-8.0.6.phar.asc
Downloading key 4AA394086372C20A
Trying to connect to keys.openpgp.org (37.218.245.50)
Downloading https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x4AA394086372C20A
Successfully downloaded key.

        Fingerprint: D840 6D0D 8294 7747 2937 7831 4AA3 9408 6372 C20A

        Sebastian Bergmann <sb@sebastian-bergmann.de>
        Sebastian Bergmann <sebastian.bergmann@thephp.cc>
        Sebastian Bergmann <sebastian@php.net>
        Sebastian Bergmann <sebastian@phpunit.de>
        Sebastian Bergmann <sebastian@thephp.cc>

        Created: 2014-07-19

Import this key? [y|N] [ERROR]    An error occurred while processing your request:

          rtrim() expects parameter 1 to be string, bool given

          #0 src/shared/cli/input/ConsoleInput.php(23)
          #1 src/shared/cli/input/ConsoleInput.php(23): rtrim()
          #2 src/services/key/KeyService.php(64): PharIo\Phive\Cli\ConsoleInput->confirm()
          #3 src/services/key/KeyService.php(48): PharIo\Phive\KeyService->allowedToImport()
          #4 src/services/signature/gpg/GnupgSignatureVerifier.php(27): PharIo\Phive\KeyService->importKey()
          #5 src/services/phar/PharDownloader.php(84): PharIo\Phive\GnupgSignatureVerifier->verify()
          #6 src/services/phar/PharDownloader.php(44): PharIo\Phive\PharDownloader->verifySignature()
          #7 src/services/phar/PharService.php(22): PharIo\Phive\PharDownloader->download()
          #8 src/services/phar/InstallService.php(45): PharIo\Phive\PharService->getPharFromRelease()
          #9 src/commands/install/InstallCommand.php(45): PharIo\Phive\InstallService->execute()
          #10 src/commands/install/InstallCommand.php(37): PharIo\Phive\InstallCommand->installRequestedPhar()
          #11 src/shared/cli/Runner.php(193): PharIo\Phive\InstallCommand->execute()
          #12 src/shared/cli/Runner.php(60): PharIo\Phive\Cli\Runner->execute()
          #13 (313): PharIo\Phive\Cli\Runner->run()
          #14 {main}

          Environment: PHP 7.4.0
          Phive Version: 0.13.2

          This should not have happened and is most likely a bug.
          Please report it at https://github.com/phar-io/phive/issues, make sure you include
          the full output of this error message. Thank you!
@theseer theseer added the bug label Dec 5, 2019
@theseer
Copy link
Member

theseer commented Dec 5, 2019

Just to verify: There is no "Y" or "N" in the output.
Did you simply press enter?

Trying to reproduce this.

@burzum
Copy link
Author

burzum commented Dec 6, 2019

@theseer No, it directly fails with this error message, I can't even enter anything. I'm running php 7.4.0.

@theseer
Copy link
Member

theseer commented Dec 6, 2019

Wow.

@burzum
Copy link
Author

burzum commented Dec 6, 2019

@theseer it asks me on Travis which is using an Ubuntu VM I think as well but it doesn't error there.

https://travis-ci.org/burzum/emogrifier/jobs/621774976 How can I set it up to suppress the question and just download it?

@theseer
Copy link
Member

theseer commented Dec 6, 2019

Add --trust-gpg-keys to the call, passing (a comma separated list of) the key id(s).

@theseer
Copy link
Member

theseer commented Dec 6, 2019

I fired up my Win 10 VM to try this and fail to reproduce it:

cmd.exe

C:\Users\TheSeer\Desktop\xx>php phive-0.13.2.phar install phpunit@8.0
Phive 0.13.2 - Copyright (C) 2015-2019 by Arne Blankerts, Sebastian Heuer and Contributors
Fetching repository list
Downloading https://phar.io/data/repositories.xml
Downloading https://phar.phpunit.de/phive.xml
Downloading https://phar.phpunit.de/phpunit-8.0.6.phar
Downloading https://phar.phpunit.de/phpunit-8.0.6.phar.asc
Downloading key 4AA394086372C20A
Trying to connect to keys.openpgp.org (37.218.245.50)
Downloading https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x4AA394086372C20A
Successfully downloaded key.

        Fingerprint: D840 6D0D 8294 7747 2937 7831 4AA3 9408 6372 C20A

        Sebastian Bergmann <sb@sebastian-bergmann.de>
        Sebastian Bergmann <sebastian.bergmann@thephp.cc>
        Sebastian Bergmann <sebastian@php.net>
        Sebastian Bergmann <sebastian@phpunit.de>
        Sebastian Bergmann <sebastian@thephp.cc>

        Created: 2014-07-19

Import this key? [y|N] n
[ERROR]   User declined import of key 4AA394086372C20A
[ERROR]   Signature could not be verified
[ERROR]   [GNUPG:] NEWSIG
[ERROR]   [GNUPG:] ERRSIG 4AA394086372C20A 1 10 00 1553608850 9 -
[ERROR]   [GNUPG:] NO_PUBKEY 4AA394086372C20A

Powershell

PS C:\Users\TheSeer\Desktop\xx> php .\phive-0.13.2.phar install phpunit@8.0
Phive 0.13.2 - Copyright (C) 2015-2019 by Arne Blankerts, Sebastian Heuer and Contributors
Downloading https://phar.phpunit.de/phpunit-8.0.6.phar
Downloading https://phar.phpunit.de/phpunit-8.0.6.phar.asc
Downloading key 4AA394086372C20A
Trying to connect to keys.openpgp.org (37.218.245.50)
Downloading https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x4AA394086372C20A
Successfully downloaded key.

        Fingerprint: D840 6D0D 8294 7747 2937 7831 4AA3 9408 6372 C20A

        Sebastian Bergmann <sb@sebastian-bergmann.de>
        Sebastian Bergmann <sebastian.bergmann@thephp.cc>
        Sebastian Bergmann <sebastian@php.net>
        Sebastian Bergmann <sebastian@phpunit.de>
        Sebastian Bergmann <sebastian@thephp.cc>

        Created: 2014-07-19

Import this key? [y|N] n
[ERROR]   User declined import of key 4AA394086372C20A
[ERROR]   Signature could not be verified
[ERROR]   [GNUPG:] NEWSIG
[ERROR]   [GNUPG:] ERRSIG 4AA394086372C20A 1 10 00 1553608850 9 -
[ERROR]   [GNUPG:] NO_PUBKEY 4AA394086372C20A

PS C:\Users\TheSeer\Desktop\xx>

Works for me? I do realize we should catch the potential boolean return value but I fail to see how this can happen ;)

@burzum
Copy link
Author

burzum commented Dec 7, 2019

I doesn't work for me. :) And I don't know why. Here is a video: https://www.dropbox.com/s/cu7gbly764qj07v/phive.mp4?dl=0

Using Phive 0.13.0 doesn't throw the error but keeps giving me trouble with the keys. Can't we completely ignore the key-check? Do I miss something on my system? I have Open SSL installed but not pgp. Is it needed as well to make thsi work?

λ php .\phive-0.13.0.phar install
Phive 0.13.0 - Copyright (C) 2015-2019 by Arne Blankerts, Sebastian Heuer and Contributors
Downloading https://phar.phpunit.de/phpunit-6.5.14.phar
Downloading https://phar.phpunit.de/phpunit-6.5.14.phar.asc
Downloading key 4AA394086372C20A
Trying to connect to keys.openpgp.org (37.218.245.50)
Downloading https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x4AA394086372C20A
Successfully downloaded key.
[WARNING]  Parsing key data failed with error code 2: unlink(C:\Users\Florian\.phive\_tmp_wrk\pubring.kbx): No such file or directory
Trying to connect to keys.fedoraproject.org (140.211.169.207)
Downloading https://keys.fedoraproject.org/pks/lookup?op=get&options=mr&search=0x4AA394086372C20A
Successfully downloaded key.
[WARNING]  Parsing key data failed with error code 2: unlink(C:\Users\Florian\.phive\_tmp_wrk\pubring.kbx): No such file or directory
Trying to connect to keyserver.ubuntu.com (162.213.33.8)
Successfully downloaded key.
[WARNING]  Parsing key data failed with error code 2: unlink(C:\Users\Florian\.phive\_tmp_wrk\pubring.kbx): No such file or directory
Trying to connect to hkps.pool.sks-keyservers.net (209.244.105.201)
Downloading https://hkps.pool.sks-keyservers.net/pks/lookup?op=get&options=mr&search=0x4AA394086372C20A
Successfully downloaded key.
[WARNING]  Parsing key data failed with error code 2: unlink(C:\Users\Florian\.phive\_tmp_wrk\pubring.kbx): No such file or directory
[ERROR]    PublicKey 4AA394086372C20A not found on key servers

@theseer
Copy link
Member

theseer commented Dec 7, 2019

Using Phive 0.13.0 doesn't throw the error but keeps giving me trouble with the keys.

Version 0.13.0 won't work (anymore) as it doesn't support the output of keys.openpgp.org - which differs in for PHIVE incompatible ways from the sks output - and has had issuss with the different output formats from GnuPG 1.x and 2.x. It doesn't even get to the point where your problem is, though.

Can't we completely ignore the key-check?

No, that would about kill the point of using phive ;)

Do I miss something on my system? I have Open SSL installed but not pgp. Is it needed as well to make thsi work?

You do need a GNUpg installation, otherwise the gpg key can not be imported and the signature can not be verified. I don't know of any Linux/Unix OS that doesn't come with it. We might have to enhance the check on windows.

I do not really have a windows installation - only a Win10-VM that I every now and then boot up to verify a problem. I have no idea how people can work with windows, imho it's unusable, but I guess I can try to make a new VM without GnuPG installed.

@burzum
Copy link
Author

burzum commented Dec 7, 2019

@theseer I've installed https://www.gpg4win.org/ this one but this didn't change anything. If Phive would tell me that it can't find the program when I run it would be a nice to identify the problem early.

@theseer
Copy link
Member

theseer commented Dec 7, 2019

That's not the problem, actually. I probably should have been more specific in my previous reply: Yes, you do need gnupg but the fact you can see the key information (fingerprint, email addresses and creation date) means you do have a working gnupg installation that phive found.

The problem we have is that seemingly reading from STDIN (via fgets()) doesn't work on your machine. At least that's what the boolean false returned from fgets() is telling us.

It still puzzles me how that should be possible - particularly in an interactive shell.

What you can try as a workaround to not have phive ask is to supply the keyid via CLI: phive install --trust-gpg-keys 0x4AA394086372C20A.

@theseer
Copy link
Member

theseer commented Dec 7, 2019

We might have to enhance the check on windows.

We already have a check in place and it will complain if it can't find gnupg.

@theseer
Copy link
Member

theseer commented Dec 7, 2019

Okay, that seems to be a PHP 7.4 related issue on Windows.
Trying PHP 7.3 and 7.2 works like charm, PHP 7.4 fails with the above error.

I consider that a bug in PHP 7.4. Will talk to php internals :)

@rask
Copy link

rask commented Dec 9, 2019

I received the same error as OP when running Phive inside Gitlab CI using DIND (Docker-in-Docker) and PHP 7.3. I fixed the issue by passing in --trust-gpg-keys which skips the prompt.

EDIT: Inside DIND the script runs on a customized CentOS.

@theseer
Copy link
Member

theseer commented Dec 9, 2019

That means on top of an issue with PHP 7.4 on Windows our interactive shell detection has room for improvement ;)

@burzum
Copy link
Author

burzum commented Dec 9, 2019

@theseer did you already create a ticket on php.net? I checked the tracker but haven't seen anything that seems to be related to this issue.

@theseer
Copy link
Member

theseer commented Dec 11, 2019

No, didn't have time yet. Will do asap.

@MacFJA
Copy link
Contributor

MacFJA commented Apr 19, 2020

No, didn't have time yet. Will do asap.

Found the issue on PHP.net : https://bugs.php.net/bug.php?id=78883
Fix with php/php-src#4961, in PHP 7.4.1RC1

@theseer
Copy link
Member

theseer commented Apr 19, 2020

Thanks @MacFJA.

I'll keep this issue open anyhow as I think we should handle a potential false return value better.

I'm currently quite busy with other things but I'll try to get a new release out early upcoming week.

MacFJA added a commit to MacFJA/phive that referenced this issue Apr 19, 2020
- Add protection for non-interactive shell (or any error from fgets)
MacFJA added a commit to MacFJA/phive that referenced this issue Apr 19, 2020
- Add protection for non-interactive shell (or any error from fgets)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants