php / pie

The PHP Installer for Extensions
BSD 3-Clause "New" or "Revised" License
314 stars 11 forks source link

Interactive GitHub OAuth token request fails #89

Open TimWolla opened 2 days ago

TimWolla commented 2 days ago

Using #83:

I was attempting to download a package from a custom GitHub VCS in a fresh Docker container without any composer credentials set up. The GitHub API requests were rejected by GitHub's API, with PIE emitting an informational message that credentials were required. However it crashed while actually requesting the credentials:

root@26098011df0d:/pwd# php bin/pie download -v redacted/redacted:dev-pie
You are running PHP 8.3.13
Target PHP installation: 8.3.13 nts, on Linux/OSX/etc x86_64 (from /usr/local/bin/php)
Reading composer.json of https://github.com/redacted/redacted.git (v0.2.0)GitHub API limit (60 calls/hr) is exhausted, could not fetch https://api.github.com/repos/redacted/redacted/contents/composer.json?ref=redacted. Create a GitHub OAuth token to go over the API rate limit. You can also wait until 2024-11-14 13:45:56 for the rate limit to reset.
When working with _public_ GitHub repositories only, head here to retrieve a token:
https://github.com/settings/tokens/new?scopes=&description=Composer+on+26098011df0d+2024-11-14+1246
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to:
https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+26098011df0d+2024-11-14+1246
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/root/.composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
Reading composer.json of https://github.com/redacted/redacted.git (v0.1.0)GitHub API limit (60 calls/hr) is exhausted, could not fetch https://api.github.com/repos/redacted/redacted/contents/composer.json?ref=redacted. Create a GitHub OAuth token to go over the API rate limit. You can also wait until 2024-11-14 13:45:56 for the rate limit to reset.
When working with _public_ GitHub repositories only, head here to retrieve a token:
https://github.com/settings/tokens/new?scopes=&description=Composer+on+26098011df0d+2024-11-14+1246
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to:
https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+26098011df0d+2024-11-14+1246
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/root/.composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
GitHub API limit (60 calls/hr) is exhausted, could not fetch https://api.github.com/repos/redacted/redacted/git/refs/heads?per_page=100. Create a GitHub OAuth token to go over the API rate limit. You can also wait until 2024-11-14 13:45:56 for the rate limit to reset.
When working with _public_ GitHub repositories only, head here to retrieve a token:
https://github.com/settings/tokens/new?scopes=&description=Composer+on+26098011df0d+2024-11-14+1246
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to:
https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+26098011df0d+2024-11-14+1246
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/root/.composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
In HelperSet.php line 67:

  [Symfony\Component\Console\Exception\InvalidArgumentException]  
  The helper "question" is not defined.                           

Exception trace:
  at /pwd/vendor/symfony/console/Helper/HelperSet.php:67
 Symfony\Component\Console\Helper\HelperSet->get() at /pwd/vendor/composer/composer/src/Composer/IO/ConsoleIO.php:292
 Composer\IO\ConsoleIO->askAndHideAnswer() at /pwd/vendor/composer/composer/src/Composer/Util/GitHub.php:112
 Composer\Util\GitHub->authorizeOAuthInteractively() at /pwd/vendor/composer/composer/src/Composer/Util/AuthHelper.php:130
 Composer\Util\AuthHelper->promptAuthIfNeeded() at /pwd/vendor/composer/composer/src/Composer/Util/Http/CurlDownloader.php:548
 Composer\Util\Http\CurlDownloader->isAuthenticatedRetryNeeded() at /pwd/vendor/composer/composer/src/Composer/Util/Http/CurlDownloader.php:414
 Composer\Util\Http\CurlDownloader->tick() at /pwd/vendor/composer/composer/src/Composer/Util/HttpDownloader.php:392
 Composer\Util\HttpDownloader->countActiveJobs() at /pwd/vendor/composer/composer/src/Composer/Util/HttpDownloader.php:363
 Composer\Util\HttpDownloader->wait() at /pwd/vendor/composer/composer/src/Composer/Util/HttpDownloader.php:114
 Composer\Util\HttpDownloader->get() at /pwd/vendor/composer/composer/src/Composer/Repository/Vcs/VcsDriver.php:170
 Composer\Repository\Vcs\VcsDriver->getContents() at /pwd/vendor/composer/composer/src/Composer/Repository/Vcs/GitHubDriver.php:448
 Composer\Repository\Vcs\GitHubDriver->getContents() at /pwd/vendor/composer/composer/src/Composer/Repository/Vcs/GitHubDriver.php:377
 Composer\Repository\Vcs\GitHubDriver->getBranches() at /pwd/vendor/composer/composer/src/Composer/Repository/VcsRepository.php:321
 Composer\Repository\VcsRepository->initialize() at /pwd/vendor/composer/composer/src/Composer/Repository/ArrayRepository.php:308
 Composer\Repository\ArrayRepository->getPackages() at /pwd/vendor/composer/composer/src/Composer/Repository/ArrayRepository.php:62
 Composer\Repository\ArrayRepository->loadPackages() at /pwd/vendor/composer/composer/src/Composer/Repository/RepositorySet.php:199
 Composer\Repository\RepositorySet->findPackages() at /pwd/vendor/composer/composer/src/Composer/Package/Version/VersionSelector.php:87
 Composer\Package\Version\VersionSelector->findBestCandidate() at /pwd/src/DependencyResolver/ResolveDependencyWithComposer.php:29
 Php\Pie\DependencyResolver\ResolveDependencyWithComposer->__invoke() at /pwd/src/Command/DownloadCommand.php:61
 Php\Pie\Command\DownloadCommand->execute() at /pwd/vendor/symfony/console/Command/Command.php:326
 Symfony\Component\Console\Command\Command->run() at /pwd/vendor/symfony/console/Application.php:1078
 Symfony\Component\Console\Application->doRunCommand() at /pwd/vendor/symfony/console/Application.php:324
 Symfony\Component\Console\Application->doRun() at /pwd/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /pwd/bin/pie:64
download [-j|--make-parallel-jobs MAKE-PARALLEL-JOBS] [--with-php-config WITH-PHP-CONFIG] [--with-php-path WITH-PHP-PATH] [--] <requested-package-and-version>

Also note that the formatting in the error messages is a bit off. A newline is missing before “GitHub API limit (60 calls/hr) is exhausted” and the message is also printed twice, because apparently it did not fail after the first failed API call.

asgrim commented 1 day ago

I believe this should just be a case of defining the helper set; it was left empty originally, but it would make sense to populate this properly.