spatie / laravel-ray

Debug with Ray to fix problems faster in Laravel apps
https://myray.app
MIT License
291 stars 64 forks source link

`composer install` fails using Docker #234

Closed MatanYadaev closed 2 years ago

MatanYadaev commented 2 years ago

Describe the bug Using Laravel Sail, when spatie/laravel-ray is in the dependencies, composer install command fails. More specifically, the php artisan package:discover command fails.

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Doctrine\DBAL\Driver\PDO\Exception 

  could not find driver

  at vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18
     14▕ final class Exception extends PDOException
     15▕ {
     16▕     public static function new(\PDOException $exception): self
     17▕     {
  ➜  18▕         return new self($exception);
     19▕     }
     20▕ }
     21▕

      +1 vendor frames 
  2   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Spatie\LaravelRay\RayServiceProvider))

      +30 vendor frames 
  33  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Spatie\LaravelRay\RayServiceProvider))
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Versions

To Reproduce Steps to reproduce the behavior:

  1. Create new Laravel app curl -s "https://laravel.build/example-app?with=mysql,redis" | bash
  2. Add "spatie/laravel-ray": "^1.9" to the composer.json
  3. Install Composer dependencies inside a Docker container (this container doesn't have an access to MySQL or Redis)
    docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

Desktop:

MatanYadaev commented 2 years ago

The issue isn't fixed by setting up the env variable RAY_ENABLED to false, but it does get fixed when I comment out QueryWatcher and DuplicateQueryWatcher from the $watchers array in the source code.

yahya077 commented 2 years ago

I run into the same issue after commenting out the QueryWatcher and DuplicateQueryWatcher from the $watchers, it does work. I guess need a new version.

patinthehat commented 2 years ago

@MatanYadaev or @yahya077 Do you have a small sample repository that replicates this issue exactly? It'd help me track down the source of the issue more quickly.

MatanYadaev commented 2 years ago

@patinthehat The reproduction guide that I mentioned doesn't work? It works to me

yahya077 commented 2 years ago

I don't directly using ray. It is requirements of Spatie packages.


#15 spatie/laravel-ray/src/Watchers/QueryWatcher.php(46): Illuminate\\Support\\Facades\\Facade::__callStatic('listen', Array)
#16 spatie/laravel-ray/src/RayServiceProvider.php(167): Spatie\\LaravelRay\\Watchers\\QueryWatcher->register()
EnumeratesValues.php(242): Spatie\\LaravelRay\\RayServiceProvider->Spatie\\LaravelRay\\{closure}('Spatie\\\\LaravelR...', 6)

End of the error down below; test.ERROR: could not find driver {"exception":"[object] (Doctrine\\DBAL\\Driver\\PDO\\Exception

yahya077 commented 2 years ago

This issue might has been fixed. The issue no longer exist for me.

timmaier commented 2 years ago

I know this issue is closed but just want to highlight I also get this error when reinstalling my docker instance using laravel sail

spatie/laravel-ray: 1.29.4


> @php artisan package:discover --ansi

   PDOException 

  could not find driver

  at vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
     66▕         if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
     67▕             return new PDOConnection($dsn, $username, $password, $options);
     68▕         }
     69▕ 
  ➜  70▕         return new PDO($dsn, $username, $password, $options);
     71▕     }
     72▕ 
     73▕     /**
     74▕      * Determine if the connection is persistent.

      +29 vendor frames 
  30  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Spatie\LaravelRay\RayServiceProvider))

      +5 vendor frames 
  36  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1```