AtomLinter / linter-phpcs

Linter plugin for PHP, using PHP_CodeSniffer.
63 stars 31 forks source link

BufferProcessError: Failed to spawn command .... #117

Closed EvanHerman closed 8 years ago

EvanHerman commented 8 years ago

I set things up this past weekend on my home computer. I am now going through and doing the same here at work.

Here at work I am hitting a wall that I did not encounter at home.

The error is as follows:

BufferedProcessError: Failed to spawn command 'C:\xampp\php\phpcs'. Make sure it's a file, not a directory, and it's executable.

Not entirely sure what's going on here. The path is exactly the same as what I have setup at home. I've gone through and performed the same steps, setup PHP_CodeSniffer, installed linter-phpcs and entered my settings.

No dice. Erors being thrown. I've also tried setting a FULL path to the file - but again, the same erorr.

I then tried double checking the file permissions - but they all appear to be correct. I'm not entirely sure what else to try at this point - any ideas?

Evan

Arcanemagus commented 8 years ago

You are probably running into the PATHEXT bug, does it work if you set the path to C:\xampp\php\phpcs.bat?

EvanHerman commented 8 years ago

Unfortunately not - I seem to be getting the same error with or without the .bat extension. I'll do some research on the PATHEXT bug.

Arcanemagus commented 8 years ago

Oh, that's just Node not respecting the PATHEXT environment setting, if you manually specified the full path with .bat that would work around that issue.

What do you get when you run where.exe phpcs?

EvanHerman commented 8 years ago

It seems to return

c:\xampp\php\phpcs
c:\xampp\php\phpcs.bat
Arcanemagus commented 8 years ago

Hmm, and what message do you get if you leave the path blank (thus using the system default of phpcs)?

EvanHerman commented 8 years ago

It looks to be a similar message, just referencing phpcs with no path:

BufferedProcessError: Failed to spawn command 'phpcs'. Make sure it's a file, not a directory, and it's executable.
    at handleError (C:\Users\user_name\.atom\packages\linter-phpcs\node_modules\atom-linter\lib\helpers.js:27:28)
    at parameters.exit (C:\Users\user_name\.atom\packages\linter-phpcs\node_modules\atom-linter\lib\helpers.js:47:15)
    at triggerExitCallback (C:\Users\user_name\AppData\Local\atom\app-1.5.4\resources\app.asar\src\buffered-process.js:213:47)
    at ChildProcess.<anonymous> (C:\Users\user_name\AppData\Local\atom\app-1.5.4\resources\app.asar\src\buffered-process.js:235:18)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
Arcanemagus commented 8 years ago

This is just bizarre.... what happens when you run C:\xampp\php\phpcs.bat in a Command Prompt?

EvanHerman commented 8 years ago

It looks like it just hangs. Nothing ever executes. I wonder if it's something that got screwed in the path or something. I can try re-installing everything from scratch again tomorrow.

Strange that things worked fine on my home computer, but here at work I ran into a few errors. Both Windows PC, one Windows 7 (home) - the other Windows 8.1 (work).

Everything else is identical.

Arcanemagus commented 8 years ago

Something definitely sounds off in your work setup if trying to run that manually hangs. Let me know how things turn out!

EvanHerman commented 8 years ago

Nothing as of yet - I'm still working through the issue. I reinstalled Atom and PHP_CodeSniffer, double checked file permissions on the directory and tried a few different paths to no success.

When I check off 'Disable when no config file', the errors do not appear - which would lead me to believe that there is no config file being found, therefore the initial errors.

Will report back here if I find any additional details.

EvanHerman commented 8 years ago

Following up once more:

I went ahead and added pear and phpcs to my environmental variables, updated my PHP_PEAR_BIN_DIR path, updated pear (pear upgrade-all), and finally restarted Atom and things seem to now be working.

For what it's worth, my PHP_PEAR_BIN_DIR environmental variable was set to .\php.exe and I updated it to the same path as my phpcs (C:\xampp\php). I think this may have been the main factor in why things were not working properly - but I can't be 100% sure.

Anyone who needs help updating environmental variables on Windows: http://www.computerhope.com/issues/ch000549.htm

Thanks again for all your help Arancemagus!

Evan

Arcanemagus commented 8 years ago

PHP_PEAR_BIN_DIR is only relevant to PEAR, Atom (and every other application...) will only search the PATH variable for where to load an executable.

(Personally I use composer instead of pear as it sets things up in a much saner manner for integrating with Windows.)

EvanHerman commented 8 years ago

Interesting - Maybe it was the environmental variable that I added. The path to that lead directly to the php directory containing both pear and phpcs (c:\xampp\php).

I'm a web/web app dev so messing with environmental variables is a bit outside my skill set :)