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

Cannot get v1.1.7 to work on Windows #5

Closed
Balkoth opened this issue Apr 20, 2022 · 16 comments
Closed

Cannot get v1.1.7 to work on Windows #5

Balkoth opened this issue Apr 20, 2022 · 16 comments

Comments

@Balkoth
Copy link

Balkoth commented Apr 20, 2022

This is the phpstan-vscode output:

Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin","args":["analyse","-c","C:\\Temp\\global.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\functions.php"],"cwd":"c:\\Temp"}
PHPStan process exited with error, data= 
Hiding status bar, last operation result = Error
File check failed for file c:\Temp\functions.php

Running PHPStan manually from the command line works fine.

@SanderRonde
Copy link
Owner

Hmm weird that it's going for that temporary director. Can you do a few things for me?

  • Check if C:/Temp actually exists
  • What windows version are you on?
  • Can you run node -e "console.log(require('os').tmpdir())" in a terminal for me and tell me what it outputs? This should print your temp dir (which should be C:/Temp probably

@Balkoth
Copy link
Author

Balkoth commented Apr 26, 2022

  • The folder C:\Temp is actually existing.

  • Windows Version 2004 19041.1415

  • The command points to:
    ❯ node -e "console.log(require('os').tmpdir())"
    C:\Users\{user}\AppData\Local\Temp

@SanderRonde
Copy link
Owner

Ah I completely misunderstood the issue. I thought something was going wrong with the extension creating a temporary file but it was actually just you using it on a workspace located at C:/Temp. I think I know what the issue is and I've fixed it in version 1.2.0 (which I just published). Can you let me know if that fixed it?

@Balkoth
Copy link
Author

Balkoth commented May 6, 2022

Will check and get back to you next week.

@Balkoth
Copy link
Author

Balkoth commented May 9, 2022

Now it does not error out, but does not show problems either.

@SanderRonde
Copy link
Owner

When you open the output panel for PHPStan, what is logged there? Does the errors= log contain any errors or does it not log any either?

@Balkoth
Copy link
Author

Balkoth commented May 9, 2022

There is nothing after errors= in a file which has problems shown when used with PHP Static Analysis and the same configuration file.

@SanderRonde
Copy link
Owner

Just checking but can you run the PHPStan binary with the args that are posted in the logs? Does PHPStan output any errors then?

@Balkoth
Copy link
Author

Balkoth commented May 9, 2022

Test file:

<?php

function test($param)
{
  if (!$result)
    return 'ERROR';

  return 'OK';
}

?>

phpstan-vscode:

Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin","args":["analyse","-c","C:\\Temp\\PHPStan-vsc\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 
Active editor changed, checking

Running PHPStan binary from cmd:

"C:\Program Files\Composer\vendor\bin\phpstan.bat" analyse -c "C:\Temp\PHPStan-vsc\phpstan.neon" --error-format=raw --no-progress --no-interaction --memory-limit=1G "C:\Temp\PHPStan-vsc\functions.php"
C:\Temp\PHPStan-vsc\functions.php:3:Function test() has no return type specified.
C:\Temp\PHPStan-vsc\functions.php:3:Function test() has parameter $param with no type specified.
C:\Temp\PHPStan-vsc\functions.php:5:Undefined variable: $result

@SanderRonde
Copy link
Owner

Thanks for the info! Looks like the binPath setting is not correct. It's currently pointing to the binary folder, not the actual binary to run. Can you check if it works when you change it to be the full C:\Program Files\Composer\vendor\bin\phpstan.bat (or C:\Program Files\Composer\vendor\bin\phpstan, not sure what's right on Windows)?

@Balkoth
Copy link
Author

Balkoth commented May 9, 2022

Does not matter:

Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin\\phpstan.bat","args":["analyse","-c","C:\\Work\\Config\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 
Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin\\phpstan","args":["analyse","-c","C:\\Work\\Config\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 

@SanderRonde
Copy link
Owner

Hmm I'm getting no issues when trying out that configuration (as far as I can replicate it). Can you send me these things:

  • The whole folder you're running PHPStan on (including the .neon file). Probably easiest to zip it up.
  • Your PHPStan extension configuration

@Balkoth
Copy link
Author

Balkoth commented May 10, 2022

As requested:
PHPStan-vsc.zip

"phpstan.binPath": "C:\\Program Files\\Composer\\vendor\\bin\\phpstan.bat",
"phpstan.configFile": "C:\\Temp\\PHPStan-vsc\\phpstan.neon"

image

@SanderRonde
Copy link
Owner

I tried your exact setup but it worked fine for me so I'm really not sure what's going on here. Can you try installing this version of the extension and showing me the new logs? It's got some more logging in it. Simply rename it from .zip to .vsix and drag it into your extensions pane (github doesn't allow uploading of .vsix files).
phpstan-vscode-1.2.1.zip

@Balkoth
Copy link
Author

Balkoth commented May 18, 2022

Yes, this version helped identifying the issue:

Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin\\phpstan.bat","args":["analyse","-c","C:\\Temp\\PHPStan-vsc\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
Got data Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

All data received= Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 
Got data Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

So there is an issue when binPath contains spaces. If i change this to a path with no spaces it works!

@SanderRonde
Copy link
Owner

Ah classic error. Will fix it in a bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants