beyondcode / herd-community

88 stars 1 forks source link

[Bug]: `herd coverage` not working on Windows #1007

Closed adevade closed 1 month ago

adevade commented 1 month ago

Platform

Windows

Operating system version

Windows 11 Home (23H2 22631.4169)

System architecture

Windows

Herd Version

1.10.0 PRO

PHP Version

PHP 8.3.11

Bug description

I'm trying to run pest to test my application, and wanted to try out coverage and the new mutation testing, but I can't get it working with Herd.

Running herd coverage vendor/bin/pest seems to fail the loading of the SQLite driver. It works as expected if I run herd php vendor/bin/pest...

Am I doing anything obviously wrong? Please let me know what more information I can provide to help with troubleshooting.


PS: I noticed that if I right click and select "Open php.ini directory" in Herd, it opens to an empty folder (sometimes) containing another empty folder called "debug".

Steps to reproduce

No response

Relevant log output

herd php vendor/bin/pest --bail

  PASS  Tests\Feature\Actions\UpdateOrCreateProductTest
  ✓ it can import a product
  ✓ it can update an existing product

  Tests: 2 passed

-------------------------

herd debug vendor/bin/pest --bail

  PASS  Tests\Feature\Actions\UpdateOrCreateProductTest
  ✓ it can import a product
  ✓ it can update an existing product

  Tests: 2 passed

-------------------------

herd coverage vendor/bin/pest --bail

   FAIL  Tests\Feature\Actions\UpdateOrCreateProductTest
  ⨯ it can import a product
  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   FAILED  Tests\Feature\Actions\UpdateOrCreateProductTest > it can import a product                   QueryException
  could not find driver (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)

  at vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:66
     62▕      */
     63▕     protected function createPdoConnection($dsn, $username, $password, $options)
     64▕     {
     65▕         return version_compare(phpversion(), '8.4.0', '<')
  ➜  66▕             ? new PDO($dsn, $username, $password, $options)
     67▕             : PDO::connect($dsn, $username, $password, $options); /** @phpstan-ignore staticMethod.notFound (PHP 8.4) */
     68▕     }
     69▕
     70▕     /**

  1   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:66
  2   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:44

  Tests:    1 failed
adevade commented 1 month ago

Here's some more info from running the different commands:

❯ herd php -v                                                     
PHP 8.3.11 (cli) (built: Aug 27 2024 21:28:35) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies

❯ herd debug -v
PHP 8.3.11 (cli) (built: Aug 27 2024 21:28:35) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies

❯ herd coverage -v
PHP 8.3.11 (cli) (built: Aug 27 2024 21:28:35) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
mpociot commented 1 month ago

herd debug and herd coverage load an additional debug.ini file You can see this when you're running php --ini

This file automatically gets populated when you have Herd Pro.

Can you verify that this file exists for you?

You should see a difference between php --ini and herd coverage --ini

adevade commented 1 month ago

@mpociot Here's the output for all commands:

❯ herd php --ini    
Configuration File (php.ini) Path: 
Loaded Configuration File:         C:\Users\adevade\.config\herd\bin\php83\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

❯ herd debug --ini
Configuration File (php.ini) Path: 
Loaded Configuration File:         (none)
Scan for additional .ini files in: C:\Users\adevade\.config\herd\bin\php83
Additional .ini files parsed:      C:\Users\adevade\.config\herd\bin\php83\php.ini

❯ herd coverage --ini
Configuration File (php.ini) Path: 
Loaded Configuration File:         (none)
Scan for additional .ini files in: "C:\Users\adevade\.config\herd\bin\php83
Additional .ini files parsed:      (none)

I see a leading double quote on the herd coverage command, but no closing one. The output above is directly from the terminal.


EDIT: There does not exist a file called debug.ini in C:\Users\adevade\.config\herd\bin\php83


EDIT 2: There's no files in C:\Users\adevade\.config\herd\config\php\83\debug either.

mpociot commented 1 month ago

@adevade Do you see "Debug" PHP CGI processes in Herd? Maybe try restarting Herd - the debug.ini file gets created when those processes are started for the first time.

adevade commented 1 month ago

@mpociot Sometimes there's a PHP 8.3 (Debug) in Herd Dashboard.

I actually tried a full reinstall today without any success unfortunately.

adevade commented 1 month ago

I get the same output on another Windows machine I use for work:

❯ herd php --ini
Configuration File (php.ini) Path:
Loaded Configuration File:         C:\Users\username\.config\herd\bin\php83\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

❯ herd debug --ini
Configuration File (php.ini) Path:
Loaded Configuration File:         (none)
Scan for additional .ini files in: C:\Users\username\.config\herd\bin\php83
Additional .ini files parsed:      C:\Users\username\.config\herd\bin\php83\php.ini

❯ herd coverage --ini
Configuration File (php.ini) Path:
Loaded Configuration File:         (none)
Scan for additional .ini files in: "C:\Users\username\.config\herd\bin\php83
Additional .ini files parsed:      (none)
mpociot commented 1 month ago

@adevade can you share a screenshot of your Herd "dashboard"? You should see these Debug services.

image

adevade commented 1 month ago

@mpociot At the moment I do see them, but I'm pretty sure they're not always there.

image

mpociot commented 1 month ago

@adevade do you have a minute to look into this via screensharing? When the debug service starts, we create the debug.ini file. So it is really weird that it doesn't exist for you.

Feel free to join here if you have a minute :)

https://meet.google.com/hrk-xunh-rdg

adevade commented 1 month ago

@mpociot Unfortunately I'm at work, and can't connect right now. I'm available Thursday and Friday, if that works for you?

Would love to see this fixed, and curious as to what could be causing it!

mpociot commented 1 month ago

@adevade no worries! Could you share your log file with me?

You can find it here: %USERPROFILE%\AppData\Roaming\Herd\logs\main.log

Maybe this already helps to figure out whats going on.

You can schedule a meeting here: https://cal.com/marcel-pociot/15min

adevade commented 1 month ago

@mpociot https://pastebin.com/usKmTUJg

mpociot commented 1 month ago

Thanks! What's interesting is that this entry exists multiple times:

Copying Debug php.ini...
...
[PHP-Debug] INI File: C:\Users\andreas.lundgren\.config\herd\config\php\83\debug\debug.ini

Hm can you verify that these files exist for you? Maybe they were deleted by some kind of antivirus tool:

C:\Program Files\Herd\resources\app.asar.unpacked\resources\bin\xdebug\

There should be a number of DLL files, each for a specific PHP version.

adevade commented 1 month ago

@mpociot

This is an empty folder on my machine: C:\Users\andreas.lundgren\.config\herd\config\php\83\debug

All DLL files exist in the following folder: C:\Program Files\Herd\resources\app.asar.unpacked\resources\bin\xdebug\


As I mentioned I see the same issue on both my private and work machine. On my private laptop I don't have any antivirus other than Windows Defender, but I've added .config/herd to the ignore list without any success.

If I remove the empty debug folder, and restart Herd services it creates the folder again but it's still empty.

mpociot commented 1 month ago

Ugh man...I found the issue in our codebase, and it'll be fixed in the next update! Sorry about that.

mpociot commented 1 month ago

This is now fixed in Herd 1.11.1

adevade commented 1 month ago

@mpociot I'm happy to report that herd debug seems to work as expected after the update (aside from some xdebug timeouts in console). However, herd coverage still isn't working for me... At least it seems to not be loading the SQLite extension. Seems to not be loading the default .ini at all.

Here's some usage output to try to isolate the issue:

❯ herd php vendor/bin/pest --compact --bail

  Tests:    2 passed (6 assertions)
  Duration: 0.49s

❯ herd debug vendor/bin/pest --compact --bail
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).

  Tests:    2 passed (6 assertions)
  Duration: 1.08s

Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).

❯ herd coverage vendor/bin/pest --compact --bail
 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Feature\Actions\UpdateOrCreateProductTest > it can import a product                                                                                                                                  QueryException   
  could not find driver (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)

  at vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:66
     62▕      */
     63▕     protected function createPdoConnection($dsn, $username, $password, $options)
     64▕     {
     65▕         return version_compare(phpversion(), '8.4.0', '<')
  ➜  66▕             ? new PDO($dsn, $username, $password, $options)
     67▕             : PDO::connect($dsn, $username, $password, $options); /** @phpstan-ignore staticMethod.notFound (PHP 8.4) */
     68▕     }
     69▕
     70▕     /**

  1   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:66
  2   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:44

  Tests:    1 failed, 1 pending (0 assertions)
  Duration: 0.34s

Here's php --ini for all commands: (Please note the leading double quote I mentioned previously on the path for herd coverage. It's not present for herd debug.)

❯ herd php --ini
Configuration File (php.ini) Path: 
Loaded Configuration File:         C:\Users\adeva\.config\herd\bin\php83\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

❯ herd debug --ini
Configuration File (php.ini) Path: 
Loaded Configuration File:         C:\Users\adeva\.config\herd\config\php\83\debug\debug.ini
Scan for additional .ini files in: C:\Users\adeva\.config\herd\bin\php83
Additional .ini files parsed:      C:\Users\adeva\.config\herd\bin\php83\php.ini

❯ herd coverage --ini
Configuration File (php.ini) Path: 
Loaded Configuration File:         C:\Users\adeva\.config\herd\config\php\83\debug\debug.ini
Scan for additional .ini files in: "C:\Users\adeva\.config\herd\bin\php83
Additional .ini files parsed:      (none)

Sidenote: Both debug and coverage loads debug.ini as the main config, and then scans the additional folder for more files. Shouldn't all commands load the default .ini and the debug commands search for additional files?