olivernybroe / phpinsights-intellij

The IntelliJ integration of phpinsights
MIT License
18 stars 2 forks source link

com.intellij.execution.process.ProcessNotCreatedException #4

Closed ghost closed 4 years ago

ghost commented 5 years ago

I just noticed the tweet about the extension for phpstorm. I installed it and get the following error message. com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "{path to the project}\vendor\bin\phpinsights": CreateProcess error=193, %1 is not a valid Win32 application

After I reinstalled phpstorm completely, I get this one. com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "{path to the project}\vendor\bin\phpinsights.bat": CreateProcess error=2, The system cannot find the file specified

It's on Windows 10 1903.

olivernybroe commented 5 years ago

Thanks for reporting the issue.

This seems like a Windows specific issue, as I don't have Windows you will have to try it out yourself. But try adding a phpinsights.bat file and add the following inside of it and it in the folder it says. If it works, we might have to make a PR with the bat file to phpinsights.

if "%PHP_PEAR_PHP_BIN%" neq "" (
    set PHPBIN=%PHP_PEAR_PHP_BIN%
) else set PHPBIN=php

"%PHPBIN%" "%~dp0\ phpinsights" %*
ghost commented 5 years ago

After I added a phpinsights.bat file with your code, I restarted phpstorm.

Now I get this message.

java.lang.NullPointerException
    at com.phpinsights.phpinsights.PhpInsightsMessageProcessor.parseLine(PhpInsightsMessageProcessor.java:31)
    at com.jetbrains.php.tools.quality.QualityToolOutputProcessor.notifyTextAvailable(QualityToolOutputProcessor.java:26)
    at com.jetbrains.php.tools.quality.QualityToolProcessHandler.notifyTextAvailable(QualityToolProcessHandler.java:24)
    at com.intellij.execution.process.BaseOSProcessHandler$SimpleOutputReader.onTextAvailable(BaseOSProcessHandler.java:179)
    at com.intellij.util.io.BaseOutputReader.sendText(BaseOutputReader.java:211)
    at com.intellij.util.io.BaseOutputReader.processInput(BaseOutputReader.java:195)
    at com.intellij.util.io.BaseOutputReader.readAvailableNonBlocking(BaseOutputReader.java:114)
    at com.intellij.util.io.BaseDataReader.readAvailable(BaseDataReader.java:77)
    at com.intellij.util.io.BaseDataReader.doRun(BaseDataReader.java:155)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:208)
    at com.intellij.util.io.BaseDataReader.lambda$start$0(BaseDataReader.java:61)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
olivernybroe commented 5 years ago

hmm, try removing the space at this line, that was a mistake "%PHPBIN%" "%~dp0\ phpinsights" %*. So that line should say "%PHPBIN%" "%~dp0\phpinsights" %*

ghost commented 5 years ago

No different behavior on this error message. PHP Insights '"php"' is not recognized as an internal or external command, operable program or batch file.

java.lang.NullPointerException
    at com.phpinsights.phpinsights.PhpInsightsMessageProcessor.parseLine(PhpInsightsMessageProcessor.java:31)
    at com.jetbrains.php.tools.quality.QualityToolOutputProcessor.notifyTextAvailable(QualityToolOutputProcessor.java:26)
    at com.jetbrains.php.tools.quality.QualityToolProcessHandler.notifyTextAvailable(QualityToolProcessHandler.java:24)
    at com.intellij.execution.process.BaseOSProcessHandler$SimpleOutputReader.onTextAvailable(BaseOSProcessHandler.java:179)
    at com.intellij.util.io.BaseOutputReader.sendText(BaseOutputReader.java:211)
    at com.intellij.util.io.BaseOutputReader.processInput(BaseOutputReader.java:195)
    at com.intellij.util.io.BaseOutputReader.readAvailableNonBlocking(BaseOutputReader.java:114)
    at com.intellij.util.io.BaseDataReader.readAvailable(BaseDataReader.java:77)
    at com.intellij.util.io.BaseDataReader.doRun(BaseDataReader.java:155)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:208)
    at com.intellij.util.io.BaseDataReader.lambda$start$0(BaseDataReader.java:61)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
olivernybroe commented 5 years ago

How do you normally run phpinsight on windows? Do you do php phpinsight, phpinsight or something else?

ghost commented 5 years ago

Normally I run phpinsights in Git Bash or within PhpStorm on Windows. Either I use php artisan insights -v or php artisan insights -v --format=json > phpinsights.json as command. But at the last one it will be included into an own web based tool.

olivernybroe commented 5 years ago

Hmm, Okay.

In the plugin we run the bin file in composer bin called phpinsights. This is the same way phpstorm does it when using phpcs or phpmd. Both of them works by running the bin file directly without prepending php, and when it is on windows, they run the .bat file edition of it instead. However phpinsights do not have a bat file to run it, so we need to create a bat file which works for phpinsights and pr it to the bin folder of the package.

Here are the bat files from phpmd and phpcs.

I also added a issue on phpinsights package about this https://github.com/nunomaduro/phpinsights/issues/266.

olivernybroe commented 5 years ago

@FFDevelopment Do you have an auto generated .bat file in your bin folder from composer? https://github.com/composer/composer/issues/7370