NickDickinsonWilde / drupal-spec-tool-commands

Provides composer command functionality to automate populate/update gherkin files as defined with acquia/drupal-spec-tool
GNU General Public License v3.0
2 stars 7 forks source link

Error Call to undefined function GuzzleHttp\Psr7\uri_for() #1

Open longmtran opened 5 years ago

longmtran commented 5 years ago

Steps followed:

  1. composer require nickwilde1990/drupal-spec-tool-commands
  2. Add "drupal-spec-tools" section to composer.json
  3. Generate Google API key file and update spreadsheet ID in composer.json
  4. Run: composer drupal-spec-dump-gherkin but hit undefined function error:
Fatal error: Uncaught Error: Call to undefined function GuzzleHttp\Psr7\uri_for() in /private/var/www/example-site/vendor/google/auth/src/OAuth2.php:1284
Stack trace:
#0 /private/var/www/example-site/vendor/google/auth/src/OAuth2.php(681): Google\Auth\OAuth2->coerceUri('https://account...')
#1 /private/var/www/example-site/vendor/google/auth/src/OAuth2.php(334): Google\Auth\OAuth2->setAuthorizationUri('https://account...')
#2 /private/var/www/example-site/vendor/google/apiclient/src/Google/Client.php(952): Google\Auth\OAuth2->__construct(Array)
#3 /private/var/www/example-site/vendor/google/apiclient/src/Google/Client.php(932): Google_Client->createOAuth2Service()
#4 /private/var/www/example-site/vendor/google/apiclient/src/Google/Client.php(337): Google_Client->getOAuth2Service()
#5 /private/var/www/example-site/vendor/nickwilde1990/drupal-spec-tool-commands/src/GoogleSpreadsheetAccessTrait.php(38): Google_Client->createAuthUrl()
#6 /private/var/www/example-site/vendor/nickwilde1990/drupal-spec-tool-commands/src/Command/DrupalSpecGherkinDumper. in /private/var/www/example-site/vendor/google/auth/src/OAuth2.php on line 1284

This site is installed with Acquia BLT and Acquia Lightning profile.

ethanteague commented 5 years ago

Same issue as above. I did try pulling in google dependencies from your composer.json, and autoloading namespaces defined in your composer.json, but same result.

tgifford-webfirst commented 4 years ago

Composer version: 1.10.8 drupal-spec-tool-commands: v1.0.0-rc1

Not sure why autoloading isn't working, but it seems to only be a problem for functions outside classes. This terrible hackpatch gets it working:

--- vendor/nickwilde1990/drupal-spec-tool-commands/src/ComposerPlugin.php.bak   2020-07-10 23:54:26.411037775 -0400
+++ vendor/nickwilde1990/drupal-spec-tool-commands/src/ComposerPlugin.php   2020-07-10 23:54:20.678567881 -0400
@@ -25,6 +25,9 @@
    */
   public function activate(Composer $composer, IOInterface $io)
   {
+    include __DIR__ . '/../../../guzzlehttp/psr7/src/functions_include.php';
+    include __DIR__ . '/../../../guzzlehttp/guzzle/src/functions_include.php';
+    include __DIR__ . '/../../../guzzlehttp/promises/src/functions_include.php';
   }

   public function getCapabilities()
esod commented 3 years ago

Composer version 1.10.15 drupal-spec-tool-commands: v1.0.0-rc1

I confirm that @tgifford-webfirst's patch solved the same problem for me. Thanks.