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

wmic is not recognized as an internal or external command on a clean install of Windows 11 24H2 #696

Open
hdcore opened this issue Oct 12, 2024 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@hdcore
Copy link
Contributor

hdcore commented Oct 12, 2024

Q A
Bug report? yes
Feature request? no
Library version 2.11.0 who is reporting itself as 2.10
PHP version 8.3.10
Windows version 24H2 clean install (no upgrade)

I've installed my computer with a clean install of the most recent Windows 24H2 installation media.
The error I've got is:

phpinsights analyse --no-interaction --ansi
'wmic' is not recognized as an internal or external command,
operable program or batch file.
'wmic' is not recognized as an internal or external command,
operable program or batch file.
'wmic' is not recognized as an internal or external command,
operable program or batch file.
'wmic' is not recognized as an internal or external command,
operable program or batch file.
'wmic' is not recognized as an internal or external command,
operable program or batch file.

Fatal error: Uncaught DivisionByZeroError: Division by zero in C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Runner.php:115
Stack trace:
#0 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightFactory.php(98): NunoMaduro\PhpInsights\Domain\Runner->run()
#1 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightFactory.php(69): NunoMaduro\PhpInsights\Domain\Insights\InsightFactory->runInsightCollector()
#2 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightCollectionFactory.php(67): NunoMaduro\PhpInsights\Domain\Insights\InsightFactory->makeFrom()
#3 [internal function]: NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory::NunoMaduro\PhpInsights\Domain\Insights{closure}()
#4 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightCollectionFactory.php(66): array_map()
#5 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Application\Console\Analyser.php(36): NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory->get()
#6 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Application\Console\Commands\AnalyseCommand.php(65): NunoMaduro\PhpInsights\Application\Console\Analyser->analyse()
#7 [internal function]: NunoMaduro\PhpInsights\Application\Console\Commands\AnalyseCommand->__invoke()
#8 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Application\Console\Commands\InvokableCommand.php(41): call_user_func()
#9 C:\WAMP\APPS\php-qa\vendor\symfony\console\Command\Command.php(279): NunoMaduro\PhpInsights\Application\Console\Commands\InvokableCommand->execute()
#10 C:\WAMP\APPS\php-qa\vendor\symfony\console\Application.php(1029): Symfony\Component\Console\Command\Command->run()
#11 C:\WAMP\APPS\php-qa\vendor\symfony\console\Application.php(316): Symfony\Component\Console\Application->doRunCommand()
#12 C:\WAMP\APPS\php-qa\vendor\symfony\console\Application.php(167): Symfony\Component\Console\Application->doRun()
#13 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\bin\phpinsights(42): Symfony\Component\Console\Application->run()
#14 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\bin\phpinsights(43): {closure}()
#15 C:\WAMP\APPS\php-qa\vendor\bin\phpinsights(119): include('...')
#16 {main}
thrown in C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Runner.php on line 115
PHP Fatal error: Uncaught DivisionByZeroError: Division by zero in C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Runner.php:115
Stack trace:
#0 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightFactory.php(98): NunoMaduro\PhpInsights\Domain\Runner->run()
#1 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightFactory.php(69): NunoMaduro\PhpInsights\Domain\Insights\InsightFactory->runInsightCollector()
#2 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightCollectionFactory.php(67): NunoMaduro\PhpInsights\Domain\Insights\InsightFactory->makeFrom()
#3 [internal function]: NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory::NunoMaduro\PhpInsights\Domain\Insights{closure}()
#4 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightCollectionFactory.php(66): array_map()
#5 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Application\Console\Analyser.php(36): NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory->get()
#6 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Application\Console\Commands\AnalyseCommand.php(65): NunoMaduro\PhpInsights\Application\Console\Analyser->analyse()
#7 [internal function]: NunoMaduro\PhpInsights\Application\Console\Commands\AnalyseCommand->__invoke()
#8 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Application\Console\Commands\InvokableCommand.php(41): call_user_func()
#9 C:\WAMP\APPS\php-qa\vendor\symfony\console\Command\Command.php(279): NunoMaduro\PhpInsights\Application\Console\Commands\InvokableCommand->execute()
#10 C:\WAMP\APPS\php-qa\vendor\symfony\console\Application.php(1029): Symfony\Component\Console\Command\Command->run()
#11 C:\WAMP\APPS\php-qa\vendor\symfony\console\Application.php(316): Symfony\Component\Console\Application->doRunCommand()
#12 C:\WAMP\APPS\php-qa\vendor\symfony\console\Application.php(167): Symfony\Component\Console\Application->doRun()
#13 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\bin\phpinsights(42): Symfony\Component\Console\Application->run()
#14 C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\bin\phpinsights(43): {closure}()
#15 C:\WAMP\APPS\php-qa\vendor\bin\phpinsights(119): include('...')
#16 {main}
thrown in C:\WAMP\APPS\php-qa\vendor\nunomaduro\phpinsights\src\Domain\Runner.php on line 115
Script phpinsights analyse --no-interaction --ansi handling the phpinsights event returned with error code 255

Starting from Windows 24H2 the wmic command will not be installed by default.
https://techcommunity.microsoft.com/t5/windows-it-pro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/ba-p/4039242 . As a workaround I could install the feature manually https://techcommunity.microsoft.com/t5/windows-it-pro-blog/how-to-install-wmic-feature-on-demand-on-windows-11/ba-p/4189530 but this is not a future proof solution.

Can you replace the wmic command by another method or library?

@Jibbarth
Copy link
Collaborator

Hello,

A solution could be to use the https://github.com/theofidry/cpu-core-counter lib instead of our own implementation, but I can see it use wmic also, so I'm not sure.

However, you can fix the number to threads in your phpinsights.php config file

    /*
    |--------------------------------------------------------------------------
    | Threads
    |--------------------------------------------------------------------------
    |
    | Here you may adjust how many threads (core) PHPInsights can use to perform
    | the analysis. This is optional, don't provide it and the tool will guess
    | the max core number available. It accepts null value or integer > 0.
    |
    */

    'threads' => 2, // For example

@Jibbarth Jibbarth added bug Something isn't working help wanted Extra attention is needed labels Oct 13, 2024
@hdcore
Copy link
Contributor Author

hdcore commented Oct 13, 2024

The workaround with the number of threads works for now.

It looks that cpu-core-counter lib has three methods for windows to detect the cpu number count (cmi/powershell, registry and wmic)
https://github.com/theofidry/cpu-core-counter/blob/main/src/Finder/FinderRegistry.php#L52

@hdcore
Copy link
Contributor Author

hdcore commented Oct 13, 2024

See also theofidry/cpu-core-counter#55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants